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
+1 -1
View File
@@ -27,7 +27,7 @@ fn Main() {
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %A: <function> = fn_decl @A [template] {
// CHECK:STDOUT: %return.var: ref i32 = var <return slot>
// CHECK:STDOUT: @A.%return: ref i32 = var <return slot>
// CHECK:STDOUT: }
// CHECK:STDOUT: %A.ref: <function> = name_ref A, %A [template = %A]
// CHECK:STDOUT: %B: <function> = bind_alias B, %A [template = %A]
+1 -1
View File
@@ -34,7 +34,7 @@ fn Main() {
// CHECK:STDOUT: @Echo.%a: {} = bind_name a, %a.loc7_9.1
// CHECK:STDOUT: %.loc7_20.1: {} = struct_literal ()
// CHECK:STDOUT: %.loc7_20.2: type = converted %.loc7_20.1, constants.%.1 [template = constants.%.1]
// CHECK:STDOUT: %return.var: ref {} = var <return slot>
// CHECK:STDOUT: @Echo.%return: ref {} = var <return slot>
// CHECK:STDOUT: }
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template] {}
// CHECK:STDOUT: }
+1 -1
View File
@@ -33,7 +33,7 @@ fn Main() {
// CHECK:STDOUT: @Echo.%a: () = bind_name a, %a.loc7_9.1
// CHECK:STDOUT: %.loc7_20.1: () = tuple_literal ()
// CHECK:STDOUT: %.loc7_20.2: type = converted %.loc7_20.1, constants.%.1 [template = constants.%.1]
// CHECK:STDOUT: %return.var: ref () = var <return slot>
// CHECK:STDOUT: @Echo.%return: ref () = var <return slot>
// CHECK:STDOUT: }
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template] {}
// CHECK:STDOUT: }
@@ -27,7 +27,7 @@ fn Run() {
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template] {
// CHECK:STDOUT: %return.var: ref f64 = var <return slot>
// CHECK:STDOUT: @Foo.%return: ref f64 = var <return slot>
// CHECK:STDOUT: }
// CHECK:STDOUT: %Run: <function> = fn_decl @Run [template] {}
// CHECK:STDOUT: }
+1 -1
View File
@@ -28,7 +28,7 @@ fn Main() {
// CHECK:STDOUT: %Echo: <function> = fn_decl @Echo [template] {
// CHECK:STDOUT: %a.loc7_9.1: i32 = param a
// CHECK:STDOUT: @Echo.%a: i32 = bind_name a, %a.loc7_9.1
// CHECK:STDOUT: %return.var: ref i32 = var <return slot>
// CHECK:STDOUT: @Echo.%return: ref i32 = var <return slot>
// CHECK:STDOUT: }
// CHECK:STDOUT: %Main: <function> = fn_decl @Main [template] {}
// CHECK:STDOUT: }