mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 14:51:03 +01:00
Add namespace-scoped private keyword support. (#4026)
Adds access to the name lookup table in name scopes. This is so that we can quickly check access during name lookup without resolving the entity itself. Does this for names in general, but does not implement handling for entity-scoped names, only namespace-scoped names (where they're essentially just not exported). Excludes `private` names from exports. Although names should be accessible to `impl` files, that's not implemented here because we'll probably want to do it by directly copying name lookup tables.
This commit is contained in:
@@ -228,10 +228,6 @@ static auto BuildFunctionDecl(Context& context,
|
||||
context.decl_introducer_state_stack().Pop<Lex::TokenKind::Fn>();
|
||||
DiagnoseModifiers(context, introducer, is_definition, parent_scope_inst_id,
|
||||
parent_scope_inst);
|
||||
if (introducer.modifier_set.HasAnyOf(KeywordModifierSet::Access)) {
|
||||
context.TODO(introducer.modifier_node_id(ModifierOrder::Access),
|
||||
"access modifier");
|
||||
}
|
||||
bool is_extern = introducer.modifier_set.HasAnyOf(KeywordModifierSet::Extern);
|
||||
if (introducer.modifier_set.HasAnyOf(KeywordModifierSet::Method)) {
|
||||
context.TODO(introducer.modifier_node_id(ModifierOrder::Decl),
|
||||
@@ -268,6 +264,8 @@ static auto BuildFunctionDecl(Context& context,
|
||||
// Create a new function if this isn't a valid redeclaration.
|
||||
if (!function_decl.function_id.is_valid()) {
|
||||
function_decl.function_id = context.functions().Add(function_info);
|
||||
} else {
|
||||
// TODO: Validate that the redeclaration doesn't set an access modifier.
|
||||
}
|
||||
function_decl.type_id = context.GetFunctionType(function_decl.function_id);
|
||||
|
||||
@@ -288,7 +286,8 @@ static auto BuildFunctionDecl(Context& context,
|
||||
}
|
||||
}
|
||||
|
||||
context.decl_name_stack().AddName(name_context, lookup_result_id);
|
||||
context.decl_name_stack().AddName(name_context, lookup_result_id,
|
||||
introducer.modifier_set.GetAccessKind());
|
||||
}
|
||||
|
||||
if (SemIR::IsEntryPoint(context.sem_ir(), function_decl.function_id)) {
|
||||
|
||||
Reference in New Issue
Block a user