mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 09:44:55 +01:00
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:
+1
-1
@@ -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]
|
||||
|
||||
@@ -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: }
|
||||
|
||||
@@ -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
@@ -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: }
|
||||
|
||||
Reference in New Issue
Block a user