File tree Expand file tree Collapse file tree 5 files changed +24
-0
lines changed
test/Interop/Cxx/class/inheritance Expand file tree Collapse file tree 5 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -5017,6 +5017,9 @@ TinyPtrVector<ValueDecl *> ClangRecordMemberLookup::evaluate(
5017
5017
if (auto cxxRecord =
5018
5018
dyn_cast<clang::CXXRecordDecl>(recordDecl->getClangDecl ())) {
5019
5019
for (auto base : cxxRecord->bases ()) {
5020
+ if (base.getAccessSpecifier () != clang::AccessSpecifier::AS_public)
5021
+ continue ;
5022
+
5020
5023
clang::QualType baseType = base.getType ();
5021
5024
if (auto spectType = dyn_cast<clang::TemplateSpecializationType>(baseType))
5022
5025
baseType = spectType->desugar ();
Original file line number Diff line number Diff line change @@ -8442,6 +8442,9 @@ void ClangImporter::Implementation::loadAllMembersOfRecordDecl(
8442
8442
// If this is a C++ record, look through the base classes too.
8443
8443
if (auto cxxRecord = dyn_cast<clang::CXXRecordDecl>(clangRecord)) {
8444
8444
for (auto base : cxxRecord->bases ()) {
8445
+ if (base.getAccessSpecifier () != clang::AccessSpecifier::AS_public)
8446
+ continue ;
8447
+
8445
8448
clang::QualType baseType = base.getType ();
8446
8449
if (auto spectType = dyn_cast<clang::TemplateSpecializationType>(baseType))
8447
8450
baseType = spectType->desugar ();
Original file line number Diff line number Diff line change @@ -77,6 +77,12 @@ struct DerivedFromDerived : Derived {
77
77
struct __attribute__ ((swift_attr(" import_unsafe" ))) DerivedFromNonTrivial
78
78
: NonTrivial {};
79
79
80
+ struct PrivatelyInherited : private Base {
81
+ };
82
+
83
+ struct ProtectedInherited : protected Base {
84
+ };
85
+
80
86
struct EmptyBaseClass {
81
87
const char *inBase () const __attribute__((swift_attr(" import_unsafe" ))) {
82
88
return " EmptyBaseClass::inBase" ;
Original file line number Diff line number Diff line change 92
92
// CHECK-NEXT: @discardableResult
93
93
// CHECK-NEXT: func inNonTrivialWithArgs(_ a: Int32, _ b: Int32) -> UnsafePointer<CChar>?
94
94
// CHECK-NEXT: }
95
+
96
+ // CHECK-NEXT: struct PrivatelyInherited {
97
+ // CHECK-NEXT: init()
98
+ // CHECK-NEXT: }
99
+
100
+ // CHECK-NEXT: struct ProtectedInherited {
101
+ // CHECK-NEXT: init()
102
+ // CHECK-NEXT: }
Original file line number Diff line number Diff line change 2
2
3
3
import Functions
4
4
5
+ PrivatelyInherited ( ) . constInBase ( ) // expected-error {{value of type 'PrivatelyInherited' has no member 'constInBase'}}
6
+ ProtectedInherited ( ) . constInBase ( ) // expected-error {{value of type 'ProtectedInherited' has no member 'constInBase'}}
7
+
8
+
5
9
extension Base {
6
10
public func swiftFunc( ) { }
7
11
}
You can’t perform that action at this time.
0 commit comments