Skip to content

[Question][Hw7] Function Return type and return value type #57

@KAIST-JongchanPark

Description

@KAIST-JongchanPark

When I type-check, I think I need to check "return type of current function" and "type of value which will be returned".

However, when I use below function and compile it, compiler add type-casting in .ll file automatically.

int f(int x) {
  char a = 0;
  return a;
}

Therefore, I modify .ll file manually but parser throws below exception.
Fatal error: exception Dummy_llvm_irreader.Error("test/example1.ll:15:7: error: value doesn't match function result type 'i32'\n ret i8 %0\n ^\n")

Because parser throws exception for this case, we don't need to consider such case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions