Skip to content

Commit 0365467

Browse files
authored
Merge toolchain/check/testdata/interop/cpp/class/struct.carbon into class.carbon (#6198)
The tests are almost identical and test the same logic so basically duplicated. The extra coverage that was in `struct.carbon` is added to `class.carbon`. One basic test in `struct.carbon` was left just to make sure `struct` is supported. Part of #5150.
1 parent 46c5209 commit 0365467

File tree

2 files changed

+36
-502
lines changed

2 files changed

+36
-502
lines changed

toolchain/check/testdata/interop/cpp/class/class.carbon

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,19 @@ fn MyF(bar : Cpp.Bar*) {
161161
class Bar {
162162
public:
163163
virtual ~Bar();
164+
virtual void f();
164165
};
165166

166-
// --- import_dynamic.carbon
167+
// --- call_dynamic.carbon
167168

168169
library "[[@TEST_NAME]]";
169170

170171
import Cpp library "dynamic.h";
171172

172173
//@dump-sem-ir-begin
173-
fn MyF(bar: Cpp.Bar*);
174+
fn MyF(bar: Cpp.Bar*) {
175+
bar->f();
176+
}
174177
//@dump-sem-ir-end
175178

176179
// ============================================================================
@@ -450,14 +453,19 @@ fn MyF(bar: Cpp.Bar*);
450453
// CHECK:STDOUT: return
451454
// CHECK:STDOUT: }
452455
// CHECK:STDOUT:
453-
// CHECK:STDOUT: --- import_dynamic.carbon
456+
// CHECK:STDOUT: --- call_dynamic.carbon
454457
// CHECK:STDOUT:
455458
// CHECK:STDOUT: constants {
456459
// CHECK:STDOUT: %Bar: type = class_type @Bar [concrete]
457-
// CHECK:STDOUT: %ptr: type = ptr_type %Bar [concrete]
458-
// CHECK:STDOUT: %pattern_type: type = pattern_type %ptr [concrete]
460+
// CHECK:STDOUT: %ptr.f68: type = ptr_type %Bar [concrete]
461+
// CHECK:STDOUT: %pattern_type.146: type = pattern_type %ptr.f68 [concrete]
459462
// CHECK:STDOUT: %MyF.type: type = fn_type @MyF [concrete]
463+
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
460464
// CHECK:STDOUT: %MyF: %MyF.type = struct_value () [concrete]
465+
// CHECK:STDOUT: %Bar.f.cpp_overload_set.type: type = cpp_overload_set_type @Bar.f.cpp_overload_set [concrete]
466+
// CHECK:STDOUT: %Bar.f.cpp_overload_set.value: %Bar.f.cpp_overload_set.type = cpp_overload_set_value @Bar.f.cpp_overload_set [concrete]
467+
// CHECK:STDOUT: %Bar.f.type: type = fn_type @Bar.f [concrete]
468+
// CHECK:STDOUT: %Bar.f: %Bar.f.type = struct_value () [concrete]
461469
// CHECK:STDOUT: }
462470
// CHECK:STDOUT:
463471
// CHECK:STDOUT: imports {
@@ -466,24 +474,39 @@ fn MyF(bar: Cpp.Bar*);
466474
// CHECK:STDOUT: import Cpp//...
467475
// CHECK:STDOUT: }
468476
// CHECK:STDOUT: %Bar.decl: type = class_decl @Bar [concrete = constants.%Bar] {} {}
477+
// CHECK:STDOUT: %Bar.f.cpp_overload_set.value: %Bar.f.cpp_overload_set.type = cpp_overload_set_value @Bar.f.cpp_overload_set [concrete = constants.%Bar.f.cpp_overload_set.value]
478+
// CHECK:STDOUT: %Bar.f.decl: %Bar.f.type = fn_decl @Bar.f [concrete = constants.%Bar.f] {
479+
// CHECK:STDOUT: <elided>
480+
// CHECK:STDOUT: } {
481+
// CHECK:STDOUT: <elided>
482+
// CHECK:STDOUT: }
469483
// CHECK:STDOUT: }
470484
// CHECK:STDOUT:
471485
// CHECK:STDOUT: file {
472486
// CHECK:STDOUT: %MyF.decl: %MyF.type = fn_decl @MyF [concrete = constants.%MyF] {
473-
// CHECK:STDOUT: %bar.patt: %pattern_type = binding_pattern bar [concrete]
474-
// CHECK:STDOUT: %bar.param_patt: %pattern_type = value_param_pattern %bar.patt, call_param0 [concrete]
487+
// CHECK:STDOUT: %bar.patt: %pattern_type.146 = binding_pattern bar [concrete]
488+
// CHECK:STDOUT: %bar.param_patt: %pattern_type.146 = value_param_pattern %bar.patt, call_param0 [concrete]
475489
// CHECK:STDOUT: } {
476-
// CHECK:STDOUT: %bar.param: %ptr = value_param call_param0
477-
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr] {
490+
// CHECK:STDOUT: %bar.param: %ptr.f68 = value_param call_param0
491+
// CHECK:STDOUT: %.loc7: type = splice_block %ptr [concrete = constants.%ptr.f68] {
478492
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
479493
// CHECK:STDOUT: %Bar.ref: type = name_ref Bar, imports.%Bar.decl [concrete = constants.%Bar]
480-
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr]
494+
// CHECK:STDOUT: %ptr: type = ptr_type %Bar.ref [concrete = constants.%ptr.f68]
481495
// CHECK:STDOUT: }
482-
// CHECK:STDOUT: %bar: %ptr = bind_name bar, %bar.param
496+
// CHECK:STDOUT: %bar: %ptr.f68 = bind_name bar, %bar.param
483497
// CHECK:STDOUT: }
484498
// CHECK:STDOUT: }
485499
// CHECK:STDOUT:
486-
// CHECK:STDOUT: fn @MyF(%bar.param: %ptr);
500+
// CHECK:STDOUT: fn @MyF(%bar.param: %ptr.f68) {
501+
// CHECK:STDOUT: !entry:
502+
// CHECK:STDOUT: %bar.ref: %ptr.f68 = name_ref bar, %bar
503+
// CHECK:STDOUT: %.loc8: ref %Bar = deref %bar.ref
504+
// CHECK:STDOUT: %f.ref: %Bar.f.cpp_overload_set.type = name_ref f, imports.%Bar.f.cpp_overload_set.value [concrete = constants.%Bar.f.cpp_overload_set.value]
505+
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc8, %f.ref
506+
// CHECK:STDOUT: %addr: %ptr.f68 = addr_of %.loc8
507+
// CHECK:STDOUT: %Bar.f.call: init %empty_tuple.type = call imports.%Bar.f.decl(%addr)
508+
// CHECK:STDOUT: return
509+
// CHECK:STDOUT: }
487510
// CHECK:STDOUT:
488511
// CHECK:STDOUT: --- import_to_inherit_public.carbon
489512
// CHECK:STDOUT:

0 commit comments

Comments
 (0)