mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Support for initialization of classes with abstract base classes. (#6802)
When initializing `.base` in class initialization, use `partial Base` as the destination type rather than `Base`. Treat `partial Base` as not being abstract even when `Base` is. Allow conversion from a `partial T` initializer to a `T` initializer. Store the vptr while performing the conversion. Do not store the vptr when performing a `partial T` initialization, only when performing a non-partial `T` initialization.
This commit is contained in:
+13
-6
@@ -2026,6 +2026,7 @@ fn Call(var instance: Cpp.PublicPrivate) {
|
||||
// CHECK:STDOUT: %ptr.d9e: type = ptr_type %C [concrete]
|
||||
// CHECK:STDOUT: %C__carbon_thunk.type.65f120.1: type = fn_type @C__carbon_thunk.1 [concrete]
|
||||
// CHECK:STDOUT: %C__carbon_thunk.d98342.1: %C__carbon_thunk.type.65f120.1 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %.73a: type = partial_type %C [concrete]
|
||||
// CHECK:STDOUT: %PublicCall.cpp_destructor.type: type = fn_type @PublicCall.cpp_destructor [concrete]
|
||||
// CHECK:STDOUT: %PublicCall.cpp_destructor: %PublicCall.cpp_destructor.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %ProtectedCall: type = class_type @ProtectedCall [concrete]
|
||||
@@ -2119,7 +2120,7 @@ fn Call(var instance: Cpp.PublicPrivate) {
|
||||
// CHECK:STDOUT: %addr.loc11_49: %ptr.dfa = addr_of %.loc11_49.1
|
||||
// CHECK:STDOUT: %PublicCall__carbon_thunk.call: init %empty_tuple.type = call imports.%PublicCall__carbon_thunk.decl(%addr.loc11_49)
|
||||
// CHECK:STDOUT: %.loc11_49.2: init %PublicCall to %.loc11_49.1 = mark_in_place_init %PublicCall__carbon_thunk.call
|
||||
// CHECK:STDOUT: %.loc11_51.1: ref %C = class_element_access %return.param, element0
|
||||
// CHECK:STDOUT: %.loc11_51.1: ref %.73a = class_element_access %return.param, element0
|
||||
// CHECK:STDOUT: %.loc11_49.3: ref %PublicCall = temporary %.loc11_49.1, %.loc11_49.2
|
||||
// CHECK:STDOUT: %.loc11_49.4: %PublicCall = acquire_value %.loc11_49.3
|
||||
// CHECK:STDOUT: %.loc11_49.5: ref %PublicCall = value_as_ref %.loc11_49.4
|
||||
@@ -2128,8 +2129,11 @@ fn Call(var instance: Cpp.PublicPrivate) {
|
||||
// CHECK:STDOUT: %C__carbon_thunk.call: init %empty_tuple.type = call imports.%C__carbon_thunk.decl.8acdfe.1(%addr.loc11_50.1, %addr.loc11_50.2)
|
||||
// CHECK:STDOUT: %.loc11_50: init %C to %.loc11_51.1 = mark_in_place_init %C__carbon_thunk.call
|
||||
// CHECK:STDOUT: %.loc11_51.2: %struct_type.base.7c3 = struct_literal (%.loc11_50)
|
||||
// CHECK:STDOUT: %.loc11_51.3: init %D to %return.param = class_init (%.loc11_50)
|
||||
// CHECK:STDOUT: %.loc11_52: init %D = converted %.loc11_51.2, %.loc11_51.3
|
||||
// CHECK:STDOUT: %.loc11_51.3: init %.73a = as_compatible %.loc11_50
|
||||
// CHECK:STDOUT: %.loc11_51.4: init %.73a = converted %.loc11_50, %.loc11_51.3
|
||||
// CHECK:STDOUT: %.loc11_51.5: init %C = as_compatible %.loc11_51.4
|
||||
// CHECK:STDOUT: %.loc11_51.6: init %D to %return.param = class_init (%.loc11_51.5)
|
||||
// CHECK:STDOUT: %.loc11_52: init %D = converted %.loc11_51.2, %.loc11_51.6
|
||||
// CHECK:STDOUT: %PublicCall.cpp_destructor.bound: <bound method> = bound_method %.loc11_49.3, constants.%PublicCall.cpp_destructor
|
||||
// CHECK:STDOUT: %PublicCall.cpp_destructor.call: init %empty_tuple.type = call %PublicCall.cpp_destructor.bound(%.loc11_49.3)
|
||||
// CHECK:STDOUT: return %.loc11_52 to %return.param
|
||||
@@ -2145,7 +2149,7 @@ fn Call(var instance: Cpp.PublicPrivate) {
|
||||
// CHECK:STDOUT: %addr.loc17_55: %ptr.8e6 = addr_of %.loc17_55.1
|
||||
// CHECK:STDOUT: %ProtectedCall__carbon_thunk.call: init %empty_tuple.type = call imports.%ProtectedCall__carbon_thunk.decl(%addr.loc17_55)
|
||||
// CHECK:STDOUT: %.loc17_55.2: init %ProtectedCall to %.loc17_55.1 = mark_in_place_init %ProtectedCall__carbon_thunk.call
|
||||
// CHECK:STDOUT: %.loc17_57.1: ref %C = class_element_access %return.param, element0
|
||||
// CHECK:STDOUT: %.loc17_57.1: ref %.73a = class_element_access %return.param, element0
|
||||
// CHECK:STDOUT: %.loc17_55.3: ref %ProtectedCall = temporary %.loc17_55.1, %.loc17_55.2
|
||||
// CHECK:STDOUT: %.loc17_55.4: %ProtectedCall = acquire_value %.loc17_55.3
|
||||
// CHECK:STDOUT: %.loc17_55.5: ref %ProtectedCall = value_as_ref %.loc17_55.4
|
||||
@@ -2154,8 +2158,11 @@ fn Call(var instance: Cpp.PublicPrivate) {
|
||||
// CHECK:STDOUT: %C__carbon_thunk.call: init %empty_tuple.type = call imports.%C__carbon_thunk.decl.8acdfe.2(%addr.loc17_56.1, %addr.loc17_56.2)
|
||||
// CHECK:STDOUT: %.loc17_56: init %C to %.loc17_57.1 = mark_in_place_init %C__carbon_thunk.call
|
||||
// CHECK:STDOUT: %.loc17_57.2: %struct_type.base.7c3 = struct_literal (%.loc17_56)
|
||||
// CHECK:STDOUT: %.loc17_57.3: init %D to %return.param = class_init (%.loc17_56)
|
||||
// CHECK:STDOUT: %.loc17_58: init %D = converted %.loc17_57.2, %.loc17_57.3
|
||||
// CHECK:STDOUT: %.loc17_57.3: init %.73a = as_compatible %.loc17_56
|
||||
// CHECK:STDOUT: %.loc17_57.4: init %.73a = converted %.loc17_56, %.loc17_57.3
|
||||
// CHECK:STDOUT: %.loc17_57.5: init %C = as_compatible %.loc17_57.4
|
||||
// CHECK:STDOUT: %.loc17_57.6: init %D to %return.param = class_init (%.loc17_57.5)
|
||||
// CHECK:STDOUT: %.loc17_58: init %D = converted %.loc17_57.2, %.loc17_57.6
|
||||
// CHECK:STDOUT: %ProtectedCall.cpp_destructor.bound: <bound method> = bound_method %.loc17_55.3, constants.%ProtectedCall.cpp_destructor
|
||||
// CHECK:STDOUT: %ProtectedCall.cpp_destructor.call: init %empty_tuple.type = call %ProtectedCall.cpp_destructor.bound(%.loc17_55.3)
|
||||
// CHECK:STDOUT: return %.loc17_58 to %return.param
|
||||
|
||||
Reference in New Issue
Block a user