|
|
@@ -199,60 +199,6 @@ fn MyF(bar: Cpp.Bar*) {
|
|
|
}
|
|
|
//@dump-sem-ir-end
|
|
|
|
|
|
-// ============================================================================
|
|
|
-// To inherit public
|
|
|
-// ============================================================================
|
|
|
-
|
|
|
-// --- to_inherit_public.h
|
|
|
-
|
|
|
-struct Bar { static auto foo() -> void; };
|
|
|
-
|
|
|
-// --- import_to_inherit_public.carbon
|
|
|
-
|
|
|
-library "[[@TEST_NAME]]";
|
|
|
-
|
|
|
-import Cpp library "to_inherit_public.h";
|
|
|
-
|
|
|
-//@dump-sem-ir-begin
|
|
|
-class Derived {
|
|
|
- extend base: Cpp.Bar;
|
|
|
-}
|
|
|
-
|
|
|
-fn MyF() {
|
|
|
- Derived.foo();
|
|
|
-}
|
|
|
-//@dump-sem-ir-end
|
|
|
-
|
|
|
-// ============================================================================
|
|
|
-// To inherit private
|
|
|
-// ============================================================================
|
|
|
-
|
|
|
-// --- to_inherit_private.h
|
|
|
-
|
|
|
-struct Bar {
|
|
|
- private:
|
|
|
- static auto foo() -> void;
|
|
|
-};
|
|
|
-
|
|
|
-// --- fail_to_inherit_private.carbon
|
|
|
-
|
|
|
-library "[[@TEST_NAME]]";
|
|
|
-
|
|
|
-import Cpp library "to_inherit_private.h";
|
|
|
-
|
|
|
-class Derived {
|
|
|
- extend base: Cpp.Bar;
|
|
|
-}
|
|
|
-
|
|
|
-fn MyF() {
|
|
|
- // CHECK:STDERR: fail_to_inherit_private.carbon:[[@LINE+5]]:3: error: cannot access private member `foo` of type `Cpp.Bar` [ClassInvalidMemberAccess]
|
|
|
- // CHECK:STDERR: Derived.foo();
|
|
|
- // CHECK:STDERR: ^~~~~~~~~~~
|
|
|
- // CHECK:STDERR: fail_to_inherit_private.carbon: note: declared here [ClassMemberDeclaration]
|
|
|
- // CHECK:STDERR:
|
|
|
- Derived.foo();
|
|
|
-}
|
|
|
-
|
|
|
// ============================================================================
|
|
|
// Template
|
|
|
// ============================================================================
|
|
|
@@ -577,59 +523,6 @@ fn MyF(bar: Cpp.Bar*);
|
|
|
// CHECK:STDOUT: return
|
|
|
// CHECK:STDOUT: }
|
|
|
// CHECK:STDOUT:
|
|
|
-// CHECK:STDOUT: --- import_to_inherit_public.carbon
|
|
|
-// CHECK:STDOUT:
|
|
|
-// CHECK:STDOUT: constants {
|
|
|
-// CHECK:STDOUT: %Derived: type = class_type @Derived [concrete]
|
|
|
-// CHECK:STDOUT: %Bar: type = class_type @Bar [concrete]
|
|
|
-// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
|
|
-// CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %Bar [concrete]
|
|
|
-// CHECK:STDOUT: %struct_type.base.36d: type = struct_type {.base: %Bar} [concrete]
|
|
|
-// CHECK:STDOUT: %complete_type.fff: <witness> = complete_type_witness %struct_type.base.36d [concrete]
|
|
|
-// CHECK:STDOUT: %MyF.type: type = fn_type @MyF [concrete]
|
|
|
-// CHECK:STDOUT: %MyF: %MyF.type = struct_value () [concrete]
|
|
|
-// CHECK:STDOUT: %Bar.foo.type: type = fn_type @Bar.foo [concrete]
|
|
|
-// CHECK:STDOUT: %Bar.foo: %Bar.foo.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: %Bar.foo.decl: %Bar.foo.type = fn_decl @Bar.foo [concrete = constants.%Bar.foo] {} {}
|
|
|
-// CHECK:STDOUT: }
|
|
|
-// CHECK:STDOUT:
|
|
|
-// CHECK:STDOUT: file {
|
|
|
-// CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [concrete = constants.%Derived] {} {}
|
|
|
-// CHECK:STDOUT: %MyF.decl: %MyF.type = fn_decl @MyF [concrete = constants.%MyF] {} {}
|
|
|
-// CHECK:STDOUT: }
|
|
|
-// CHECK:STDOUT:
|
|
|
-// CHECK:STDOUT: class @Derived {
|
|
|
-// 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: %.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: <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
|
|
|
-// CHECK:STDOUT: .Cpp = <poisoned>
|
|
|
-// CHECK:STDOUT: .base = %.loc8
|
|
|
-// CHECK:STDOUT: .foo = <poisoned>
|
|
|
-// CHECK:STDOUT: extend %Bar.ref
|
|
|
-// CHECK:STDOUT: }
|
|
|
-// CHECK:STDOUT:
|
|
|
-// CHECK:STDOUT: fn @MyF() {
|
|
|
-// CHECK:STDOUT: !entry:
|
|
|
-// CHECK:STDOUT: %Derived.ref: type = name_ref Derived, file.%Derived.decl [concrete = constants.%Derived]
|
|
|
-// 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()
|
|
|
-// CHECK:STDOUT: return
|
|
|
-// CHECK:STDOUT: }
|
|
|
-// CHECK:STDOUT:
|
|
|
// CHECK:STDOUT: --- fail_todo_import_template.carbon
|
|
|
// CHECK:STDOUT:
|
|
|
// CHECK:STDOUT: constants {
|