Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5007,6 +5007,9 @@ TinyPtrVector<ValueDecl *> ClangRecordMemberLookup::evaluate(
if (auto cxxRecord =
dyn_cast<clang::CXXRecordDecl>(recordDecl->getClangDecl())) {
for (auto base : cxxRecord->bases()) {
if (base.getAccessSpecifier() != clang::AccessSpecifier::AS_public)
continue;

clang::QualType baseType = base.getType();
if (auto spectType = dyn_cast<clang::TemplateSpecializationType>(baseType))
baseType = spectType->desugar();
Expand Down
3 changes: 3 additions & 0 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8442,6 +8442,9 @@ void ClangImporter::Implementation::loadAllMembersOfRecordDecl(
// If this is a C++ record, look through the base classes too.
if (auto cxxRecord = dyn_cast<clang::CXXRecordDecl>(clangRecord)) {
for (auto base : cxxRecord->bases()) {
if (base.getAccessSpecifier() != clang::AccessSpecifier::AS_public)
continue;

clang::QualType baseType = base.getType();
if (auto spectType = dyn_cast<clang::TemplateSpecializationType>(baseType))
baseType = spectType->desugar();
Expand Down
6 changes: 6 additions & 0 deletions test/Interop/Cxx/class/inheritance/Inputs/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ struct DerivedFromDerived : Derived {
struct __attribute__((swift_attr("import_unsafe"))) DerivedFromNonTrivial
: NonTrivial {};

struct PrivatelyInherited : private Base {
};

struct ProtectedInherited : protected Base {
};

struct EmptyBaseClass {
const char *inBase() const __attribute__((swift_attr("import_unsafe"))) {
return "EmptyBaseClass::inBase";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,11 @@
// CHECK-NEXT: @discardableResult
// CHECK-NEXT: func inNonTrivialWithArgs(_ a: Int32, _ b: Int32) -> UnsafePointer<CChar>?
// CHECK-NEXT: }

// CHECK-NEXT: struct PrivatelyInherited {
// CHECK-NEXT: init()
// CHECK-NEXT: }

// CHECK-NEXT: struct ProtectedInherited {
// CHECK-NEXT: init()
// CHECK-NEXT: }
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import Functions

PrivatelyInherited().constInBase() // expected-error {{value of type 'PrivatelyInherited' has no member 'constInBase'}}
ProtectedInherited().constInBase() // expected-error {{value of type 'ProtectedInherited' has no member 'constInBase'}}


extension Base {
public func swiftFunc() {}
}
Expand Down