From a5ddc3e3cddc77f03588563a3ee50d59dc7ff2c2 Mon Sep 17 00:00:00 2001 From: Boaz Brickner Date: Thu, 10 Jul 2025 10:00:37 +0200 Subject: [PATCH] Support importing C++ `_Nonnull` pointers as function parameters or return values (#5773) We avoid using canonical type before knowing it's not a pointer because we need the nullability attribute. No support for pointers to pointers, yet. C++ Interop Demo: ```c++ // hello_world.h auto hello_world_param(int* _Nonnull i) -> void; auto hello_world_return() -> int* _Nonnull; ``` ```c++ // hello_world.cpp #include "hello_world.h" #include auto hello_world_param(int* _Nonnull i) -> void { printf("hello_world: %d\n", *i); } static int x = 5; auto hello_world_return() -> int* _Nonnull { return &x; } ``` ```carbon // main.carbon library "Main"; import Core library "io"; import Cpp library "hello_world.h"; fn Run() -> i32 { var i: i32 = 10; Cpp.hello_world_param(&i); let p: i32* = Cpp.hello_world_return(); Core.Print(*p); return 0; } ``` ```shell $ clang -c hello_world.cpp $ ./bazel-bin/toolchain/install/prefix_root/bin/carbon compile main.carbon $ ./bazel-bin/toolchain/install/prefix_root/bin/carbon link hello_world.o main.o --output=demo $ ./demo hello_world: 10 5 ``` Part of #5772. --- toolchain/check/import_cpp.cpp | 61 +- .../interop/cpp/function/class.carbon | 83 ++- .../interop/cpp/function/param_int16.carbon | 56 +- .../interop/cpp/function/param_int32.carbon | 55 +- .../interop/cpp/function/pointer.carbon | 659 ++++++++++++++++++ .../interop/cpp/function/struct.carbon | 83 ++- .../interop/cpp/function/union.carbon | 47 +- 7 files changed, 899 insertions(+), 145 deletions(-) create mode 100644 toolchain/check/testdata/interop/cpp/function/pointer.carbon diff --git a/toolchain/check/import_cpp.cpp b/toolchain/check/import_cpp.cpp index 562d2ca02469..2d567ec6bd75 100644 --- a/toolchain/check/import_cpp.cpp +++ b/toolchain/check/import_cpp.cpp @@ -700,10 +700,13 @@ static auto MapRecordType(Context& context, SemIR::LocId loc_id, .type_id = SemIR::ErrorInst::TypeId}; } -// Maps a C++ type to a Carbon type. +// Maps a C++ non-pointer type to a Carbon type. // TODO: Support more types. -static auto MapType(Context& context, SemIR::LocId loc_id, clang::QualType type) - -> TypeExpr { +static auto MapNonPointerType(Context& context, SemIR::LocId loc_id, + clang::QualType type) -> TypeExpr { + type = type.getCanonicalType(); + CARBON_CHECK(!type->isPointerType()); + if (const auto* builtin_type = dyn_cast(type)) { return MapBuiltinType(context, *builtin_type); } @@ -716,6 +719,54 @@ static auto MapType(Context& context, SemIR::LocId loc_id, clang::QualType type) .type_id = SemIR::ErrorInst::TypeId}; } +// Maps a C++ pointer type to a Carbon pointer type. +static auto MapPointerType(Context& context, SemIR::LocId loc_id, + clang::QualType type) -> TypeExpr { + CARBON_CHECK(type->isPointerType()); + + if (auto nullability = type->getNullability(); + !nullability.has_value() || + *nullability != clang::NullabilityKind::NonNull) { + context.TODO(loc_id, llvm::formatv("Unsupported: nullable pointer: {0}", + type.getAsString())); + return {.inst_id = SemIR::ErrorInst::TypeInstId, + .type_id = SemIR::ErrorInst::TypeId}; + } + + clang::QualType pointee_type = type->getPointeeType(); + + if (pointee_type->isAnyPointerType()) { + context.TODO(loc_id, + llvm::formatv("Unsupported: pointer to pointer type: {0}", + pointee_type.getAsString())); + return {.inst_id = SemIR::ErrorInst::TypeInstId, + .type_id = SemIR::ErrorInst::TypeId}; + } + + TypeExpr pointee_type_expr = MapNonPointerType(context, loc_id, pointee_type); + if (pointee_type_expr.inst_id == SemIR::ErrorInst::InstId || + pointee_type_expr.type_id == SemIR::ErrorInst::TypeId) { + return {.inst_id = SemIR::ErrorInst::TypeInstId, + .type_id = SemIR::ErrorInst::TypeId}; + } + + SemIR::TypeId pointer_type_id = + GetPointerType(context, pointee_type_expr.inst_id); + return {.inst_id = context.types().GetInstId(pointer_type_id), + .type_id = pointer_type_id}; +} + +// Maps a C++ type to a Carbon type. `type` should not be canonicalized because +// we check for pointer nullability and nullability will be lost by +// canonicalization. +static auto MapType(Context& context, SemIR::LocId loc_id, clang::QualType type) + -> TypeExpr { + if (type->isPointerType()) { + return MapPointerType(context, loc_id, type); + } + return MapNonPointerType(context, loc_id, type); +} + // Returns a block id for the explicit parameters of the given function // declaration. If the function declaration has no parameters, it returns // `SemIR::InstBlockId::Empty`. In the case of an unsupported parameter type, it @@ -731,7 +782,7 @@ static auto MakeParamPatternsBlockId(Context& context, SemIR::LocId loc_id, llvm::SmallVector params; params.reserve(clang_decl.parameters().size()); for (const clang::ParmVarDecl* param : clang_decl.parameters()) { - clang::QualType param_type = param->getType().getCanonicalType(); + clang::QualType param_type = param->getType(); // Mark the start of a region of insts, needed for the type expression // created later with the call of `EndSubpatternAsExpr()`. @@ -784,7 +835,7 @@ static auto MakeParamPatternsBlockId(Context& context, SemIR::LocId loc_id, static auto GetReturnType(Context& context, SemIR::LocId loc_id, const clang::FunctionDecl* clang_decl) -> SemIR::InstId { - clang::QualType ret_type = clang_decl->getReturnType().getCanonicalType(); + clang::QualType ret_type = clang_decl->getReturnType(); if (ret_type->isVoidType()) { return SemIR::InstId::None; } diff --git a/toolchain/check/testdata/interop/cpp/function/class.carbon b/toolchain/check/testdata/interop/cpp/function/class.carbon index b06f0be3db76..bb219c128b91 100644 --- a/toolchain/check/testdata/interop/cpp/function/class.carbon +++ b/toolchain/check/testdata/interop/cpp/function/class.carbon @@ -34,7 +34,7 @@ fn F() { // CHECK:STDERR: Cpp.foo({}); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: - // CHECK:STDERR: fail_todo_import_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: class C` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: C` [SemanticsTodo] // CHECK:STDERR: Cpp.foo({}); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_value_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -63,7 +63,7 @@ fn F() { // CHECK:STDERR: ^ // CHECK:STDERR: let c: Cpp.C; - // CHECK:STDERR: fail_todo_import_decl_value_param_type_previously_imported.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: class C` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_value_param_type_previously_imported.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: C` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(c); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_value_param_type_previously_imported.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -98,7 +98,7 @@ fn F() { // CHECK:STDERR: Cpp.foo1({}); // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: - // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: class C` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: C` [SemanticsTodo] // CHECK:STDERR: Cpp.foo1({}); // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo1` [InCppNameLookup] @@ -106,7 +106,7 @@ fn F() { // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: Cpp.foo1({}); - // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: class C` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: C` [SemanticsTodo] // CHECK:STDERR: Cpp.foo2({}); // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo2` [InCppNameLookup] @@ -283,7 +283,7 @@ fn F() { class C; -auto foo(C*) -> void; +auto foo(C* _Nonnull) -> void; // --- fail_todo_import_decl_pointer_param_type.carbon @@ -300,7 +300,7 @@ import Cpp library "decl_pointer_param_type.h"; // CHECK:STDERR: fn F(c: Cpp.C*) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_decl_pointer_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: class C *` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_pointer_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: C * _Nonnull` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(c); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_pointer_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -319,9 +319,9 @@ fn F(c: Cpp.C*) { class C {}; -auto foo(C*) -> void; +auto foo(C* _Nonnull) -> void; -// --- fail_todo_import_definition_pointer_param_type.carbon +// --- import_definition_pointer_param_type.carbon library "[[@TEST_NAME]]"; @@ -329,13 +329,6 @@ import Cpp library "definition_pointer_param_type.h"; fn F(c: Cpp.C*) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_definition_pointer_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: class C *` [SemanticsTodo] - // CHECK:STDERR: Cpp.foo(c); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: fail_todo_import_definition_pointer_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] - // CHECK:STDERR: Cpp.foo(c); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: Cpp.foo(c); //@dump-sem-ir-end } @@ -364,7 +357,7 @@ fn F() { // CHECK:STDERR: Cpp.foo(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: - // CHECK:STDERR: fail_todo_import_decl_value_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: class C` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_value_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: C` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_value_return_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -404,7 +397,7 @@ fn F() { class C; -auto foo() -> C*; +auto foo() -> C* _Nonnull; // --- fail_todo_import_decl_pointer_return_type.carbon @@ -414,7 +407,14 @@ import Cpp library "decl_pointer_return_type.h"; fn F() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: class C *` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+14]]:3: error: semantics TODO: `Unsupported: Record declarations without a definition` [SemanticsTodo] + // CHECK:STDERR: Cpp.foo(); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+11]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] + // CHECK:STDERR: Cpp.foo(); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: + // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: C * _Nonnull` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -433,9 +433,9 @@ fn F() { class C {}; -auto foo() -> C*; +auto foo() -> C* _Nonnull; -// --- fail_todo_import_definition_pointer_return_type.carbon +// --- import_definition_pointer_return_type.carbon library "[[@TEST_NAME]]"; @@ -443,13 +443,6 @@ import Cpp library "definition_pointer_return_type.h"; fn F() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_definition_pointer_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: class C *` [SemanticsTodo] - // CHECK:STDERR: Cpp.foo(); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: fail_todo_import_definition_pointer_return_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] - // CHECK:STDERR: Cpp.foo(); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: Cpp.foo(); //@dump-sem-ir-end } @@ -904,27 +897,36 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_import_definition_pointer_param_type.carbon +// CHECK:STDOUT: --- import_definition_pointer_param_type.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %C: type = class_type @C [concrete] // CHECK:STDOUT: %ptr: type = ptr_type %C [concrete] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete] +// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { // CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: .foo = +// CHECK:STDOUT: .foo = %foo.decl // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} +// CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] { +// CHECK:STDOUT: +// CHECK:STDOUT: } { +// CHECK:STDOUT: +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%c.param: %ptr) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Cpp.ref.loc15: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %foo.ref: = name_ref foo, [concrete = ] +// CHECK:STDOUT: %Cpp.ref.loc8: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] // CHECK:STDOUT: %c.ref: %ptr = name_ref c, %c +// CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%c.ref) // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: @@ -989,6 +991,7 @@ fn F() { // CHECK:STDOUT: imports { // CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { // CHECK:STDOUT: .foo = +// CHECK:STDOUT: .C = // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -1000,22 +1003,34 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_import_definition_pointer_return_type.carbon +// CHECK:STDOUT: --- import_definition_pointer_return_type.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [concrete] +// CHECK:STDOUT: %ptr: type = ptr_type %C [concrete] +// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete] +// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { -// CHECK:STDOUT: .foo = +// CHECK:STDOUT: .foo = %foo.decl +// CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} +// CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] { +// CHECK:STDOUT: +// CHECK:STDOUT: } { +// CHECK:STDOUT: +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Cpp.ref: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %foo.ref: = name_ref foo, [concrete = ] +// CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] +// CHECK:STDOUT: %foo.call: init %ptr = call %foo.ref() // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interop/cpp/function/param_int16.carbon b/toolchain/check/testdata/interop/cpp/function/param_int16.carbon index ff9097fc02f1..89faf69d88eb 100644 --- a/toolchain/check/testdata/interop/cpp/function/param_int16.carbon +++ b/toolchain/check/testdata/interop/cpp/function/param_int16.carbon @@ -269,9 +269,9 @@ fn F() { // --- short_pointer.h -auto foo(short* a) -> void; +auto foo(short* _Nonnull a) -> void; -// --- fail_todo_import_short_pointer.carbon +// --- import_short_pointer.carbon library "[[@TEST_NAME]]"; @@ -280,13 +280,6 @@ import Cpp library "short_pointer.h"; fn F() { var a: i16 = 1; //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_short_pointer.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: short *` [SemanticsTodo] - // CHECK:STDERR: Cpp.foo(&a); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: fail_todo_import_short_pointer.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] - // CHECK:STDERR: Cpp.foo(&a); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: Cpp.foo(&a); //@dump-sem-ir-end } @@ -297,9 +290,9 @@ fn F() { // --- const_short_pointer.h -auto foo(const short* a) -> void; +auto foo(const short* _Nonnull a) -> void; -// --- fail_todo_import_const_short_pointer.carbon +// --- import_const_short_pointer.carbon library "[[@TEST_NAME]]"; @@ -308,13 +301,6 @@ import Cpp library "const_short_pointer.h"; fn F() { var a: i16 = 1; //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_const_short_pointer.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: const short *` [SemanticsTodo] - // CHECK:STDERR: Cpp.foo(&a); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: fail_todo_import_const_short_pointer.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] - // CHECK:STDERR: Cpp.foo(&a); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: Cpp.foo(&a); //@dump-sem-ir-end } @@ -834,53 +820,71 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_import_short_pointer.carbon +// CHECK:STDOUT: --- import_short_pointer.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete] // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete] // CHECK:STDOUT: %ptr.251: type = ptr_type %i16 [concrete] +// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete] +// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { -// CHECK:STDOUT: .foo = +// CHECK:STDOUT: .foo = %foo.decl // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } +// CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] { +// CHECK:STDOUT: +// CHECK:STDOUT: } { +// CHECK:STDOUT: +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: // CHECK:STDOUT: %Cpp.ref: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %foo.ref: = name_ref foo, [concrete = ] +// CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] // CHECK:STDOUT: %a.ref: ref %i16 = name_ref a, %a -// CHECK:STDOUT: %addr.loc16: %ptr.251 = addr_of %a.ref +// CHECK:STDOUT: %addr.loc9: %ptr.251 = addr_of %a.ref +// CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%addr.loc9) // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_import_const_short_pointer.carbon +// CHECK:STDOUT: --- import_const_short_pointer.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete] // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete] // CHECK:STDOUT: %ptr.251: type = ptr_type %i16 [concrete] +// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete] +// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { -// CHECK:STDOUT: .foo = +// CHECK:STDOUT: .foo = %foo.decl // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } +// CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] { +// CHECK:STDOUT: +// CHECK:STDOUT: } { +// CHECK:STDOUT: +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: // CHECK:STDOUT: %Cpp.ref: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %foo.ref: = name_ref foo, [concrete = ] +// CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] // CHECK:STDOUT: %a.ref: ref %i16 = name_ref a, %a -// CHECK:STDOUT: %addr.loc16: %ptr.251 = addr_of %a.ref +// CHECK:STDOUT: %addr.loc9: %ptr.251 = addr_of %a.ref +// CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%addr.loc9) // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interop/cpp/function/param_int32.carbon b/toolchain/check/testdata/interop/cpp/function/param_int32.carbon index 4dc4af390e28..17cb4bc4f7ae 100644 --- a/toolchain/check/testdata/interop/cpp/function/param_int32.carbon +++ b/toolchain/check/testdata/interop/cpp/function/param_int32.carbon @@ -329,9 +329,9 @@ fn F() { // --- int_pointer.h -auto foo(int* a) -> void; +auto foo(int* _Nonnull a) -> void; -// --- fail_todo_import_int_pointer.carbon +// --- import_int_pointer.carbon library "[[@TEST_NAME]]"; @@ -340,13 +340,6 @@ import Cpp library "int_pointer.h"; fn F() { var a: i32 = 1; //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_int_pointer.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: int *` [SemanticsTodo] - // CHECK:STDERR: Cpp.foo(&a); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: fail_todo_import_int_pointer.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] - // CHECK:STDERR: Cpp.foo(&a); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: Cpp.foo(&a); //@dump-sem-ir-end } @@ -357,9 +350,9 @@ fn F() { // --- const_int_pointer.h -auto foo(const int* a) -> int; +auto foo(const int* _Nonnull a) -> int; -// --- fail_todo_import_const_int_pointer.carbon +// --- import_const_int_pointer.carbon library "[[@TEST_NAME]]"; @@ -368,13 +361,6 @@ import Cpp library "const_int_pointer.h"; fn F() { var a : i32 = 1; //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_const_int_pointer.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: const int *` [SemanticsTodo] - // CHECK:STDERR: Cpp.foo(&a); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: fail_todo_import_const_int_pointer.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] - // CHECK:STDERR: Cpp.foo(&a); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: Cpp.foo(&a); //@dump-sem-ir-end } @@ -1077,53 +1063,70 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_import_int_pointer.carbon +// CHECK:STDOUT: --- import_int_pointer.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] // CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [concrete] +// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete] +// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { -// CHECK:STDOUT: .foo = +// CHECK:STDOUT: .foo = %foo.decl // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } +// CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] { +// CHECK:STDOUT: +// CHECK:STDOUT: } { +// CHECK:STDOUT: +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: // CHECK:STDOUT: %Cpp.ref: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %foo.ref: = name_ref foo, [concrete = ] +// CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] // CHECK:STDOUT: %a.ref: ref %i32 = name_ref a, %a -// CHECK:STDOUT: %addr.loc16: %ptr.235 = addr_of %a.ref +// CHECK:STDOUT: %addr.loc9: %ptr.235 = addr_of %a.ref +// CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%addr.loc9) // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_import_const_int_pointer.carbon +// CHECK:STDOUT: --- import_const_int_pointer.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] // CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [concrete] +// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete] +// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { -// CHECK:STDOUT: .foo = +// CHECK:STDOUT: .foo = %foo.decl // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } +// CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] { +// CHECK:STDOUT: +// CHECK:STDOUT: } { +// CHECK:STDOUT: +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: // CHECK:STDOUT: %Cpp.ref: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %foo.ref: = name_ref foo, [concrete = ] +// CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] // CHECK:STDOUT: %a.ref: ref %i32 = name_ref a, %a -// CHECK:STDOUT: %addr.loc16: %ptr.235 = addr_of %a.ref +// CHECK:STDOUT: %addr.loc9: %ptr.235 = addr_of %a.ref +// CHECK:STDOUT: %foo.call: init %i32 = call %foo.ref(%addr.loc9) // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interop/cpp/function/pointer.carbon b/toolchain/check/testdata/interop/cpp/function/pointer.carbon new file mode 100644 index 000000000000..190edcfe9358 --- /dev/null +++ b/toolchain/check/testdata/interop/cpp/function/pointer.carbon @@ -0,0 +1,659 @@ +// 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/convert.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/function/pointer.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/function/pointer.carbon + +// ============================================================================ +// Pointer as a parameter type +// ============================================================================ + +// --- pointer_param.h + +struct S {}; + +auto foo(S* _Nonnull) -> void; + +// --- import_pointer_param.carbon + +library "[[@TEST_NAME]]"; + +import Cpp library "pointer_param.h"; + +fn F() { + //@dump-sem-ir-begin + var s: Cpp.S = {}; + Cpp.foo(&s); + //@dump-sem-ir-end +} + +// ============================================================================ +// Double pointer as a parameter type +// ============================================================================ + +// --- double_pointer_param.h + +struct S {}; + +auto foo(S* _Nonnull * _Nonnull) -> void; + +// --- fail_todo_import_double_pointer_param.carbon + +library "[[@TEST_NAME]]"; + +import Cpp library "double_pointer_param.h"; + +fn F() { + //@dump-sem-ir-begin + var s: Cpp.S = {}; + var p: Cpp.S* = &s; + // CHECK:STDERR: fail_todo_import_double_pointer_param.carbon:[[@LINE+14]]:3: error: semantics TODO: `Unsupported: pointer to pointer type: S * _Nonnull` [SemanticsTodo] + // CHECK:STDERR: Cpp.foo(&p); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: fail_todo_import_double_pointer_param.carbon:[[@LINE+11]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] + // CHECK:STDERR: Cpp.foo(&p); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: + // CHECK:STDERR: fail_todo_import_double_pointer_param.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: S * _Nonnull * _Nonnull` [SemanticsTodo] + // CHECK:STDERR: Cpp.foo(&p); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: fail_todo_import_double_pointer_param.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] + // CHECK:STDERR: Cpp.foo(&p); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: + Cpp.foo(&p); + //@dump-sem-ir-end +} + +// ============================================================================ +// Const pointer as a parameter type +// ============================================================================ + +// --- const_pointer_param.h + +struct S {}; + +auto foo(const S* _Nonnull) -> void; + +// --- fail_todo_import_const_pointer_param.carbon + +library "[[@TEST_NAME]]"; + +import Cpp library "const_pointer_param.h"; + +fn G() -> const Cpp.S; + +fn F() { + //@dump-sem-ir-begin + var s: const Cpp.S = G(); + // CHECK:STDERR: fail_todo_import_const_pointer_param.carbon:[[@LINE+8]]:11: error: cannot implicitly convert expression of type `const Cpp.S*` to `Cpp.S*` [ConversionFailure] + // CHECK:STDERR: Cpp.foo(&s); + // CHECK:STDERR: ^~ + // CHECK:STDERR: fail_todo_import_const_pointer_param.carbon:[[@LINE+5]]:11: note: type `const Cpp.S*` does not implement interface `Core.ImplicitAs(Cpp.S*)` [MissingImplInMemberAccessNote] + // CHECK:STDERR: Cpp.foo(&s); + // CHECK:STDERR: ^~ + // CHECK:STDERR: fail_todo_import_const_pointer_param.carbon: note: initializing function parameter [InCallToFunctionParam] + // CHECK:STDERR: + Cpp.foo(&s); + //@dump-sem-ir-end +} + +// ============================================================================ +// Pointer as a return value +// ============================================================================ + +// --- pointer_return.h + +struct S {}; + +auto foo() -> S* _Nonnull; + +// --- import_pointer_return.carbon + +library "[[@TEST_NAME]]"; + +import Cpp library "pointer_return.h"; + +fn IngestDoublePointer(s: Cpp.S*); + +fn F() { + //@dump-sem-ir-begin + IngestDoublePointer(Cpp.foo()); + Cpp.foo(); + //@dump-sem-ir-end +} + +// ============================================================================ +// Double pointer as a return value +// ============================================================================ + +// --- double_pointer_return.h + +struct S {}; + +auto foo() -> S* _Nonnull * _Nonnull; + +// --- fail_todo_import_double_pointer_return.carbon + +library "[[@TEST_NAME]]"; + +import Cpp library "double_pointer_return.h"; + +fn IngestDoublePointer(s: Cpp.S**); + +fn F() { + //@dump-sem-ir-begin + // CHECK:STDERR: fail_todo_import_double_pointer_return.carbon:[[@LINE+14]]:23: error: semantics TODO: `Unsupported: pointer to pointer type: S * _Nonnull` [SemanticsTodo] + // CHECK:STDERR: IngestDoublePointer(Cpp.foo()); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: fail_todo_import_double_pointer_return.carbon:[[@LINE+11]]:23: note: in `Cpp` name lookup for `foo` [InCppNameLookup] + // CHECK:STDERR: IngestDoublePointer(Cpp.foo()); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: + // CHECK:STDERR: fail_todo_import_double_pointer_return.carbon:[[@LINE+7]]:23: error: semantics TODO: `Unsupported: return type: S * _Nonnull * _Nonnull` [SemanticsTodo] + // CHECK:STDERR: IngestDoublePointer(Cpp.foo()); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: fail_todo_import_double_pointer_return.carbon:[[@LINE+4]]:23: note: in `Cpp` name lookup for `foo` [InCppNameLookup] + // CHECK:STDERR: IngestDoublePointer(Cpp.foo()); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: + IngestDoublePointer(Cpp.foo()); + Cpp.foo(); + //@dump-sem-ir-end +} + +// ============================================================================ +// Const pointer as a return value +// ============================================================================ + +// --- const_pointer_return.h + +struct S {}; + +auto foo() -> const S* _Nonnull; + +// --- fail_todo_import_const_pointer_return.carbon + +library "[[@TEST_NAME]]"; + +import Cpp library "const_pointer_return.h"; + +fn IngestConstPointer(s: const Cpp.S*); + +fn F() { + //@dump-sem-ir-begin + // CHECK:STDERR: fail_todo_import_const_pointer_return.carbon:[[@LINE+10]]:22: error: cannot implicitly convert expression of type `Cpp.S*` to `const Cpp.S*` [ConversionFailure] + // CHECK:STDERR: IngestConstPointer(Cpp.foo()); + // CHECK:STDERR: ^~~~~~~~~ + // CHECK:STDERR: fail_todo_import_const_pointer_return.carbon:[[@LINE+7]]:22: note: type `Cpp.S*` does not implement interface `Core.ImplicitAs(const Cpp.S*)` [MissingImplInMemberAccessNote] + // CHECK:STDERR: IngestConstPointer(Cpp.foo()); + // CHECK:STDERR: ^~~~~~~~~ + // CHECK:STDERR: fail_todo_import_const_pointer_return.carbon:[[@LINE-10]]:23: note: initializing function parameter [InCallToFunctionParam] + // CHECK:STDERR: fn IngestConstPointer(s: const Cpp.S*); + // CHECK:STDERR: ^~~~~~~~~~~~~~~ + // CHECK:STDERR: + IngestConstPointer(Cpp.foo()); + Cpp.foo(); + //@dump-sem-ir-end +} + +// ============================================================================ +// Nullable pointer +// ============================================================================ + +// --- nullable_pointer_param.h + +struct S {}; + +auto foo(S*) -> void; + +// --- fail_todo_import_nullable_pointer_param.carbon + +library "[[@TEST_NAME]]"; + +import Cpp library "nullable_pointer_param.h"; + +fn F() { + //@dump-sem-ir-begin + var s: Cpp.S = {}; + // CHECK:STDERR: fail_todo_import_nullable_pointer_param.carbon:[[@LINE+14]]:3: error: semantics TODO: `Unsupported: nullable pointer: S *` [SemanticsTodo] + // CHECK:STDERR: Cpp.foo(&s); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: fail_todo_import_nullable_pointer_param.carbon:[[@LINE+11]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] + // CHECK:STDERR: Cpp.foo(&s); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: + // CHECK:STDERR: fail_todo_import_nullable_pointer_param.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: S *` [SemanticsTodo] + // CHECK:STDERR: Cpp.foo(&s); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: fail_todo_import_nullable_pointer_param.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] + // CHECK:STDERR: Cpp.foo(&s); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: + Cpp.foo(&s); + //@dump-sem-ir-end +} + +// CHECK:STDOUT: --- import_pointer_param.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %S: type = class_type @S [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %pattern_type.7da: type = pattern_type %S [concrete] +// CHECK:STDOUT: %S.val: %S = struct_value () [concrete] +// CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete] +// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete] +// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete] +// CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete] +// CHECK:STDOUT: %Op.type.bae: type = fn_type @Op.1 [concrete] +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %Op.type.bc9: type = fn_type @Op.2, @impl(%T) [symbolic] +// CHECK:STDOUT: %Op.46f: %Op.type.bc9 = struct_value () [symbolic] +// CHECK:STDOUT: %Destroy.impl_witness.2d2: = impl_witness imports.%Destroy.impl_witness_table, @impl(%S) [concrete] +// CHECK:STDOUT: %Op.type.642: type = fn_type @Op.2, @impl(%S) [concrete] +// CHECK:STDOUT: %Op.ab5: %Op.type.642 = struct_value () [concrete] +// CHECK:STDOUT: %Destroy.facet: %Destroy.type = facet_value %S, (%Destroy.impl_witness.2d2) [concrete] +// CHECK:STDOUT: %.271: type = fn_type_with_self_type %Op.type.bae, %Destroy.facet [concrete] +// CHECK:STDOUT: %Op.specific_fn: = specific_function %Op.ab5, @Op.2(%S) [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { +// CHECK:STDOUT: .S = %S.decl +// CHECK:STDOUT: .foo = %foo.decl +// CHECK:STDOUT: import Cpp//... +// CHECK:STDOUT: } +// CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {} +// CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] { +// CHECK:STDOUT: +// CHECK:STDOUT: } { +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import_ref.0b9: @impl.%Op.type (%Op.type.bc9) = import_ref Core//prelude/parts/destroy, loc8_29, loaded [symbolic = @impl.%Op (constants.%Op.46f)] +// CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (%Core.import_ref.0b9), @impl [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %s.patt: %pattern_type.7da = binding_pattern s [concrete] +// CHECK:STDOUT: %s.var_patt: %pattern_type.7da = var_pattern %s.patt [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %s.var: ref %S = var %s.var_patt +// CHECK:STDOUT: %.loc8_19.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc8_19.2: init %S = class_init (), %s.var [concrete = constants.%S.val] +// CHECK:STDOUT: %.loc8_3: init %S = converted %.loc8_19.1, %.loc8_19.2 [concrete = constants.%S.val] +// CHECK:STDOUT: assign %s.var, %.loc8_3 +// CHECK:STDOUT: %.loc8_13: type = splice_block %S.ref [concrete = constants.%S] { +// CHECK:STDOUT: %Cpp.ref.loc8: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S] +// CHECK:STDOUT: } +// CHECK:STDOUT: %s: ref %S = bind_name s, %s.var +// CHECK:STDOUT: %Cpp.ref.loc9: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] +// CHECK:STDOUT: %s.ref: ref %S = name_ref s, %s +// CHECK:STDOUT: %addr.loc9: %ptr.5c7 = addr_of %s.ref +// CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%addr.loc9) +// CHECK:STDOUT: %impl.elem0: %.271 = impl_witness_access constants.%Destroy.impl_witness.2d2, element0 [concrete = constants.%Op.ab5] +// CHECK:STDOUT: %bound_method.loc8_3.1: = bound_method %s.var, %impl.elem0 +// CHECK:STDOUT: %specific_fn: = specific_function %impl.elem0, @Op.2(constants.%S) [concrete = constants.%Op.specific_fn] +// CHECK:STDOUT: %bound_method.loc8_3.2: = bound_method %s.var, %specific_fn +// CHECK:STDOUT: %addr.loc8: %ptr.5c7 = addr_of %s.var +// CHECK:STDOUT: %no_op: init %empty_tuple.type = call %bound_method.loc8_3.2(%addr.loc8) +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_import_double_pointer_param.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %S: type = class_type @S [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %pattern_type.7da: type = pattern_type %S [concrete] +// CHECK:STDOUT: %S.val: %S = struct_value () [concrete] +// CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete] +// CHECK:STDOUT: %pattern_type.259: type = pattern_type %ptr.5c7 [concrete] +// CHECK:STDOUT: %ptr.dfe: type = ptr_type %ptr.5c7 [concrete] +// CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete] +// CHECK:STDOUT: %Op.type.bae: type = fn_type @Op.1 [concrete] +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %Op.type.bc9: type = fn_type @Op.2, @impl(%T) [symbolic] +// CHECK:STDOUT: %Op.46f: %Op.type.bc9 = struct_value () [symbolic] +// CHECK:STDOUT: %Destroy.impl_witness.79a: = impl_witness imports.%Destroy.impl_witness_table, @impl(%ptr.5c7) [concrete] +// CHECK:STDOUT: %Op.type.c07: type = fn_type @Op.2, @impl(%ptr.5c7) [concrete] +// CHECK:STDOUT: %Op.64b: %Op.type.c07 = struct_value () [concrete] +// CHECK:STDOUT: %Destroy.facet.a4e: %Destroy.type = facet_value %ptr.5c7, (%Destroy.impl_witness.79a) [concrete] +// CHECK:STDOUT: %.33b: type = fn_type_with_self_type %Op.type.bae, %Destroy.facet.a4e [concrete] +// CHECK:STDOUT: %Op.specific_fn.131: = specific_function %Op.64b, @Op.2(%ptr.5c7) [concrete] +// CHECK:STDOUT: %Destroy.impl_witness.2d2: = impl_witness imports.%Destroy.impl_witness_table, @impl(%S) [concrete] +// CHECK:STDOUT: %Op.type.642: type = fn_type @Op.2, @impl(%S) [concrete] +// CHECK:STDOUT: %Op.ab5: %Op.type.642 = struct_value () [concrete] +// CHECK:STDOUT: %Destroy.facet.556: %Destroy.type = facet_value %S, (%Destroy.impl_witness.2d2) [concrete] +// CHECK:STDOUT: %.271: type = fn_type_with_self_type %Op.type.bae, %Destroy.facet.556 [concrete] +// CHECK:STDOUT: %Op.specific_fn.4ce: = specific_function %Op.ab5, @Op.2(%S) [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { +// CHECK:STDOUT: .S = %S.decl +// CHECK:STDOUT: .foo = +// CHECK:STDOUT: import Cpp//... +// CHECK:STDOUT: } +// CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {} +// CHECK:STDOUT: %Core.import_ref.0b9: @impl.%Op.type (%Op.type.bc9) = import_ref Core//prelude/parts/destroy, loc8_29, loaded [symbolic = @impl.%Op (constants.%Op.46f)] +// CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (%Core.import_ref.0b9), @impl [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %s.patt: %pattern_type.7da = binding_pattern s [concrete] +// CHECK:STDOUT: %s.var_patt: %pattern_type.7da = var_pattern %s.patt [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %s.var: ref %S = var %s.var_patt +// CHECK:STDOUT: %.loc8_19.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc8_19.2: init %S = class_init (), %s.var [concrete = constants.%S.val] +// CHECK:STDOUT: %.loc8_3: init %S = converted %.loc8_19.1, %.loc8_19.2 [concrete = constants.%S.val] +// CHECK:STDOUT: assign %s.var, %.loc8_3 +// CHECK:STDOUT: %.loc8_13: type = splice_block %S.ref.loc8 [concrete = constants.%S] { +// CHECK:STDOUT: %Cpp.ref.loc8: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %S.ref.loc8: type = name_ref S, imports.%S.decl [concrete = constants.%S] +// CHECK:STDOUT: } +// CHECK:STDOUT: %s: ref %S = bind_name s, %s.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %p.patt: %pattern_type.259 = binding_pattern p [concrete] +// CHECK:STDOUT: %p.var_patt: %pattern_type.259 = var_pattern %p.patt [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %p.var: ref %ptr.5c7 = var %p.var_patt +// CHECK:STDOUT: %s.ref: ref %S = name_ref s, %s +// CHECK:STDOUT: %addr.loc9_19: %ptr.5c7 = addr_of %s.ref +// CHECK:STDOUT: assign %p.var, %addr.loc9_19 +// CHECK:STDOUT: %.loc9: type = splice_block %ptr [concrete = constants.%ptr.5c7] { +// CHECK:STDOUT: %Cpp.ref.loc9: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %S.ref.loc9: type = name_ref S, imports.%S.decl [concrete = constants.%S] +// CHECK:STDOUT: %ptr: type = ptr_type %S.ref.loc9 [concrete = constants.%ptr.5c7] +// CHECK:STDOUT: } +// CHECK:STDOUT: %p: ref %ptr.5c7 = bind_name p, %p.var +// CHECK:STDOUT: %Cpp.ref.loc24: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %foo.ref: = name_ref foo, [concrete = ] +// CHECK:STDOUT: %p.ref: ref %ptr.5c7 = name_ref p, %p +// CHECK:STDOUT: %addr.loc24: %ptr.dfe = addr_of %p.ref +// CHECK:STDOUT: %impl.elem0.loc9: %.33b = impl_witness_access constants.%Destroy.impl_witness.79a, element0 [concrete = constants.%Op.64b] +// CHECK:STDOUT: %bound_method.loc9_3.1: = bound_method %p.var, %impl.elem0.loc9 +// CHECK:STDOUT: %specific_fn.loc9: = specific_function %impl.elem0.loc9, @Op.2(constants.%ptr.5c7) [concrete = constants.%Op.specific_fn.131] +// CHECK:STDOUT: %bound_method.loc9_3.2: = bound_method %p.var, %specific_fn.loc9 +// CHECK:STDOUT: %addr.loc9_3: %ptr.dfe = addr_of %p.var +// CHECK:STDOUT: %no_op.loc9: init %empty_tuple.type = call %bound_method.loc9_3.2(%addr.loc9_3) +// CHECK:STDOUT: %impl.elem0.loc8: %.271 = impl_witness_access constants.%Destroy.impl_witness.2d2, element0 [concrete = constants.%Op.ab5] +// CHECK:STDOUT: %bound_method.loc8_3.1: = bound_method %s.var, %impl.elem0.loc8 +// CHECK:STDOUT: %specific_fn.loc8: = specific_function %impl.elem0.loc8, @Op.2(constants.%S) [concrete = constants.%Op.specific_fn.4ce] +// CHECK:STDOUT: %bound_method.loc8_3.2: = bound_method %s.var, %specific_fn.loc8 +// CHECK:STDOUT: %addr.loc8: %ptr.5c7 = addr_of %s.var +// CHECK:STDOUT: %no_op.loc8: init %empty_tuple.type = call %bound_method.loc8_3.2(%addr.loc8) +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_import_const_pointer_param.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %S: type = class_type @S [concrete] +// CHECK:STDOUT: %const: type = const_type %S [concrete] +// CHECK:STDOUT: %pattern_type.9be: type = pattern_type %const [concrete] +// CHECK:STDOUT: %G.type: type = fn_type @G [concrete] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %G: %G.type = struct_value () [concrete] +// CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete] +// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete] +// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete] +// CHECK:STDOUT: %ptr.ff5: type = ptr_type %const [concrete] +// CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete] +// CHECK:STDOUT: %Op.type.bae: type = fn_type @Op.1 [concrete] +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %Op.type.bc9: type = fn_type @Op.2, @impl(%T) [symbolic] +// CHECK:STDOUT: %Op.46f: %Op.type.bc9 = struct_value () [symbolic] +// CHECK:STDOUT: %Destroy.impl_witness.4d8: = impl_witness imports.%Destroy.impl_witness_table, @impl(%const) [concrete] +// CHECK:STDOUT: %Op.type.372: type = fn_type @Op.2, @impl(%const) [concrete] +// CHECK:STDOUT: %Op.af7: %Op.type.372 = struct_value () [concrete] +// CHECK:STDOUT: %Destroy.facet: %Destroy.type = facet_value %const, (%Destroy.impl_witness.4d8) [concrete] +// CHECK:STDOUT: %.af2: type = fn_type_with_self_type %Op.type.bae, %Destroy.facet [concrete] +// CHECK:STDOUT: %Op.specific_fn: = specific_function %Op.af7, @Op.2(%const) [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { +// CHECK:STDOUT: .S = %S.decl +// CHECK:STDOUT: .foo = %foo.decl +// CHECK:STDOUT: import Cpp//... +// CHECK:STDOUT: } +// CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {} +// CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] { +// CHECK:STDOUT: +// CHECK:STDOUT: } { +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import_ref.0b9: @impl.%Op.type (%Op.type.bc9) = import_ref Core//prelude/parts/destroy, loc8_29, loaded [symbolic = @impl.%Op (constants.%Op.46f)] +// CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (%Core.import_ref.0b9), @impl [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %s.patt: %pattern_type.9be = binding_pattern s [concrete] +// CHECK:STDOUT: %s.var_patt: %pattern_type.9be = var_pattern %s.patt [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %s.var: ref %const = var %s.var_patt +// CHECK:STDOUT: %G.ref: %G.type = name_ref G, file.%G.decl [concrete = constants.%G] +// CHECK:STDOUT: %.loc10_3: ref %const = splice_block %s.var {} +// CHECK:STDOUT: %G.call: init %const = call %G.ref() to %.loc10_3 +// CHECK:STDOUT: assign %s.var, %G.call +// CHECK:STDOUT: %.loc10_10: type = splice_block %const [concrete = constants.%const] { +// CHECK:STDOUT: %Cpp.ref.loc10: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S] +// CHECK:STDOUT: %const: type = const_type %S.ref [concrete = constants.%const] +// CHECK:STDOUT: } +// CHECK:STDOUT: %s: ref %const = bind_name s, %s.var +// CHECK:STDOUT: %Cpp.ref.loc19: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] +// CHECK:STDOUT: %s.ref: ref %const = name_ref s, %s +// CHECK:STDOUT: %addr.loc19: %ptr.ff5 = addr_of %s.ref +// CHECK:STDOUT: %.loc19: %ptr.5c7 = converted %addr.loc19, [concrete = ] +// CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref() +// CHECK:STDOUT: %impl.elem0.loc10_3.1: %.af2 = impl_witness_access constants.%Destroy.impl_witness.4d8, element0 [concrete = constants.%Op.af7] +// CHECK:STDOUT: %bound_method.loc10_3.1: = bound_method %.loc10_3, %impl.elem0.loc10_3.1 +// CHECK:STDOUT: %specific_fn.loc10_3.1: = specific_function %impl.elem0.loc10_3.1, @Op.2(constants.%const) [concrete = constants.%Op.specific_fn] +// CHECK:STDOUT: %bound_method.loc10_3.2: = bound_method %.loc10_3, %specific_fn.loc10_3.1 +// CHECK:STDOUT: %addr.loc10_3.1: %ptr.ff5 = addr_of %.loc10_3 +// CHECK:STDOUT: %no_op.loc10_3.1: init %empty_tuple.type = call %bound_method.loc10_3.2(%addr.loc10_3.1) +// CHECK:STDOUT: %impl.elem0.loc10_3.2: %.af2 = impl_witness_access constants.%Destroy.impl_witness.4d8, element0 [concrete = constants.%Op.af7] +// CHECK:STDOUT: %bound_method.loc10_3.3: = bound_method %s.var, %impl.elem0.loc10_3.2 +// CHECK:STDOUT: %specific_fn.loc10_3.2: = specific_function %impl.elem0.loc10_3.2, @Op.2(constants.%const) [concrete = constants.%Op.specific_fn] +// CHECK:STDOUT: %bound_method.loc10_3.4: = bound_method %s.var, %specific_fn.loc10_3.2 +// CHECK:STDOUT: %addr.loc10_3.2: %ptr.ff5 = addr_of %s.var +// CHECK:STDOUT: %no_op.loc10_3.2: init %empty_tuple.type = call %bound_method.loc10_3.4(%addr.loc10_3.2) +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- import_pointer_return.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %S: type = class_type @S [concrete] +// CHECK:STDOUT: %ptr: type = ptr_type %S [concrete] +// CHECK:STDOUT: %IngestDoublePointer.type: type = fn_type @IngestDoublePointer [concrete] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %IngestDoublePointer: %IngestDoublePointer.type = struct_value () [concrete] +// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete] +// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { +// CHECK:STDOUT: .S = %S.decl +// CHECK:STDOUT: .foo = %foo.decl +// CHECK:STDOUT: import Cpp//... +// CHECK:STDOUT: } +// CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {} +// CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] { +// CHECK:STDOUT: +// CHECK:STDOUT: } { +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %IngestDoublePointer.ref: %IngestDoublePointer.type = name_ref IngestDoublePointer, file.%IngestDoublePointer.decl [concrete = constants.%IngestDoublePointer] +// CHECK:STDOUT: %Cpp.ref.loc10: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %foo.ref.loc10: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] +// CHECK:STDOUT: %foo.call.loc10: init %ptr = call %foo.ref.loc10() +// CHECK:STDOUT: %.loc10_31.1: %ptr = value_of_initializer %foo.call.loc10 +// CHECK:STDOUT: %.loc10_31.2: %ptr = converted %foo.call.loc10, %.loc10_31.1 +// CHECK:STDOUT: %IngestDoublePointer.call: init %empty_tuple.type = call %IngestDoublePointer.ref(%.loc10_31.2) +// CHECK:STDOUT: %Cpp.ref.loc11: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %foo.ref.loc11: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] +// CHECK:STDOUT: %foo.call.loc11: init %ptr = call %foo.ref.loc11() +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_import_double_pointer_return.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %S: type = class_type @S [concrete] +// CHECK:STDOUT: %IngestDoublePointer.type: type = fn_type @IngestDoublePointer [concrete] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %IngestDoublePointer: %IngestDoublePointer.type = struct_value () [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { +// CHECK:STDOUT: .S = %S.decl +// CHECK:STDOUT: .foo = +// CHECK:STDOUT: import Cpp//... +// CHECK:STDOUT: } +// CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %IngestDoublePointer.ref: %IngestDoublePointer.type = name_ref IngestDoublePointer, file.%IngestDoublePointer.decl [concrete = constants.%IngestDoublePointer] +// CHECK:STDOUT: %Cpp.ref.loc24: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %foo.ref.loc24: = name_ref foo, [concrete = ] +// CHECK:STDOUT: %IngestDoublePointer.call: init %empty_tuple.type = call %IngestDoublePointer.ref() +// CHECK:STDOUT: %Cpp.ref.loc25: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %foo.ref.loc25: = name_ref foo, [concrete = ] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_import_const_pointer_return.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %S: type = class_type @S [concrete] +// CHECK:STDOUT: %const: type = const_type %S [concrete] +// CHECK:STDOUT: %ptr.ff5: type = ptr_type %const [concrete] +// CHECK:STDOUT: %IngestConstPointer.type: type = fn_type @IngestConstPointer [concrete] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %IngestConstPointer: %IngestConstPointer.type = struct_value () [concrete] +// CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete] +// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete] +// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { +// CHECK:STDOUT: .S = %S.decl +// CHECK:STDOUT: .foo = %foo.decl +// CHECK:STDOUT: import Cpp//... +// CHECK:STDOUT: } +// CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {} +// CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] { +// CHECK:STDOUT: +// CHECK:STDOUT: } { +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %IngestConstPointer.ref: %IngestConstPointer.type = name_ref IngestConstPointer, file.%IngestConstPointer.decl [concrete = constants.%IngestConstPointer] +// CHECK:STDOUT: %Cpp.ref.loc20: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %foo.ref.loc20: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] +// CHECK:STDOUT: %foo.call.loc20: init %ptr.5c7 = call %foo.ref.loc20() +// CHECK:STDOUT: %.loc20: %ptr.ff5 = converted %foo.call.loc20, [concrete = ] +// CHECK:STDOUT: %IngestConstPointer.call: init %empty_tuple.type = call %IngestConstPointer.ref() +// CHECK:STDOUT: %Cpp.ref.loc21: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %foo.ref.loc21: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] +// CHECK:STDOUT: %foo.call.loc21: init %ptr.5c7 = call %foo.ref.loc21() +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_import_nullable_pointer_param.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %S: type = class_type @S [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %pattern_type.7da: type = pattern_type %S [concrete] +// CHECK:STDOUT: %S.val: %S = struct_value () [concrete] +// CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete] +// CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete] +// CHECK:STDOUT: %Op.type.bae: type = fn_type @Op.1 [concrete] +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %Op.type.bc9: type = fn_type @Op.2, @impl(%T) [symbolic] +// CHECK:STDOUT: %Op.46f: %Op.type.bc9 = struct_value () [symbolic] +// CHECK:STDOUT: %Destroy.impl_witness.2d2: = impl_witness imports.%Destroy.impl_witness_table, @impl(%S) [concrete] +// CHECK:STDOUT: %Op.type.642: type = fn_type @Op.2, @impl(%S) [concrete] +// CHECK:STDOUT: %Op.ab5: %Op.type.642 = struct_value () [concrete] +// CHECK:STDOUT: %Destroy.facet: %Destroy.type = facet_value %S, (%Destroy.impl_witness.2d2) [concrete] +// CHECK:STDOUT: %.271: type = fn_type_with_self_type %Op.type.bae, %Destroy.facet [concrete] +// CHECK:STDOUT: %Op.specific_fn: = specific_function %Op.ab5, @Op.2(%S) [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { +// CHECK:STDOUT: .S = %S.decl +// CHECK:STDOUT: .foo = +// CHECK:STDOUT: import Cpp//... +// CHECK:STDOUT: } +// CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {} +// CHECK:STDOUT: %Core.import_ref.0b9: @impl.%Op.type (%Op.type.bc9) = import_ref Core//prelude/parts/destroy, loc8_29, loaded [symbolic = @impl.%Op (constants.%Op.46f)] +// CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (%Core.import_ref.0b9), @impl [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %s.patt: %pattern_type.7da = binding_pattern s [concrete] +// CHECK:STDOUT: %s.var_patt: %pattern_type.7da = var_pattern %s.patt [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %s.var: ref %S = var %s.var_patt +// CHECK:STDOUT: %.loc8_19.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc8_19.2: init %S = class_init (), %s.var [concrete = constants.%S.val] +// CHECK:STDOUT: %.loc8_3: init %S = converted %.loc8_19.1, %.loc8_19.2 [concrete = constants.%S.val] +// CHECK:STDOUT: assign %s.var, %.loc8_3 +// CHECK:STDOUT: %.loc8_13: type = splice_block %S.ref [concrete = constants.%S] { +// CHECK:STDOUT: %Cpp.ref.loc8: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S] +// CHECK:STDOUT: } +// CHECK:STDOUT: %s: ref %S = bind_name s, %s.var +// CHECK:STDOUT: %Cpp.ref.loc23: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %foo.ref: = name_ref foo, [concrete = ] +// CHECK:STDOUT: %s.ref: ref %S = name_ref s, %s +// CHECK:STDOUT: %addr.loc23: %ptr.5c7 = addr_of %s.ref +// CHECK:STDOUT: %impl.elem0: %.271 = impl_witness_access constants.%Destroy.impl_witness.2d2, element0 [concrete = constants.%Op.ab5] +// CHECK:STDOUT: %bound_method.loc8_3.1: = bound_method %s.var, %impl.elem0 +// CHECK:STDOUT: %specific_fn: = specific_function %impl.elem0, @Op.2(constants.%S) [concrete = constants.%Op.specific_fn] +// CHECK:STDOUT: %bound_method.loc8_3.2: = bound_method %s.var, %specific_fn +// CHECK:STDOUT: %addr.loc8: %ptr.5c7 = addr_of %s.var +// CHECK:STDOUT: %no_op: init %empty_tuple.type = call %bound_method.loc8_3.2(%addr.loc8) +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/interop/cpp/function/struct.carbon b/toolchain/check/testdata/interop/cpp/function/struct.carbon index 0af2ca5b79f4..856ea1be5786 100644 --- a/toolchain/check/testdata/interop/cpp/function/struct.carbon +++ b/toolchain/check/testdata/interop/cpp/function/struct.carbon @@ -34,7 +34,7 @@ fn F() { // CHECK:STDERR: Cpp.foo({}); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: - // CHECK:STDERR: fail_todo_import_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: struct S` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: S` [SemanticsTodo] // CHECK:STDERR: Cpp.foo({}); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_value_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -63,7 +63,7 @@ fn F() { // CHECK:STDERR: ^ // CHECK:STDERR: let s: Cpp.S; - // CHECK:STDERR: fail_todo_import_decl_value_param_type_previously_imported.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: struct S` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_value_param_type_previously_imported.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: S` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(s); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_value_param_type_previously_imported.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -98,7 +98,7 @@ fn F() { // CHECK:STDERR: Cpp.foo1({}); // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: - // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: struct S` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: S` [SemanticsTodo] // CHECK:STDERR: Cpp.foo1({}); // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo1` [InCppNameLookup] @@ -106,7 +106,7 @@ fn F() { // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: Cpp.foo1({}); - // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: struct S` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: S` [SemanticsTodo] // CHECK:STDERR: Cpp.foo2({}); // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo2` [InCppNameLookup] @@ -283,7 +283,7 @@ fn F() { struct S; -auto foo(S*) -> void; +auto foo(S* _Nonnull) -> void; // --- fail_todo_import_decl_pointer_param_type.carbon @@ -300,7 +300,7 @@ import Cpp library "decl_pointer_param_type.h"; // CHECK:STDERR: fn F(s: Cpp.S*) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_decl_pointer_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: struct S *` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_pointer_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: S * _Nonnull` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(s); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_pointer_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -319,9 +319,9 @@ fn F(s: Cpp.S*) { struct S {}; -auto foo(S*) -> void; +auto foo(S* _Nonnull) -> void; -// --- fail_todo_import_definition_pointer_param_type.carbon +// --- import_definition_pointer_param_type.carbon library "[[@TEST_NAME]]"; @@ -329,13 +329,6 @@ import Cpp library "definition_pointer_param_type.h"; fn F(s: Cpp.S*) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_definition_pointer_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: struct S *` [SemanticsTodo] - // CHECK:STDERR: Cpp.foo(s); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: fail_todo_import_definition_pointer_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] - // CHECK:STDERR: Cpp.foo(s); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: Cpp.foo(s); //@dump-sem-ir-end } @@ -364,7 +357,7 @@ fn F() { // CHECK:STDERR: Cpp.foo(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: - // CHECK:STDERR: fail_todo_import_decl_value_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: struct S` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_value_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: S` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_value_return_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -404,7 +397,7 @@ fn F() { struct S; -auto foo() -> S*; +auto foo() -> S* _Nonnull; // --- fail_todo_import_decl_pointer_return_type.carbon @@ -414,7 +407,14 @@ import Cpp library "decl_pointer_return_type.h"; fn F() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: struct S *` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+14]]:3: error: semantics TODO: `Unsupported: Record declarations without a definition` [SemanticsTodo] + // CHECK:STDERR: Cpp.foo(); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+11]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] + // CHECK:STDERR: Cpp.foo(); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: + // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: S * _Nonnull` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -433,9 +433,9 @@ fn F() { struct S {}; -auto foo() -> S*; +auto foo() -> S* _Nonnull; -// --- fail_todo_import_definition_pointer_return_type.carbon +// --- import_definition_pointer_return_type.carbon library "[[@TEST_NAME]]"; @@ -443,13 +443,6 @@ import Cpp library "definition_pointer_return_type.h"; fn F() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_definition_pointer_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: struct S *` [SemanticsTodo] - // CHECK:STDERR: Cpp.foo(); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: fail_todo_import_definition_pointer_return_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] - // CHECK:STDERR: Cpp.foo(); - // CHECK:STDERR: ^~~~~~~ - // CHECK:STDERR: Cpp.foo(); //@dump-sem-ir-end } @@ -904,27 +897,36 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_import_definition_pointer_param_type.carbon +// CHECK:STDOUT: --- import_definition_pointer_param_type.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %S: type = class_type @S [concrete] // CHECK:STDOUT: %ptr: type = ptr_type %S [concrete] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete] +// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { // CHECK:STDOUT: .S = %S.decl -// CHECK:STDOUT: .foo = +// CHECK:STDOUT: .foo = %foo.decl // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {} +// CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] { +// CHECK:STDOUT: +// CHECK:STDOUT: } { +// CHECK:STDOUT: +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%s.param: %ptr) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Cpp.ref.loc15: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %foo.ref: = name_ref foo, [concrete = ] +// CHECK:STDOUT: %Cpp.ref.loc8: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] // CHECK:STDOUT: %s.ref: %ptr = name_ref s, %s +// CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%s.ref) // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: @@ -989,6 +991,7 @@ fn F() { // CHECK:STDOUT: imports { // CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { // CHECK:STDOUT: .foo = +// CHECK:STDOUT: .S = // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -1000,22 +1003,34 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_import_definition_pointer_return_type.carbon +// CHECK:STDOUT: --- import_definition_pointer_return_type.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %S: type = class_type @S [concrete] +// CHECK:STDOUT: %ptr: type = ptr_type %S [concrete] +// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete] +// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { -// CHECK:STDOUT: .foo = +// CHECK:STDOUT: .foo = %foo.decl +// CHECK:STDOUT: .S = %S.decl // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } +// CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {} +// CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] { +// CHECK:STDOUT: +// CHECK:STDOUT: } { +// CHECK:STDOUT: +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Cpp.ref: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %foo.ref: = name_ref foo, [concrete = ] +// CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo] +// CHECK:STDOUT: %foo.call: init %ptr = call %foo.ref() // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interop/cpp/function/union.carbon b/toolchain/check/testdata/interop/cpp/function/union.carbon index 6cf657cf3789..2f2342a94627 100644 --- a/toolchain/check/testdata/interop/cpp/function/union.carbon +++ b/toolchain/check/testdata/interop/cpp/function/union.carbon @@ -29,7 +29,7 @@ import Cpp library "decl_value_param_type.h"; fn F() { //@dump-sem-ir-begin // TODO: This should fail on the fact `U` is declared and not defined. - // CHECK:STDERR: fail_todo_import_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: union U` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: U` [SemanticsTodo] // CHECK:STDERR: Cpp.foo({}); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_value_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -59,7 +59,7 @@ fn F() { // CHECK:STDERR: ^ // CHECK:STDERR: let u: Cpp.U; - // CHECK:STDERR: fail_todo_import_decl_value_param_type_previously_imported.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: union U` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_value_param_type_previously_imported.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: U` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(u); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_value_param_type_previously_imported.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -87,7 +87,7 @@ library "[[@TEST_NAME]]"; import Cpp library "double_decl_value_param_type.h"; fn F() { - // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: union U` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: U` [SemanticsTodo] // CHECK:STDERR: Cpp.foo1({}); // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo1` [InCppNameLookup] @@ -95,7 +95,7 @@ fn F() { // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: Cpp.foo1({}); - // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: union U` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: U` [SemanticsTodo] // CHECK:STDERR: Cpp.foo2({}); // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: fail_todo_import_double_decl_value_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo2` [InCppNameLookup] @@ -123,7 +123,7 @@ import Cpp library "definition_no_data_members_value_param_type.h"; fn F() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_definition_no_data_members_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: union U` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_definition_no_data_members_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: U` [SemanticsTodo] // CHECK:STDERR: Cpp.foo({}); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_definition_no_data_members_value_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -156,7 +156,7 @@ import Cpp library "definition_single_data_member_value_param_type.h"; fn F() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_definition_single_data_member_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: union U` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_definition_single_data_member_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: U` [SemanticsTodo] // CHECK:STDERR: Cpp.foo({}); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_definition_single_data_member_value_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -191,7 +191,7 @@ import Cpp library "definition_multiple_data_members_value_param_type.h"; fn F() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_definition_multiple_data_members_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: union U` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_definition_multiple_data_members_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: U` [SemanticsTodo] // CHECK:STDERR: Cpp.foo({}); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_definition_multiple_data_members_value_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -220,7 +220,7 @@ import Cpp library "definition_in_namespace_value_param_type.h"; fn F() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_definition_in_namespace_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: union N::U` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_definition_in_namespace_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: N::U` [SemanticsTodo] // CHECK:STDERR: Cpp.foo({}); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_definition_in_namespace_value_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -250,7 +250,7 @@ import Cpp library "definition_in_relative_namespace_value_param_type.h"; fn F() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_definition_in_relative_namespace_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: union N1::N2::U` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_definition_in_relative_namespace_value_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: N2::U` [SemanticsTodo] // CHECK:STDERR: Cpp.N1.foo({}); // CHECK:STDERR: ^~~~~~~~~~ // CHECK:STDERR: fail_todo_import_definition_in_relative_namespace_value_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -282,7 +282,7 @@ import Cpp library "definition_with_static_method.h"; fn F() { //@dump-sem-ir-begin Cpp.U.bar(); - // CHECK:STDERR: fail_todo_import_definition_and_static_method_call_before.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: union U` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_definition_and_static_method_call_before.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: U` [SemanticsTodo] // CHECK:STDERR: Cpp.foo({}); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_definition_and_static_method_call_before.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -301,7 +301,7 @@ import Cpp library "definition_with_static_method.h"; fn F() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_definition_and_static_method_call_after.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: union U` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_definition_and_static_method_call_after.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: U` [SemanticsTodo] // CHECK:STDERR: Cpp.foo({}); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_definition_and_static_method_call_after.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -321,7 +321,7 @@ fn F() { union U; -auto foo(U*) -> void; +auto foo(U* _Nonnull) -> void; // --- fail_todo_import_decl_pointer_param_type.carbon @@ -338,7 +338,7 @@ import Cpp library "decl_pointer_param_type.h"; // CHECK:STDERR: fn F(u: Cpp.U*) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_decl_pointer_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: union U *` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_pointer_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: U * _Nonnull` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(u); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_pointer_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -357,7 +357,7 @@ fn F(u: Cpp.U*) { union U {}; -auto foo(U*) -> void; +auto foo(U* _Nonnull) -> void; // --- fail_todo_import_definition_pointer_param_type.carbon @@ -367,7 +367,7 @@ import Cpp library "definition_pointer_param_type.h"; fn F(u: Cpp.U*) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_definition_pointer_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: union U *` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_definition_pointer_param_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: U * _Nonnull` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(u); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_definition_pointer_param_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -396,7 +396,7 @@ import Cpp library "decl_value_return_type.h"; fn F() { // TODO: This should fail on the fact `U` is declared and not defined. - // CHECK:STDERR: fail_todo_import_decl_value_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: union U` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_value_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: U` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_value_return_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -424,7 +424,7 @@ import Cpp library "definition_value_return_type.h"; fn F() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_definition_value_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: union U` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_definition_value_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: U` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_definition_value_return_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -453,7 +453,14 @@ import Cpp library "decl_pointer_return_type.h"; fn F() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: union U *` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+14]]:3: error: semantics TODO: `Unsupported: nullable pointer: U *` [SemanticsTodo] + // CHECK:STDERR: Cpp.foo(); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+11]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] + // CHECK:STDERR: Cpp.foo(); + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: + // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: U *` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_decl_pointer_return_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup] @@ -472,7 +479,7 @@ fn F() { union U {}; -auto foo() -> U*; +auto foo() -> U* _Nonnull; // --- fail_todo_import_definition_pointer_return_type.carbon @@ -482,7 +489,7 @@ import Cpp library "definition_pointer_return_type.h"; fn F() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_import_definition_pointer_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: union U *` [SemanticsTodo] + // CHECK:STDERR: fail_todo_import_definition_pointer_return_type.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: return type: U * _Nonnull` [SemanticsTodo] // CHECK:STDERR: Cpp.foo(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_todo_import_definition_pointer_return_type.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup]