Move and deduplicate testing access when a Carbon class extends a C++ record to access.carbon (#5897)

Followup of #5858.
Part of #5859.
This commit is contained in:
Boaz Brickner
2025-08-01 13:44:08 +00:00
committed by GitHub
parent 25681901bd
commit 7de86a0b10
3 changed files with 93 additions and 137 deletions
-30
View File
@@ -211,36 +211,6 @@ fn MyF() {
}
//@dump-sem-ir-end
// ============================================================================
// To inherit private
// ============================================================================
// --- to_inherit_private.h
class 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
// ============================================================================