mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 17:52:58 +01:00
Fix diagnostic for access of protected/private base member. (#5874)
When importing the member, import the access level for the lookup result, not the declared access of the member declaration.
This commit is contained in:
@@ -1407,14 +1407,15 @@ static auto MapAccess(clang::AccessSpecifier access_specifier)
|
||||
static auto ImportNameDeclIntoScope(Context& context, SemIR::LocId loc_id,
|
||||
SemIR::NameScopeId scope_id,
|
||||
SemIR::NameId name_id,
|
||||
clang::NamedDecl* clang_decl)
|
||||
clang::NamedDecl* clang_decl,
|
||||
clang::AccessSpecifier access)
|
||||
-> SemIR::ScopeLookupResult {
|
||||
SemIR::InstId inst_id =
|
||||
ImportDeclAndDependencies(context, loc_id, clang_decl);
|
||||
if (!inst_id.has_value()) {
|
||||
return SemIR::ScopeLookupResult::MakeNotFound();
|
||||
}
|
||||
SemIR::AccessKind access_kind = MapAccess(clang_decl->getAccess());
|
||||
SemIR::AccessKind access_kind = MapAccess(access);
|
||||
AddNameToScope(context, scope_id, name_id, access_kind, inst_id);
|
||||
return SemIR::ScopeLookupResult::MakeWrappedLookupResult(inst_id,
|
||||
access_kind);
|
||||
@@ -1447,7 +1448,8 @@ auto ImportNameFromCpp(Context& context, SemIR::LocId loc_id,
|
||||
}
|
||||
|
||||
return ImportNameDeclIntoScope(context, loc_id, scope_id, name_id,
|
||||
lookup->getFoundDecl());
|
||||
lookup->getFoundDecl(),
|
||||
lookup->begin().getAccess());
|
||||
}
|
||||
|
||||
} // namespace Carbon::Check
|
||||
|
||||
Reference in New Issue
Block a user