Allow incomplete return types in function declarations. (#3875)

Move completeness check to the point where the function is defined or
first called. This means we also defer deciding whether the function has
a return slot until that point. Instead of storing a return slot per
function, store the location of the return storage, which may or may not
be used, and compute and store a separate flag saying whether to use it
at the point of first use or definition.

This is the final piece in supporting simple `Make` functions in classes
as a replacement for constructors.
This commit is contained in:
Richard Smith
2024-04-11 07:23:56 +00:00
committed by GitHub
parent 28ceb4dd4e
commit 1b335402d1
173 changed files with 980 additions and 615 deletions
+2 -2
View File
@@ -39,10 +39,10 @@ fn G() -> i32 {
// CHECK:STDOUT: @F.%arr: [i32; 3] = bind_name arr, %arr.loc7_6.1
// CHECK:STDOUT: %i.loc7_21.1: i32 = param i
// CHECK:STDOUT: @F.%i: i32 = bind_name i, %i.loc7_21.1
// CHECK:STDOUT: %return.var.loc7: ref i32 = var <return slot>
// CHECK:STDOUT: @F.%return: ref i32 = var <return slot>
// CHECK:STDOUT: }
// CHECK:STDOUT: %G: <function> = fn_decl @G [template] {
// CHECK:STDOUT: %return.var.loc11: ref i32 = var <return slot>
// CHECK:STDOUT: @G.%return: ref i32 = var <return slot>
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT: