Move 'export name' out of the import section. (#3950)

This implements recent updates to #3938
This commit is contained in:
Jon Ross-Perkins
2024-05-17 18:26:14 +00:00
committed by GitHub
parent 40b2217421
commit ecb300ee5e
12 changed files with 208 additions and 74 deletions
+6
View File
@@ -4,6 +4,7 @@
#include "toolchain/check/context.h"
#include "toolchain/check/decl_name_stack.h"
#include "toolchain/check/modifiers.h"
#include "toolchain/parse/typed_nodes.h"
#include "toolchain/sem_ir/ids.h"
#include "toolchain/sem_ir/typed_insts.h"
@@ -12,6 +13,7 @@ namespace Carbon::Check {
auto HandleExportIntroducer(Context& context,
Parse::ExportIntroducerId /*node_id*/) -> bool {
context.decl_state_stack().Push(DeclState::Export);
// TODO: Probably need to update DeclNameStack to restrict to only namespaces.
context.decl_name_stack().PushScopeAndStartName();
return true;
@@ -22,6 +24,10 @@ auto HandleExportDirective(Context& context, Parse::ExportDirectiveId node_id)
auto name_context = context.decl_name_stack().FinishName();
context.decl_name_stack().PopScope();
LimitModifiersOnDecl(context, KeywordModifierSet::None,
Lex::TokenKind::Export);
context.decl_state_stack().Pop(DeclState::Export);
if (name_context.state == DeclNameStack::NameContext::State::Error) {
// Should already be diagnosed.
return true;