mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Initial support for interop with class/struct/union fields. (#5849)
Add a new type, `custom_layout_type`, representing a struct type whose
size, alignment, and field offsets can be manually controlled. Use this
as the object representation type for imported C++ class types (which
also includes struct and union types), allowing us to model C++ class
type layouts. In passing, also add support for incomplete C++ class
types, mapping them into incomplete Carbon class types.
Map C++ fields into Carbon field declarations, allowing direct access to
C++ fields from Carbon. So far, no support is added for base classes nor
anonymous struct or union declarations; those will be added in
subsequent PRs. Also, we don't map C++ access control into Carbon yet,
so all C++ fields are accessible regardless of their access control.
For now we still use a `struct_type` as the object representation for
empty C++ classes, in order to continue to support our existing tests
that convert `{}` to empty C++ class types. This is temporary and should
be removed once we support interop with C++ class initialization.
This commit is contained in:
+66
-74
@@ -18,23 +18,32 @@
|
||||
|
||||
class Bar;
|
||||
|
||||
// --- fail_todo_import_declaration.carbon
|
||||
// --- import_declaration.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "declaration.h";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_todo_import_declaration.carbon:[[@LINE+7]]:13: error: semantics TODO: `Unsupported: Record declarations without a definition` [SemanticsTodo]
|
||||
// CHECK:STDERR: fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR: fail_todo_import_declaration.carbon:[[@LINE+4]]:13: note: in `Cpp` name lookup for `Bar` [InCppNameLookup]
|
||||
// CHECK:STDERR: fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn MyF(bar: Cpp.Bar*);
|
||||
//@dump-sem-ir-end
|
||||
|
||||
// --- fail_use_declaration_as_definition.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "declaration.h";
|
||||
|
||||
fn MyF() {
|
||||
// CHECK:STDERR: fail_use_declaration_as_definition.carbon:[[@LINE+6]]:12: error: binding pattern has incomplete type `Bar` in name binding declaration [IncompleteTypeInBindingDecl]
|
||||
// CHECK:STDERR: var bar: Cpp.Bar;
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR: fail_use_declaration_as_definition.carbon:[[@LINE-6]]:1: in import [InImport]
|
||||
// CHECK:STDERR: ./declaration.h:2: note: class was forward declared here [ClassForwardDeclaredHere]
|
||||
// CHECK:STDERR:
|
||||
var bar: Cpp.Bar;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Definition
|
||||
// ============================================================================
|
||||
@@ -158,28 +167,17 @@ fn MyF() {
|
||||
|
||||
class Bar {
|
||||
public:
|
||||
Bar* foo;
|
||||
Bar* _Nonnull foo;
|
||||
};
|
||||
|
||||
// --- fail_todo_import_public_data_member.carbon
|
||||
// --- import_public_data_member.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "public_static_data_member.h";
|
||||
import Cpp library "public_data_member.h";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
fn MyF(bar : Cpp.Bar*) {
|
||||
// CHECK:STDERR: fail_todo_import_public_data_member.carbon:[[@LINE+11]]:27: error: semantics TODO: `Unsupported: Declaration type Var` [SemanticsTodo]
|
||||
// CHECK:STDERR: let foo_bar: Cpp.Bar* = bar->foo;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_import_public_data_member.carbon:[[@LINE+8]]:27: note: in `Cpp` name lookup for `foo` [InCppNameLookup]
|
||||
// CHECK:STDERR: let foo_bar: Cpp.Bar* = bar->foo;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_import_public_data_member.carbon:[[@LINE+4]]:27: error: member name `foo` not found in `Cpp.Bar` [MemberNameNotFoundInInstScope]
|
||||
// CHECK:STDERR: let foo_bar: Cpp.Bar* = bar->foo;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
let foo_bar: Cpp.Bar* = bar->foo;
|
||||
}
|
||||
//@dump-sem-ir-end
|
||||
@@ -230,7 +228,7 @@ library "[[@TEST_NAME]]";
|
||||
import Cpp library "inheritance_pointers.h";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
fn MyF1(bar : Cpp.Bar1*);
|
||||
fn MyF1(bar: Cpp.Bar1*);
|
||||
// TODO: Support C++ inheritance.
|
||||
// CHECK:STDERR: fail_todo_import_inheritance_pointers.carbon:[[@LINE+10]]:33: error: cannot implicitly convert expression of type `Cpp.Bar2*` to `Cpp.Bar1*` [ConversionFailure]
|
||||
// CHECK:STDERR: fn MyF2(bar : Cpp.Bar2*) { MyF1(bar); }
|
||||
@@ -239,8 +237,8 @@ fn MyF1(bar : Cpp.Bar1*);
|
||||
// CHECK:STDERR: fn MyF2(bar : Cpp.Bar2*) { MyF1(bar); }
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR: fail_todo_import_inheritance_pointers.carbon:[[@LINE-8]]:9: note: initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: fn MyF1(bar : Cpp.Bar1*);
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fn MyF1(bar: Cpp.Bar1*);
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn MyF2(bar : Cpp.Bar2*) { MyF1(bar); }
|
||||
//@dump-sem-ir-end
|
||||
@@ -256,21 +254,14 @@ class Bar {
|
||||
virtual ~Bar();
|
||||
};
|
||||
|
||||
// --- fail_todo_import_dynamic.carbon
|
||||
// --- import_dynamic.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "dynamic.h";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_todo_import_dynamic.carbon:[[@LINE+7]]:14: error: semantics TODO: `Unsupported: Dynamic Class` [SemanticsTodo]
|
||||
// CHECK:STDERR: fn MyF(bar : Cpp.Bar*);
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR: fail_todo_import_dynamic.carbon:[[@LINE+4]]:14: note: in `Cpp` name lookup for `Bar` [InCppNameLookup]
|
||||
// CHECK:STDERR: fn MyF(bar : Cpp.Bar*);
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn MyF(bar : Cpp.Bar*);
|
||||
fn MyF(bar: Cpp.Bar*);
|
||||
//@dump-sem-ir-end
|
||||
|
||||
// ============================================================================
|
||||
@@ -355,36 +346,40 @@ import Cpp library "template.h";
|
||||
fn MyF(bar: Cpp.Bar*);
|
||||
//@dump-sem-ir-end
|
||||
|
||||
// CHECK:STDOUT: --- fail_todo_import_declaration.carbon
|
||||
// CHECK:STDOUT: --- import_declaration.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Bar: type = class_type @Bar [concrete]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar [concrete]
|
||||
// CHECK:STDOUT: %pattern_type: type = pattern_type %ptr [concrete]
|
||||
// CHECK:STDOUT: %MyF.type: type = fn_type @MyF [concrete]
|
||||
// CHECK:STDOUT: %MyF: %MyF.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
|
||||
// CHECK:STDOUT: .Bar = <error>
|
||||
// CHECK:STDOUT: .Bar = %Bar.decl
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Bar.decl: type = class_decl @Bar [concrete = constants.%Bar] {} {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: %MyF.decl: %MyF.type = fn_decl @MyF [concrete = constants.%MyF] {
|
||||
// CHECK:STDOUT: %bar.patt: <error> = binding_pattern bar [concrete]
|
||||
// CHECK:STDOUT: %bar.param_patt: <error> = value_param_pattern %bar.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %bar.patt: %pattern_type = binding_pattern bar [concrete]
|
||||
// CHECK:STDOUT: %bar.param_patt: %pattern_type = value_param_pattern %bar.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %bar.param: <error> = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc14: type = splice_block %ptr [concrete = <error>] {
|
||||
// CHECK:STDOUT: %bar.param: %ptr = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Bar.ref: <error> = name_ref Bar, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %bar: <error> = bind_name bar, %bar.param
|
||||
// CHECK:STDOUT: %bar: %ptr = bind_name bar, %bar.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @MyF(%bar.param: <error>);
|
||||
// CHECK:STDOUT: fn @MyF(%bar.param: %ptr);
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- import_definition.carbon
|
||||
// CHECK:STDOUT:
|
||||
@@ -412,7 +407,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %bar.param: %ptr = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -448,7 +442,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %bar.param: %ptr = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -479,7 +472,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: fn @MyF() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %foo.ref: %Bar.foo.type = name_ref foo, imports.%Bar.foo.decl [concrete = constants.%Bar.foo]
|
||||
// CHECK:STDOUT: %Bar.foo.call: init %empty_tuple.type = call %foo.ref()
|
||||
@@ -512,7 +504,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc19: type = splice_block %ptr [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc19_12: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref.loc19_15: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref.loc19_15 [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -520,11 +511,12 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_todo_import_public_data_member.carbon
|
||||
// CHECK:STDOUT: --- import_public_data_member.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Bar: type = class_type @Bar [concrete]
|
||||
// CHECK:STDOUT: %ptr.f68: type = ptr_type %Bar [concrete]
|
||||
// CHECK:STDOUT: %Bar.elem: type = unbound_element_type %Bar, %ptr.f68 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type: type = pattern_type %ptr.f68 [concrete]
|
||||
// CHECK:STDOUT: %MyF.type: type = fn_type @MyF [concrete]
|
||||
// CHECK:STDOUT: %MyF: %MyF.type = struct_value () [concrete]
|
||||
@@ -546,7 +538,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %bar.param: %ptr.f68 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr.loc7 [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc7: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref.loc7: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr.loc7: type = ptr_type %Bar.ref.loc7 [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -560,14 +551,16 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %foo_bar.patt: %pattern_type = binding_pattern foo_bar [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %bar.ref: %ptr.f68 = name_ref bar, %bar
|
||||
// CHECK:STDOUT: %.loc19_30: ref %Bar = deref %bar.ref
|
||||
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc19_23: type = splice_block %ptr.loc19 [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc19: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Bar.ref.loc19: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr.loc19: type = ptr_type %Bar.ref.loc19 [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: %.loc8_30.1: ref %Bar = deref %bar.ref
|
||||
// CHECK:STDOUT: %foo.ref: %Bar.elem = name_ref foo, @Bar.%.1 [concrete = @Bar.%.1]
|
||||
// CHECK:STDOUT: %.loc8_30.2: ref %ptr.f68 = class_element_access %.loc8_30.1, element0
|
||||
// CHECK:STDOUT: %.loc8_23: type = splice_block %ptr.loc8 [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Bar.ref.loc8: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr.loc8: type = ptr_type %Bar.ref.loc8 [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %foo_bar: %ptr.f68 = bind_name foo_bar, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc8_30.3: %ptr.f68 = bind_value %.loc8_30.2
|
||||
// CHECK:STDOUT: %foo_bar: %ptr.f68 = bind_name foo_bar, %.loc8_30.3
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -598,12 +591,10 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: fn @MyF() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar1.ref: type = name_ref Bar1, imports.%Bar1.decl [concrete = constants.%Bar1]
|
||||
// CHECK:STDOUT: %foo1.ref.loc8: %Bar1.foo1.type = name_ref foo1, imports.%Bar1.foo1.decl [concrete = constants.%Bar1.foo1]
|
||||
// CHECK:STDOUT: %Bar1.foo1.call.loc8: init %empty_tuple.type = call %foo1.ref.loc8()
|
||||
// CHECK:STDOUT: %Cpp.ref.loc9: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar2.ref.loc9: type = name_ref Bar2, imports.%Bar2.decl [concrete = constants.%Bar2]
|
||||
// CHECK:STDOUT: %foo1.ref.loc9: %Bar1.foo1.type = name_ref foo1, imports.%Bar1.foo1.decl [concrete = constants.%Bar1.foo1]
|
||||
// CHECK:STDOUT: %Bar1.foo1.call.loc9: init %empty_tuple.type = call %foo1.ref.loc9()
|
||||
@@ -648,7 +639,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %bar.param: %ptr.f68 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar1.ref: type = name_ref Bar1, imports.%Bar1.decl [concrete = constants.%Bar1]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar1.ref [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -661,7 +651,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %bar.param: %ptr.eca = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc19_23: type = splice_block %ptr [concrete = constants.%ptr.eca] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar2.ref: type = name_ref Bar2, imports.%Bar2.decl [concrete = constants.%Bar2]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar2.ref [concrete = constants.%ptr.eca]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -680,36 +669,40 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_todo_import_dynamic.carbon
|
||||
// CHECK:STDOUT: --- import_dynamic.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Bar: type = class_type @Bar [concrete]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar [concrete]
|
||||
// CHECK:STDOUT: %pattern_type: type = pattern_type %ptr [concrete]
|
||||
// CHECK:STDOUT: %MyF.type: type = fn_type @MyF [concrete]
|
||||
// CHECK:STDOUT: %MyF: %MyF.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
|
||||
// CHECK:STDOUT: .Bar = <error>
|
||||
// CHECK:STDOUT: .Bar = %Bar.decl
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Bar.decl: type = class_decl @Bar [concrete = constants.%Bar] {} {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: %MyF.decl: %MyF.type = fn_decl @MyF [concrete = constants.%MyF] {
|
||||
// CHECK:STDOUT: %bar.patt: <error> = binding_pattern bar [concrete]
|
||||
// CHECK:STDOUT: %bar.param_patt: <error> = value_param_pattern %bar.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %bar.patt: %pattern_type = binding_pattern bar [concrete]
|
||||
// CHECK:STDOUT: %bar.param_patt: %pattern_type = value_param_pattern %bar.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %bar.param: <error> = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc14: type = splice_block %ptr [concrete = <error>] {
|
||||
// CHECK:STDOUT: %bar.param: %ptr = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Bar.ref: <error> = name_ref Bar, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %bar: <error> = bind_name bar, %bar.param
|
||||
// CHECK:STDOUT: %bar: %ptr = bind_name bar, %bar.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @MyF(%bar.param: <error>);
|
||||
// CHECK:STDOUT: fn @MyF(%bar.param: %ptr);
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- import_to_inherit_public.carbon
|
||||
// CHECK:STDOUT:
|
||||
@@ -742,12 +735,11 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @Derived {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %.loc8: %Derived.elem = base_decl %Bar.ref, element0 [concrete]
|
||||
// CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %Bar} [concrete = constants.%struct_type.base.36d]
|
||||
// CHECK:STDOUT: %complete_type.loc9: <witness> = complete_type_witness %struct_type.base [concrete = constants.%complete_type.fff]
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type.loc9
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [concrete = constants.%complete_type.fff]
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%Derived
|
||||
|
||||
@@ -0,0 +1,670 @@
|
||||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/primitives.carbon
|
||||
// EXTRA-ARGS: --dump-sem-ir-ranges=ignore
|
||||
//
|
||||
// AUTOUPDATE
|
||||
// TIP: To test this file alone, run:
|
||||
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/class/field.carbon
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/class/field.carbon
|
||||
|
||||
// --- struct.h
|
||||
|
||||
struct Struct {
|
||||
int a;
|
||||
int b;
|
||||
int* _Nonnull p;
|
||||
};
|
||||
|
||||
// --- use_struct_fields.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "struct.h";
|
||||
|
||||
fn F(s: Cpp.Struct) -> (i32, i32, i32) {
|
||||
//@dump-sem-ir-begin
|
||||
return (s.a, s.b, *s.p);
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
// --- union.h
|
||||
|
||||
union Union {
|
||||
int a;
|
||||
int b;
|
||||
int* _Nonnull p;
|
||||
};
|
||||
|
||||
// --- use_union_fields.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "union.h";
|
||||
|
||||
fn F(u: Cpp.Union) -> i32 {
|
||||
//@dump-sem-ir-begin
|
||||
return u.a;
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
fn G(u: Cpp.Union) -> i32 {
|
||||
//@dump-sem-ir-begin
|
||||
return u.b;
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
fn H(u: Cpp.Union) -> i32 {
|
||||
//@dump-sem-ir-begin
|
||||
return *u.p;
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
// --- with_bitfields.h
|
||||
|
||||
struct Struct {
|
||||
int a;
|
||||
int b : 2;
|
||||
};
|
||||
|
||||
union Union {
|
||||
int c;
|
||||
int d : 3;
|
||||
};
|
||||
|
||||
// --- use_non_bitfields_in_type_with_bitfields.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "with_bitfields.h";
|
||||
|
||||
fn F(s: Cpp.Struct) -> i32 {
|
||||
//@dump-sem-ir-begin
|
||||
return s.a;
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
fn G(s: Cpp.Union) -> i32 {
|
||||
//@dump-sem-ir-begin
|
||||
return s.c;
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
// --- fail_todo_use_bitfields.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "with_bitfields.h";
|
||||
|
||||
fn F(s: Cpp.Struct) -> i32 {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_todo_use_bitfields.carbon:[[@LINE+11]]:10: error: semantics TODO: `Unsupported: Unhandled kind of field declaration` [SemanticsTodo]
|
||||
// CHECK:STDERR: return s.b;
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR: fail_todo_use_bitfields.carbon:[[@LINE+8]]:10: note: in `Cpp` name lookup for `b` [InCppNameLookup]
|
||||
// CHECK:STDERR: return s.b;
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_use_bitfields.carbon:[[@LINE+4]]:10: error: member name `b` not found in `Cpp.Struct` [MemberNameNotFoundInInstScope]
|
||||
// CHECK:STDERR: return s.b;
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR:
|
||||
return s.b;
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
fn G(s: Cpp.Union) -> i32 {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_todo_use_bitfields.carbon:[[@LINE+11]]:10: error: semantics TODO: `Unsupported: Unhandled kind of field declaration` [SemanticsTodo]
|
||||
// CHECK:STDERR: return s.d;
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR: fail_todo_use_bitfields.carbon:[[@LINE+8]]:10: note: in `Cpp` name lookup for `d` [InCppNameLookup]
|
||||
// CHECK:STDERR: return s.d;
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_use_bitfields.carbon:[[@LINE+4]]:10: error: member name `d` not found in `Cpp.Union` [MemberNameNotFoundInInstScope]
|
||||
// CHECK:STDERR: return s.d;
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR:
|
||||
return s.d;
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
// CHECK:STDOUT: --- use_struct_fields.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Struct: type = class_type @Struct [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
|
||||
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %Struct.elem.86b: type = unbound_element_type %Struct, %i32 [concrete]
|
||||
// CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [concrete]
|
||||
// CHECK:STDOUT: %Struct.elem.765: type = unbound_element_type %Struct, %ptr.235 [concrete]
|
||||
// CHECK:STDOUT: %.550: type = custom_layout_type {size=16, align=8, .a@0: %i32, .b@4: %i32, .p@8: %ptr.235} [concrete]
|
||||
// CHECK:STDOUT: %complete_type.8cf: <witness> = complete_type_witness %.550 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.60c: type = pattern_type %Struct [concrete]
|
||||
// CHECK:STDOUT: %tuple.type.ff9: type = tuple_type (type, type, type) [concrete]
|
||||
// CHECK:STDOUT: %tuple.type.189: type = tuple_type (%i32, %i32, %i32) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.b5a: type = pattern_type %tuple.type.189 [concrete]
|
||||
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
|
||||
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
|
||||
// CHECK:STDOUT: .Int = %Core.Int
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
|
||||
// CHECK:STDOUT: .Struct = %Struct.decl
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Struct.decl: type = class_decl @Struct [concrete = constants.%Struct] {} {}
|
||||
// CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .Cpp = imports.%Cpp
|
||||
// CHECK:STDOUT: .F = %F.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
|
||||
// CHECK:STDOUT: import Cpp "struct.h"
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
|
||||
// CHECK:STDOUT: %s.patt: %pattern_type.60c = binding_pattern s [concrete]
|
||||
// CHECK:STDOUT: %s.param_patt: %pattern_type.60c = value_param_pattern %s.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %return.patt: %pattern_type.b5a = return_slot_pattern [concrete]
|
||||
// CHECK:STDOUT: %return.param_patt: %pattern_type.b5a = out_param_pattern %return.patt, call_param1 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %int_32.loc6_25: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc6_25: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %int_32.loc6_30: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc6_30: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %int_32.loc6_35: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc6_35: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.loc6_38.1: %tuple.type.ff9 = tuple_literal (%i32.loc6_25, %i32.loc6_30, %i32.loc6_35)
|
||||
// CHECK:STDOUT: %.loc6_38.2: type = converted %.loc6_38.1, constants.%tuple.type.189 [concrete = constants.%tuple.type.189]
|
||||
// CHECK:STDOUT: %s.param: %Struct = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc6_12: type = splice_block %Struct.ref [concrete = constants.%Struct] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Struct.ref: type = name_ref Struct, imports.%Struct.decl [concrete = constants.%Struct]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %s: %Struct = bind_name s, %s.param
|
||||
// CHECK:STDOUT: %return.param: ref %tuple.type.189 = out_param call_param1
|
||||
// CHECK:STDOUT: %return: ref %tuple.type.189 = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @Struct {
|
||||
// CHECK:STDOUT: %int_32.1: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.1: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.1: %Struct.elem.86b = field_decl a, element0 [concrete]
|
||||
// CHECK:STDOUT: %int_32.2: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.2: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.2: %Struct.elem.86b = field_decl b, element1 [concrete]
|
||||
// CHECK:STDOUT: %int_32.3: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.3: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.3: %Struct.elem.765 = field_decl p, element2 [concrete]
|
||||
// CHECK:STDOUT: %.4: type = custom_layout_type {size=16, align=8, .a@0: %i32, .b@4: %i32, .p@8: %ptr.235} [concrete = constants.%.550]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %.4 [concrete = constants.%complete_type.8cf]
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%Struct
|
||||
// CHECK:STDOUT: .a = %.1
|
||||
// CHECK:STDOUT: .b = %.2
|
||||
// CHECK:STDOUT: .p = %.3
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @F(%s.param: %Struct) -> %return.param: %tuple.type.189 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %s.ref.loc8_11: %Struct = name_ref s, %s
|
||||
// CHECK:STDOUT: %a.ref: %Struct.elem.86b = name_ref a, @Struct.%.1 [concrete = @Struct.%.1]
|
||||
// CHECK:STDOUT: %.loc8_12.1: ref %i32 = class_element_access %s.ref.loc8_11, element0
|
||||
// CHECK:STDOUT: %.loc8_12.2: %i32 = bind_value %.loc8_12.1
|
||||
// CHECK:STDOUT: %s.ref.loc8_16: %Struct = name_ref s, %s
|
||||
// CHECK:STDOUT: %b.ref: %Struct.elem.86b = name_ref b, @Struct.%.2 [concrete = @Struct.%.2]
|
||||
// CHECK:STDOUT: %.loc8_17.1: ref %i32 = class_element_access %s.ref.loc8_16, element1
|
||||
// CHECK:STDOUT: %.loc8_17.2: %i32 = bind_value %.loc8_17.1
|
||||
// CHECK:STDOUT: %s.ref.loc8_22: %Struct = name_ref s, %s
|
||||
// CHECK:STDOUT: %p.ref: %Struct.elem.765 = name_ref p, @Struct.%.3 [concrete = @Struct.%.3]
|
||||
// CHECK:STDOUT: %.loc8_23.1: ref %ptr.235 = class_element_access %s.ref.loc8_22, element2
|
||||
// CHECK:STDOUT: %.loc8_23.2: %ptr.235 = bind_value %.loc8_23.1
|
||||
// CHECK:STDOUT: %.loc8_21.1: ref %i32 = deref %.loc8_23.2
|
||||
// CHECK:STDOUT: %.loc8_25.1: %tuple.type.189 = tuple_literal (%.loc8_12.2, %.loc8_17.2, %.loc8_21.1)
|
||||
// CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %return, element0
|
||||
// CHECK:STDOUT: %.loc8_25.2: init %i32 = initialize_from %.loc8_12.2 to %tuple.elem0
|
||||
// CHECK:STDOUT: %tuple.elem1: ref %i32 = tuple_access %return, element1
|
||||
// CHECK:STDOUT: %.loc8_25.3: init %i32 = initialize_from %.loc8_17.2 to %tuple.elem1
|
||||
// CHECK:STDOUT: %.loc8_21.2: %i32 = bind_value %.loc8_21.1
|
||||
// CHECK:STDOUT: %tuple.elem2: ref %i32 = tuple_access %return, element2
|
||||
// CHECK:STDOUT: %.loc8_25.4: init %i32 = initialize_from %.loc8_21.2 to %tuple.elem2
|
||||
// CHECK:STDOUT: %.loc8_25.5: init %tuple.type.189 = tuple_init (%.loc8_25.2, %.loc8_25.3, %.loc8_25.4) to %return
|
||||
// CHECK:STDOUT: %.loc8_26: init %tuple.type.189 = converted %.loc8_25.1, %.loc8_25.5
|
||||
// CHECK:STDOUT: return %.loc8_26 to %return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- use_union_fields.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Union: type = class_type @Union [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
|
||||
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %Union.elem.041: type = unbound_element_type %Union, %i32 [concrete]
|
||||
// CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [concrete]
|
||||
// CHECK:STDOUT: %Union.elem.92a: type = unbound_element_type %Union, %ptr.235 [concrete]
|
||||
// CHECK:STDOUT: %.c84: type = custom_layout_type {size=8, align=8, .a@0: %i32, .b@0: %i32, .p@0: %ptr.235} [concrete]
|
||||
// CHECK:STDOUT: %complete_type.1b0: <witness> = complete_type_witness %.c84 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.a90: type = pattern_type %Union [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
|
||||
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
|
||||
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
|
||||
// CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %H.type: type = fn_type @H [concrete]
|
||||
// CHECK:STDOUT: %H: %H.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
|
||||
// CHECK:STDOUT: .Int = %Core.Int
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
|
||||
// CHECK:STDOUT: .Union = %Union.decl
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Union.decl: type = class_decl @Union [concrete = constants.%Union] {} {}
|
||||
// CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .Cpp = imports.%Cpp
|
||||
// CHECK:STDOUT: .F = %F.decl
|
||||
// CHECK:STDOUT: .G = %G.decl
|
||||
// CHECK:STDOUT: .H = %H.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
|
||||
// CHECK:STDOUT: import Cpp "union.h"
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
|
||||
// CHECK:STDOUT: %u.patt: %pattern_type.a90 = binding_pattern u [concrete]
|
||||
// CHECK:STDOUT: %u.param_patt: %pattern_type.a90 = value_param_pattern %u.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
|
||||
// CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %u.param: %Union = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc6: type = splice_block %Union.ref [concrete = constants.%Union] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Union.ref: type = name_ref Union, imports.%Union.decl [concrete = constants.%Union]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %u: %Union = bind_name u, %u.param
|
||||
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
|
||||
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
|
||||
// CHECK:STDOUT: %u.patt: %pattern_type.a90 = binding_pattern u [concrete]
|
||||
// CHECK:STDOUT: %u.param_patt: %pattern_type.a90 = value_param_pattern %u.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
|
||||
// CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %u.param: %Union = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc12: type = splice_block %Union.ref [concrete = constants.%Union] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Union.ref: type = name_ref Union, imports.%Union.decl [concrete = constants.%Union]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %u: %Union = bind_name u, %u.param
|
||||
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
|
||||
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [concrete = constants.%H] {
|
||||
// CHECK:STDOUT: %u.patt: %pattern_type.a90 = binding_pattern u [concrete]
|
||||
// CHECK:STDOUT: %u.param_patt: %pattern_type.a90 = value_param_pattern %u.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
|
||||
// CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %u.param: %Union = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc18: type = splice_block %Union.ref [concrete = constants.%Union] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Union.ref: type = name_ref Union, imports.%Union.decl [concrete = constants.%Union]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %u: %Union = bind_name u, %u.param
|
||||
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
|
||||
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @Union {
|
||||
// CHECK:STDOUT: %int_32.1: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.1: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.1: %Union.elem.041 = field_decl a, element0 [concrete]
|
||||
// CHECK:STDOUT: %int_32.2: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.2: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.2: %Union.elem.041 = field_decl b, element1 [concrete]
|
||||
// CHECK:STDOUT: %int_32.3: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.3: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.3: %Union.elem.92a = field_decl p, element2 [concrete]
|
||||
// CHECK:STDOUT: %.4: type = custom_layout_type {size=8, align=8, .a@0: %i32, .b@0: %i32, .p@0: %ptr.235} [concrete = constants.%.c84]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %.4 [concrete = constants.%complete_type.1b0]
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%Union
|
||||
// CHECK:STDOUT: .a = %.1
|
||||
// CHECK:STDOUT: .b = %.2
|
||||
// CHECK:STDOUT: .p = %.3
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @F(%u.param: %Union) -> %i32 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %u.ref: %Union = name_ref u, %u
|
||||
// CHECK:STDOUT: %a.ref: %Union.elem.041 = name_ref a, @Union.%.1 [concrete = @Union.%.1]
|
||||
// CHECK:STDOUT: %.loc8_11.1: ref %i32 = class_element_access %u.ref, element0
|
||||
// CHECK:STDOUT: %.loc8_11.2: %i32 = bind_value %.loc8_11.1
|
||||
// CHECK:STDOUT: return %.loc8_11.2
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @G(%u.param: %Union) -> %i32 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %u.ref: %Union = name_ref u, %u
|
||||
// CHECK:STDOUT: %b.ref: %Union.elem.041 = name_ref b, @Union.%.2 [concrete = @Union.%.2]
|
||||
// CHECK:STDOUT: %.loc14_11.1: ref %i32 = class_element_access %u.ref, element1
|
||||
// CHECK:STDOUT: %.loc14_11.2: %i32 = bind_value %.loc14_11.1
|
||||
// CHECK:STDOUT: return %.loc14_11.2
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @H(%u.param: %Union) -> %i32 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %u.ref: %Union = name_ref u, %u
|
||||
// CHECK:STDOUT: %p.ref: %Union.elem.92a = name_ref p, @Union.%.3 [concrete = @Union.%.3]
|
||||
// CHECK:STDOUT: %.loc20_12.1: ref %ptr.235 = class_element_access %u.ref, element2
|
||||
// CHECK:STDOUT: %.loc20_12.2: %ptr.235 = bind_value %.loc20_12.1
|
||||
// CHECK:STDOUT: %.loc20_10.1: ref %i32 = deref %.loc20_12.2
|
||||
// CHECK:STDOUT: %.loc20_10.2: %i32 = bind_value %.loc20_10.1
|
||||
// CHECK:STDOUT: return %.loc20_10.2
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- use_non_bitfields_in_type_with_bitfields.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Struct: type = class_type @Struct [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
|
||||
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %Struct.elem: type = unbound_element_type %Struct, %i32 [concrete]
|
||||
// CHECK:STDOUT: %.f9e: type = custom_layout_type {size=8, align=4, .a@0: %i32} [concrete]
|
||||
// CHECK:STDOUT: %complete_type.d3c: <witness> = complete_type_witness %.f9e [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.60c: type = pattern_type %Struct [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
|
||||
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
|
||||
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Union: type = class_type @Union [concrete]
|
||||
// CHECK:STDOUT: %Union.elem: type = unbound_element_type %Union, %i32 [concrete]
|
||||
// CHECK:STDOUT: %.891: type = custom_layout_type {size=4, align=4, .c@0: %i32} [concrete]
|
||||
// CHECK:STDOUT: %complete_type.591: <witness> = complete_type_witness %.891 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.a90: type = pattern_type %Union [concrete]
|
||||
// CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
|
||||
// CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
|
||||
// CHECK:STDOUT: .Int = %Core.Int
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
|
||||
// CHECK:STDOUT: .Struct = %Struct.decl
|
||||
// CHECK:STDOUT: .Union = %Union.decl
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Struct.decl: type = class_decl @Struct [concrete = constants.%Struct] {} {}
|
||||
// CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
|
||||
// CHECK:STDOUT: %Union.decl: type = class_decl @Union [concrete = constants.%Union] {} {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .Cpp = imports.%Cpp
|
||||
// CHECK:STDOUT: .F = %F.decl
|
||||
// CHECK:STDOUT: .G = %G.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
|
||||
// CHECK:STDOUT: import Cpp "with_bitfields.h"
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
|
||||
// CHECK:STDOUT: %s.patt: %pattern_type.60c = binding_pattern s [concrete]
|
||||
// CHECK:STDOUT: %s.param_patt: %pattern_type.60c = value_param_pattern %s.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
|
||||
// CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %s.param: %Struct = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc6: type = splice_block %Struct.ref [concrete = constants.%Struct] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Struct.ref: type = name_ref Struct, imports.%Struct.decl [concrete = constants.%Struct]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %s: %Struct = bind_name s, %s.param
|
||||
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
|
||||
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
|
||||
// CHECK:STDOUT: %s.patt: %pattern_type.a90 = binding_pattern s [concrete]
|
||||
// CHECK:STDOUT: %s.param_patt: %pattern_type.a90 = value_param_pattern %s.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
|
||||
// CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %s.param: %Union = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc12: type = splice_block %Union.ref [concrete = constants.%Union] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Union.ref: type = name_ref Union, imports.%Union.decl [concrete = constants.%Union]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %s: %Union = bind_name s, %s.param
|
||||
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
|
||||
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @Struct {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.1: %Struct.elem = field_decl a, element0 [concrete]
|
||||
// CHECK:STDOUT: %.2: type = custom_layout_type {size=8, align=4, .a@0: %i32} [concrete = constants.%.f9e]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %.2 [concrete = constants.%complete_type.d3c]
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%Struct
|
||||
// CHECK:STDOUT: .a = %.1
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @Union {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.1: %Union.elem = field_decl c, element0 [concrete]
|
||||
// CHECK:STDOUT: %.2: type = custom_layout_type {size=4, align=4, .c@0: %i32} [concrete = constants.%.891]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %.2 [concrete = constants.%complete_type.591]
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%Union
|
||||
// CHECK:STDOUT: .c = %.1
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @F(%s.param: %Struct) -> %i32 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %s.ref: %Struct = name_ref s, %s
|
||||
// CHECK:STDOUT: %a.ref: %Struct.elem = name_ref a, @Struct.%.1 [concrete = @Struct.%.1]
|
||||
// CHECK:STDOUT: %.loc8_11.1: ref %i32 = class_element_access %s.ref, element0
|
||||
// CHECK:STDOUT: %.loc8_11.2: %i32 = bind_value %.loc8_11.1
|
||||
// CHECK:STDOUT: return %.loc8_11.2
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @G(%s.param: %Union) -> %i32 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %s.ref: %Union = name_ref s, %s
|
||||
// CHECK:STDOUT: %c.ref: %Union.elem = name_ref c, @Union.%.1 [concrete = @Union.%.1]
|
||||
// CHECK:STDOUT: %.loc14_11.1: ref %i32 = class_element_access %s.ref, element0
|
||||
// CHECK:STDOUT: %.loc14_11.2: %i32 = bind_value %.loc14_11.1
|
||||
// CHECK:STDOUT: return %.loc14_11.2
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_todo_use_bitfields.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Struct: type = class_type @Struct [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
|
||||
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
// CHECK:STDOUT: %Struct.elem: type = unbound_element_type %Struct, %i32 [concrete]
|
||||
// CHECK:STDOUT: %.f9e: type = custom_layout_type {size=8, align=4, .a@0: %i32} [concrete]
|
||||
// CHECK:STDOUT: %complete_type.d3c: <witness> = complete_type_witness %.f9e [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.60c: type = pattern_type %Struct [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
|
||||
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
|
||||
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Union: type = class_type @Union [concrete]
|
||||
// CHECK:STDOUT: %Union.elem: type = unbound_element_type %Union, %i32 [concrete]
|
||||
// CHECK:STDOUT: %.891: type = custom_layout_type {size=4, align=4, .c@0: %i32} [concrete]
|
||||
// CHECK:STDOUT: %complete_type.591: <witness> = complete_type_witness %.891 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.a90: type = pattern_type %Union [concrete]
|
||||
// CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
|
||||
// CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
|
||||
// CHECK:STDOUT: .Int = %Core.Int
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
|
||||
// CHECK:STDOUT: .Struct = %Struct.decl
|
||||
// CHECK:STDOUT: .Union = %Union.decl
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Struct.decl: type = class_decl @Struct [concrete = constants.%Struct] {} {}
|
||||
// CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
|
||||
// CHECK:STDOUT: %Union.decl: type = class_decl @Union [concrete = constants.%Union] {} {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .Cpp = imports.%Cpp
|
||||
// CHECK:STDOUT: .F = %F.decl
|
||||
// CHECK:STDOUT: .G = %G.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
|
||||
// CHECK:STDOUT: import Cpp "with_bitfields.h"
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
|
||||
// CHECK:STDOUT: %s.patt: %pattern_type.60c = binding_pattern s [concrete]
|
||||
// CHECK:STDOUT: %s.param_patt: %pattern_type.60c = value_param_pattern %s.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
|
||||
// CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %s.param: %Struct = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc6: type = splice_block %Struct.ref [concrete = constants.%Struct] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Struct.ref: type = name_ref Struct, imports.%Struct.decl [concrete = constants.%Struct]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %s: %Struct = bind_name s, %s.param
|
||||
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
|
||||
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
|
||||
// CHECK:STDOUT: %s.patt: %pattern_type.a90 = binding_pattern s [concrete]
|
||||
// CHECK:STDOUT: %s.param_patt: %pattern_type.a90 = value_param_pattern %s.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
|
||||
// CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %s.param: %Union = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc23: type = splice_block %Union.ref [concrete = constants.%Union] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Union.ref: type = name_ref Union, imports.%Union.decl [concrete = constants.%Union]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %s: %Union = bind_name s, %s.param
|
||||
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
|
||||
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @Struct {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.1: %Struct.elem = field_decl a, element0 [concrete]
|
||||
// CHECK:STDOUT: %.2: type = custom_layout_type {size=8, align=4, .a@0: %i32} [concrete = constants.%.f9e]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %.2 [concrete = constants.%complete_type.d3c]
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%Struct
|
||||
// CHECK:STDOUT: .b = <poisoned>
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @Union {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.1: %Union.elem = field_decl c, element0 [concrete]
|
||||
// CHECK:STDOUT: %.2: type = custom_layout_type {size=4, align=4, .c@0: %i32} [concrete = constants.%.891]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %.2 [concrete = constants.%complete_type.591]
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%Union
|
||||
// CHECK:STDOUT: .d = <poisoned>
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @F(%s.param: %Struct) -> %i32 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %s.ref: %Struct = name_ref s, %s
|
||||
// CHECK:STDOUT: %b.ref: <error> = name_ref b, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: return <error>
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @G(%s.param: %Union) -> %i32 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %s.ref: %Union = name_ref s, %s
|
||||
// CHECK:STDOUT: %d.ref: <error> = name_ref d, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: return <error>
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
+12
-12
@@ -226,8 +226,6 @@ fn Ref(p: Cpp.HasQualifiers*) {
|
||||
// CHECK:STDOUT: %v.param: %HasQualifiers = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc6_12: type = splice_block %HasQualifiers.ref.loc6_12 [concrete = constants.%HasQualifiers] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc6_9: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
|
||||
// CHECK:STDOUT: %HasQualifiers.ref.loc6_12: type = name_ref HasQualifiers, imports.%HasQualifiers.decl [concrete = constants.%HasQualifiers]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %v: %HasQualifiers = bind_name v, %v.param
|
||||
@@ -242,7 +240,9 @@ fn Ref(p: Cpp.HasQualifiers*) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @HasQualifiers {
|
||||
// CHECK:STDOUT: complete_type_witness = @F.%complete_type
|
||||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%HasQualifiers
|
||||
@@ -378,8 +378,6 @@ fn Ref(p: Cpp.HasQualifiers*) {
|
||||
// CHECK:STDOUT: %v.param: %HasQualifiers = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc6: type = splice_block %HasQualifiers.ref [concrete = constants.%HasQualifiers] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357]
|
||||
// CHECK:STDOUT: %HasQualifiers.ref: type = name_ref HasQualifiers, imports.%HasQualifiers.decl [concrete = constants.%HasQualifiers]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %v: %HasQualifiers = bind_name v, %v.param
|
||||
@@ -387,7 +385,9 @@ fn Ref(p: Cpp.HasQualifiers*) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @HasQualifiers {
|
||||
// CHECK:STDOUT: complete_type_witness = @Value.%complete_type
|
||||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357]
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%HasQualifiers
|
||||
@@ -500,8 +500,6 @@ fn Ref(p: Cpp.HasQualifiers*) {
|
||||
// CHECK:STDOUT: %p.param: %ptr.ec3 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc6: type = splice_block %ptr [concrete = constants.%ptr.ec3] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
|
||||
// CHECK:STDOUT: %HasQualifiers.ref: type = name_ref HasQualifiers, imports.%HasQualifiers.decl [concrete = constants.%HasQualifiers]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %HasQualifiers.ref [concrete = constants.%ptr.ec3]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -510,7 +508,9 @@ fn Ref(p: Cpp.HasQualifiers*) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @HasQualifiers {
|
||||
// CHECK:STDOUT: complete_type_witness = @Ref.%complete_type
|
||||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%HasQualifiers
|
||||
@@ -572,8 +572,6 @@ fn Ref(p: Cpp.HasQualifiers*) {
|
||||
// CHECK:STDOUT: %p.param: %ptr.ec3 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc6: type = splice_block %ptr [concrete = constants.%ptr.ec3] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
|
||||
// CHECK:STDOUT: %HasQualifiers.ref: type = name_ref HasQualifiers, imports.%HasQualifiers.decl [concrete = constants.%HasQualifiers]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %HasQualifiers.ref [concrete = constants.%ptr.ec3]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -582,7 +580,9 @@ fn Ref(p: Cpp.HasQualifiers*) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @HasQualifiers {
|
||||
// CHECK:STDOUT: complete_type_witness = @Ref.%complete_type
|
||||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%HasQualifiers
|
||||
|
||||
+129
-75
@@ -18,23 +18,32 @@
|
||||
|
||||
struct Bar;
|
||||
|
||||
// --- fail_todo_import_declaration.carbon
|
||||
// --- import_declaration.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "declaration.h";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_todo_import_declaration.carbon:[[@LINE+7]]:13: error: semantics TODO: `Unsupported: Record declarations without a definition` [SemanticsTodo]
|
||||
// CHECK:STDERR: fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR: fail_todo_import_declaration.carbon:[[@LINE+4]]:13: note: in `Cpp` name lookup for `Bar` [InCppNameLookup]
|
||||
// CHECK:STDERR: fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn MyF(bar: Cpp.Bar*);
|
||||
//@dump-sem-ir-end
|
||||
|
||||
// --- fail_use_declaration_as_definition.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "declaration.h";
|
||||
|
||||
fn MyF() {
|
||||
// CHECK:STDERR: fail_use_declaration_as_definition.carbon:[[@LINE+6]]:12: error: binding pattern has incomplete type `Bar` in name binding declaration [IncompleteTypeInBindingDecl]
|
||||
// CHECK:STDERR: var bar: Cpp.Bar;
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR: fail_use_declaration_as_definition.carbon:[[@LINE-6]]:1: in import [InImport]
|
||||
// CHECK:STDERR: ./declaration.h:2: note: class was forward declared here [ClassForwardDeclaredHere]
|
||||
// CHECK:STDERR:
|
||||
var bar: Cpp.Bar;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Definition
|
||||
// ============================================================================
|
||||
@@ -112,6 +121,7 @@ library "[[@TEST_NAME]]";
|
||||
import Cpp library "private_static_member_function.h";
|
||||
|
||||
fn MyF() {
|
||||
// TODO: Should fail because `foo` is inaccessible.
|
||||
Cpp.Bar.foo();
|
||||
}
|
||||
|
||||
@@ -122,7 +132,7 @@ fn MyF() {
|
||||
// --- public_static_data_member.h
|
||||
|
||||
struct Bar {
|
||||
static Bar* foo;
|
||||
static Bar* _Nonnull foo;
|
||||
};
|
||||
|
||||
// --- fail_todo_import_public_static_data_member.carbon
|
||||
@@ -155,10 +165,10 @@ fn MyF() {
|
||||
// --- public_data_member.h
|
||||
|
||||
struct Bar {
|
||||
Bar* foo;
|
||||
Bar* _Nonnull foo;
|
||||
};
|
||||
|
||||
// --- fail_todo_import_public_data_member.carbon
|
||||
// --- import_public_data_member.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
@@ -166,17 +176,6 @@ import Cpp library "public_data_member.h";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
fn MyF(bar : Cpp.Bar*) {
|
||||
// CHECK:STDERR: fail_todo_import_public_data_member.carbon:[[@LINE+11]]:27: error: semantics TODO: `Unsupported: Declaration type Field` [SemanticsTodo]
|
||||
// CHECK:STDERR: let foo_bar: Cpp.Bar* = bar->foo;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_import_public_data_member.carbon:[[@LINE+8]]:27: note: in `Cpp` name lookup for `foo` [InCppNameLookup]
|
||||
// CHECK:STDERR: let foo_bar: Cpp.Bar* = bar->foo;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_import_public_data_member.carbon:[[@LINE+4]]:27: error: member name `foo` not found in `Cpp.Bar` [MemberNameNotFoundInInstScope]
|
||||
// CHECK:STDERR: let foo_bar: Cpp.Bar* = bar->foo;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
let foo_bar: Cpp.Bar* = bar->foo;
|
||||
}
|
||||
//@dump-sem-ir-end
|
||||
@@ -225,7 +224,7 @@ library "[[@TEST_NAME]]";
|
||||
import Cpp library "inheritance_pointers.h";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
fn MyF1(bar : Cpp.Bar1*);
|
||||
fn MyF1(bar: Cpp.Bar1*);
|
||||
// TODO: Support C++ inheritance.
|
||||
// CHECK:STDERR: fail_todo_import_inheritance_pointers.carbon:[[@LINE+10]]:33: error: cannot implicitly convert expression of type `Cpp.Bar2*` to `Cpp.Bar1*` [ConversionFailure]
|
||||
// CHECK:STDERR: fn MyF2(bar : Cpp.Bar2*) { MyF1(bar); }
|
||||
@@ -234,8 +233,8 @@ fn MyF1(bar : Cpp.Bar1*);
|
||||
// CHECK:STDERR: fn MyF2(bar : Cpp.Bar2*) { MyF1(bar); }
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR: fail_todo_import_inheritance_pointers.carbon:[[@LINE-8]]:9: note: initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: fn MyF1(bar : Cpp.Bar1*);
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fn MyF1(bar: Cpp.Bar1*);
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn MyF2(bar : Cpp.Bar2*) { MyF1(bar); }
|
||||
//@dump-sem-ir-end
|
||||
@@ -247,24 +246,36 @@ fn MyF2(bar : Cpp.Bar2*) { MyF1(bar); }
|
||||
// --- dynamic.h
|
||||
|
||||
struct Bar {
|
||||
virtual ~Bar();
|
||||
virtual void f();
|
||||
};
|
||||
|
||||
// --- fail_todo_import_dynamic.carbon
|
||||
// --- import_dynamic.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "dynamic.h";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_todo_import_dynamic.carbon:[[@LINE+7]]:14: error: semantics TODO: `Unsupported: Dynamic Class` [SemanticsTodo]
|
||||
// CHECK:STDERR: fn MyF(bar : Cpp.Bar*);
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR: fail_todo_import_dynamic.carbon:[[@LINE+4]]:14: note: in `Cpp` name lookup for `Bar` [InCppNameLookup]
|
||||
// CHECK:STDERR: fn MyF(bar : Cpp.Bar*);
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn MyF(bar : Cpp.Bar*);
|
||||
fn MyF(bar: Cpp.Bar*);
|
||||
//@dump-sem-ir-end
|
||||
|
||||
// --- fail_todo_call_dynamic.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "dynamic.h";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
fn MyF(bar: Cpp.Bar*) {
|
||||
// CHECK:STDERR: fail_todo_call_dynamic.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: Virtual function` [SemanticsTodo]
|
||||
// CHECK:STDERR: bar->f();
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
// CHECK:STDERR: fail_todo_call_dynamic.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `f` [InCppNameLookup]
|
||||
// CHECK:STDERR: bar->f();
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
// CHECK:STDERR:
|
||||
bar->f();
|
||||
}
|
||||
//@dump-sem-ir-end
|
||||
|
||||
// ============================================================================
|
||||
@@ -313,6 +324,7 @@ class Derived {
|
||||
}
|
||||
|
||||
fn MyF() {
|
||||
// TODO: Should fail because `foo` is inaccessible.
|
||||
Derived.foo();
|
||||
}
|
||||
|
||||
@@ -346,36 +358,40 @@ import Cpp library "template.h";
|
||||
fn MyF(bar: Cpp.Bar*);
|
||||
//@dump-sem-ir-end
|
||||
|
||||
// CHECK:STDOUT: --- fail_todo_import_declaration.carbon
|
||||
// CHECK:STDOUT: --- import_declaration.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Bar: type = class_type @Bar [concrete]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar [concrete]
|
||||
// CHECK:STDOUT: %pattern_type: type = pattern_type %ptr [concrete]
|
||||
// CHECK:STDOUT: %MyF.type: type = fn_type @MyF [concrete]
|
||||
// CHECK:STDOUT: %MyF: %MyF.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
|
||||
// CHECK:STDOUT: .Bar = <error>
|
||||
// CHECK:STDOUT: .Bar = %Bar.decl
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Bar.decl: type = class_decl @Bar [concrete = constants.%Bar] {} {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: %MyF.decl: %MyF.type = fn_decl @MyF [concrete = constants.%MyF] {
|
||||
// CHECK:STDOUT: %bar.patt: <error> = binding_pattern bar [concrete]
|
||||
// CHECK:STDOUT: %bar.param_patt: <error> = value_param_pattern %bar.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %bar.patt: %pattern_type = binding_pattern bar [concrete]
|
||||
// CHECK:STDOUT: %bar.param_patt: %pattern_type = value_param_pattern %bar.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %bar.param: <error> = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc14: type = splice_block %ptr [concrete = <error>] {
|
||||
// CHECK:STDOUT: %bar.param: %ptr = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Bar.ref: <error> = name_ref Bar, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %bar: <error> = bind_name bar, %bar.param
|
||||
// CHECK:STDOUT: %bar: %ptr = bind_name bar, %bar.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @MyF(%bar.param: <error>);
|
||||
// CHECK:STDOUT: fn @MyF(%bar.param: %ptr);
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- import_definition.carbon
|
||||
// CHECK:STDOUT:
|
||||
@@ -403,7 +419,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %bar.param: %ptr = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -439,7 +454,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %bar.param: %ptr = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -470,7 +484,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: fn @MyF() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %foo.ref: %Bar.foo.type = name_ref foo, imports.%Bar.foo.decl [concrete = constants.%Bar.foo]
|
||||
// CHECK:STDOUT: %Bar.foo.call: init %empty_tuple.type = call %foo.ref()
|
||||
@@ -503,7 +516,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc19: type = splice_block %ptr [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc19_12: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref.loc19_15: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref.loc19_15 [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -511,11 +523,12 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_todo_import_public_data_member.carbon
|
||||
// CHECK:STDOUT: --- import_public_data_member.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Bar: type = class_type @Bar [concrete]
|
||||
// CHECK:STDOUT: %ptr.f68: type = ptr_type %Bar [concrete]
|
||||
// CHECK:STDOUT: %Bar.elem: type = unbound_element_type %Bar, %ptr.f68 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type: type = pattern_type %ptr.f68 [concrete]
|
||||
// CHECK:STDOUT: %MyF.type: type = fn_type @MyF [concrete]
|
||||
// CHECK:STDOUT: %MyF: %MyF.type = struct_value () [concrete]
|
||||
@@ -537,7 +550,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %bar.param: %ptr.f68 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr.loc7 [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc7: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref.loc7: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr.loc7: type = ptr_type %Bar.ref.loc7 [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -551,14 +563,16 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %foo_bar.patt: %pattern_type = binding_pattern foo_bar [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %bar.ref: %ptr.f68 = name_ref bar, %bar
|
||||
// CHECK:STDOUT: %.loc19_30: ref %Bar = deref %bar.ref
|
||||
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc19_23: type = splice_block %ptr.loc19 [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc19: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Bar.ref.loc19: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr.loc19: type = ptr_type %Bar.ref.loc19 [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: %.loc8_30.1: ref %Bar = deref %bar.ref
|
||||
// CHECK:STDOUT: %foo.ref: %Bar.elem = name_ref foo, @Bar.%.1 [concrete = @Bar.%.1]
|
||||
// CHECK:STDOUT: %.loc8_30.2: ref %ptr.f68 = class_element_access %.loc8_30.1, element0
|
||||
// CHECK:STDOUT: %.loc8_23: type = splice_block %ptr.loc8 [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Bar.ref.loc8: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr.loc8: type = ptr_type %Bar.ref.loc8 [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %foo_bar: %ptr.f68 = bind_name foo_bar, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc8_30.3: %ptr.f68 = bind_value %.loc8_30.2
|
||||
// CHECK:STDOUT: %foo_bar: %ptr.f68 = bind_name foo_bar, %.loc8_30.3
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -589,12 +603,10 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: fn @MyF() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar1.ref: type = name_ref Bar1, imports.%Bar1.decl [concrete = constants.%Bar1]
|
||||
// CHECK:STDOUT: %foo1.ref.loc8: %Bar1.foo1.type = name_ref foo1, imports.%Bar1.foo1.decl [concrete = constants.%Bar1.foo1]
|
||||
// CHECK:STDOUT: %Bar1.foo1.call.loc8: init %empty_tuple.type = call %foo1.ref.loc8()
|
||||
// CHECK:STDOUT: %Cpp.ref.loc9: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar2.ref.loc9: type = name_ref Bar2, imports.%Bar2.decl [concrete = constants.%Bar2]
|
||||
// CHECK:STDOUT: %foo1.ref.loc9: %Bar1.foo1.type = name_ref foo1, imports.%Bar1.foo1.decl [concrete = constants.%Bar1.foo1]
|
||||
// CHECK:STDOUT: %Bar1.foo1.call.loc9: init %empty_tuple.type = call %foo1.ref.loc9()
|
||||
@@ -639,7 +651,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %bar.param: %ptr.f68 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar1.ref: type = name_ref Bar1, imports.%Bar1.decl [concrete = constants.%Bar1]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar1.ref [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -652,7 +663,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %bar.param: %ptr.eca = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc19_23: type = splice_block %ptr [concrete = constants.%ptr.eca] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar2.ref: type = name_ref Bar2, imports.%Bar2.decl [concrete = constants.%Bar2]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar2.ref [concrete = constants.%ptr.eca]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -671,36 +681,81 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_todo_import_dynamic.carbon
|
||||
// CHECK:STDOUT: --- import_dynamic.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Bar: type = class_type @Bar [concrete]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar [concrete]
|
||||
// CHECK:STDOUT: %pattern_type: type = pattern_type %ptr [concrete]
|
||||
// CHECK:STDOUT: %MyF.type: type = fn_type @MyF [concrete]
|
||||
// CHECK:STDOUT: %MyF: %MyF.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
|
||||
// CHECK:STDOUT: .Bar = <error>
|
||||
// CHECK:STDOUT: .Bar = %Bar.decl
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Bar.decl: type = class_decl @Bar [concrete = constants.%Bar] {} {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: %MyF.decl: %MyF.type = fn_decl @MyF [concrete = constants.%MyF] {
|
||||
// CHECK:STDOUT: %bar.patt: <error> = binding_pattern bar [concrete]
|
||||
// CHECK:STDOUT: %bar.param_patt: <error> = value_param_pattern %bar.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %bar.patt: %pattern_type = binding_pattern bar [concrete]
|
||||
// CHECK:STDOUT: %bar.param_patt: %pattern_type = value_param_pattern %bar.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %bar.param: <error> = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc14: type = splice_block %ptr [concrete = <error>] {
|
||||
// CHECK:STDOUT: %bar.param: %ptr = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Bar.ref: <error> = name_ref Bar, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %bar: <error> = bind_name bar, %bar.param
|
||||
// CHECK:STDOUT: %bar: %ptr = bind_name bar, %bar.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @MyF(%bar.param: <error>);
|
||||
// CHECK:STDOUT: fn @MyF(%bar.param: %ptr);
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_todo_call_dynamic.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Bar: type = class_type @Bar [concrete]
|
||||
// CHECK:STDOUT: %ptr.f68: type = ptr_type %Bar [concrete]
|
||||
// CHECK:STDOUT: %pattern_type: type = pattern_type %ptr.f68 [concrete]
|
||||
// CHECK:STDOUT: %MyF.type: type = fn_type @MyF [concrete]
|
||||
// CHECK:STDOUT: %MyF: %MyF.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
|
||||
// CHECK:STDOUT: .Bar = %Bar.decl
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Bar.decl: type = class_decl @Bar [concrete = constants.%Bar] {} {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: %MyF.decl: %MyF.type = fn_decl @MyF [concrete = constants.%MyF] {
|
||||
// CHECK:STDOUT: %bar.patt: %pattern_type = binding_pattern bar [concrete]
|
||||
// CHECK:STDOUT: %bar.param_patt: %pattern_type = value_param_pattern %bar.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %bar.param: %ptr.f68 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %bar: %ptr.f68 = bind_name bar, %bar.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @MyF(%bar.param: %ptr.f68) {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %bar.ref: %ptr.f68 = name_ref bar, %bar
|
||||
// CHECK:STDOUT: %.loc15: ref %Bar = deref %bar.ref
|
||||
// CHECK:STDOUT: %f.ref: <error> = name_ref f, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- import_to_inherit_public.carbon
|
||||
// CHECK:STDOUT:
|
||||
@@ -733,12 +788,11 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @Derived {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %.loc8: %Derived.elem = base_decl %Bar.ref, element0 [concrete]
|
||||
// CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %Bar} [concrete = constants.%struct_type.base.36d]
|
||||
// CHECK:STDOUT: %complete_type.loc9: <witness> = complete_type_witness %struct_type.base [concrete = constants.%complete_type.fff]
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type.loc9
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [concrete = constants.%complete_type.fff]
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%Derived
|
||||
|
||||
+49
-47
@@ -2,7 +2,7 @@
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
|
||||
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
|
||||
//
|
||||
// AUTOUPDATE
|
||||
// TIP: To test this file alone, run:
|
||||
@@ -18,23 +18,32 @@
|
||||
|
||||
union Bar;
|
||||
|
||||
// --- fail_todo_import_declaration.carbon
|
||||
// --- import_declaration.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "declaration.h";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_todo_import_declaration.carbon:[[@LINE+7]]:13: error: semantics TODO: `Unsupported: Record declarations without a definition` [SemanticsTodo]
|
||||
// CHECK:STDERR: fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR: fail_todo_import_declaration.carbon:[[@LINE+4]]:13: note: in `Cpp` name lookup for `Bar` [InCppNameLookup]
|
||||
// CHECK:STDERR: fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn MyF(bar: Cpp.Bar*);
|
||||
//@dump-sem-ir-end
|
||||
|
||||
// --- fail_use_declaration_as_definition.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "declaration.h";
|
||||
|
||||
fn MyF() {
|
||||
// CHECK:STDERR: fail_use_declaration_as_definition.carbon:[[@LINE+6]]:12: error: binding pattern has incomplete type `Bar` in name binding declaration [IncompleteTypeInBindingDecl]
|
||||
// CHECK:STDERR: var bar: Cpp.Bar;
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR: fail_use_declaration_as_definition.carbon:[[@LINE-6]]:1: in import [InImport]
|
||||
// CHECK:STDERR: ./declaration.h:2: note: class was forward declared here [ClassForwardDeclaredHere]
|
||||
// CHECK:STDERR:
|
||||
var bar: Cpp.Bar;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Definition
|
||||
// ============================================================================
|
||||
@@ -113,6 +122,7 @@ library "[[@TEST_NAME]]";
|
||||
import Cpp library "private_static_member_function.h";
|
||||
|
||||
fn MyF() {
|
||||
// TODO: Should fail because `foo` is inaccessible.
|
||||
Cpp.Bar.foo();
|
||||
}
|
||||
|
||||
@@ -124,7 +134,7 @@ fn MyF() {
|
||||
|
||||
union Bar {
|
||||
public:
|
||||
static Bar* foo;
|
||||
static Bar* _Nonnull foo;
|
||||
};
|
||||
|
||||
// --- fail_todo_import_public_static_data_member.carbon
|
||||
@@ -158,28 +168,17 @@ fn MyF() {
|
||||
|
||||
union Bar {
|
||||
public:
|
||||
Bar* foo;
|
||||
Bar* _Nonnull foo;
|
||||
};
|
||||
|
||||
// --- fail_todo_import_public_data_member.carbon
|
||||
// --- import_public_data_member.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "public_static_data_member.h";
|
||||
import Cpp library "public_data_member.h";
|
||||
|
||||
//@dump-sem-ir-begin
|
||||
fn MyF(bar : Cpp.Bar*) {
|
||||
// CHECK:STDERR: fail_todo_import_public_data_member.carbon:[[@LINE+11]]:27: error: semantics TODO: `Unsupported: Declaration type Var` [SemanticsTodo]
|
||||
// CHECK:STDERR: let foo_bar: Cpp.Bar* = bar->foo;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_import_public_data_member.carbon:[[@LINE+8]]:27: note: in `Cpp` name lookup for `foo` [InCppNameLookup]
|
||||
// CHECK:STDERR: let foo_bar: Cpp.Bar* = bar->foo;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_import_public_data_member.carbon:[[@LINE+4]]:27: error: member name `foo` not found in `Cpp.Bar` [MemberNameNotFoundInInstScope]
|
||||
// CHECK:STDERR: let foo_bar: Cpp.Bar* = bar->foo;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
let foo_bar: Cpp.Bar* = bar->foo;
|
||||
}
|
||||
//@dump-sem-ir-end
|
||||
@@ -202,6 +201,7 @@ library "[[@TEST_NAME]]";
|
||||
import Cpp library "to_inherit_public.h";
|
||||
|
||||
class Derived {
|
||||
// TODO: Presumably we should disallow deriving from a union.
|
||||
extend base: Cpp.Bar;
|
||||
}
|
||||
|
||||
@@ -239,36 +239,40 @@ import Cpp library "template.h";
|
||||
fn MyF(bar: Cpp.Bar*);
|
||||
//@dump-sem-ir-end
|
||||
|
||||
// CHECK:STDOUT: --- fail_todo_import_declaration.carbon
|
||||
// CHECK:STDOUT: --- import_declaration.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Bar: type = class_type @Bar [concrete]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar [concrete]
|
||||
// CHECK:STDOUT: %pattern_type: type = pattern_type %ptr [concrete]
|
||||
// CHECK:STDOUT: %MyF.type: type = fn_type @MyF [concrete]
|
||||
// CHECK:STDOUT: %MyF: %MyF.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
|
||||
// CHECK:STDOUT: .Bar = <error>
|
||||
// CHECK:STDOUT: .Bar = %Bar.decl
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Bar.decl: type = class_decl @Bar [concrete = constants.%Bar] {} {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: %MyF.decl: %MyF.type = fn_decl @MyF [concrete = constants.%MyF] {
|
||||
// CHECK:STDOUT: %bar.patt: <error> = binding_pattern bar [concrete]
|
||||
// CHECK:STDOUT: %bar.param_patt: <error> = value_param_pattern %bar.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: %bar.patt: %pattern_type = binding_pattern bar [concrete]
|
||||
// CHECK:STDOUT: %bar.param_patt: %pattern_type = value_param_pattern %bar.patt, call_param0 [concrete]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %bar.param: <error> = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc14: type = splice_block %ptr [concrete = <error>] {
|
||||
// CHECK:STDOUT: %bar.param: %ptr = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Bar.ref: <error> = name_ref Bar, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %bar: <error> = bind_name bar, %bar.param
|
||||
// CHECK:STDOUT: %bar: %ptr = bind_name bar, %bar.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @MyF(%bar.param: <error>);
|
||||
// CHECK:STDOUT: fn @MyF(%bar.param: %ptr);
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- import_definition.carbon
|
||||
// CHECK:STDOUT:
|
||||
@@ -296,7 +300,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %bar.param: %ptr = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -332,7 +335,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %bar.param: %ptr = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr] {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -363,7 +365,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: fn @MyF() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %foo.ref: %Bar.foo.type = name_ref foo, imports.%Bar.foo.decl [concrete = constants.%Bar.foo]
|
||||
// CHECK:STDOUT: %Bar.foo.call: init %empty_tuple.type = call %foo.ref()
|
||||
@@ -396,7 +397,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc19: type = splice_block %ptr [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc19_12: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref.loc19_15: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref.loc19_15 [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -404,11 +404,12 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_todo_import_public_data_member.carbon
|
||||
// CHECK:STDOUT: --- import_public_data_member.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Bar: type = class_type @Bar [concrete]
|
||||
// CHECK:STDOUT: %ptr.f68: type = ptr_type %Bar [concrete]
|
||||
// CHECK:STDOUT: %Bar.elem: type = unbound_element_type %Bar, %ptr.f68 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type: type = pattern_type %ptr.f68 [concrete]
|
||||
// CHECK:STDOUT: %MyF.type: type = fn_type @MyF [concrete]
|
||||
// CHECK:STDOUT: %MyF: %MyF.type = struct_value () [concrete]
|
||||
@@ -430,7 +431,6 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %bar.param: %ptr.f68 = value_param call_param0
|
||||
// CHECK:STDOUT: %.loc7: type = splice_block %ptr.loc7 [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc7: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: %Bar.ref.loc7: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr.loc7: type = ptr_type %Bar.ref.loc7 [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -444,14 +444,16 @@ fn MyF(bar: Cpp.Bar*);
|
||||
// CHECK:STDOUT: %foo_bar.patt: %pattern_type = binding_pattern foo_bar [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %bar.ref: %ptr.f68 = name_ref bar, %bar
|
||||
// CHECK:STDOUT: %.loc19_30: ref %Bar = deref %bar.ref
|
||||
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc19_23: type = splice_block %ptr.loc19 [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc19: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Bar.ref.loc19: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr.loc19: type = ptr_type %Bar.ref.loc19 [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: %.loc8_30.1: ref %Bar = deref %bar.ref
|
||||
// CHECK:STDOUT: %foo.ref: %Bar.elem = name_ref foo, @Bar.%.1 [concrete = @Bar.%.1]
|
||||
// CHECK:STDOUT: %.loc8_30.2: ref %ptr.f68 = class_element_access %.loc8_30.1, element0
|
||||
// CHECK:STDOUT: %.loc8_23: type = splice_block %ptr.loc8 [concrete = constants.%ptr.f68] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Bar.ref.loc8: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
|
||||
// CHECK:STDOUT: %ptr.loc8: type = ptr_type %Bar.ref.loc8 [concrete = constants.%ptr.f68]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %foo_bar: %ptr.f68 = bind_name foo_bar, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc8_30.3: %ptr.f68 = bind_value %.loc8_30.2
|
||||
// CHECK:STDOUT: %foo_bar: %ptr.f68 = bind_name foo_bar, %.loc8_30.3
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
Reference in New Issue
Block a user