For modifiers, get the TokenKind from DeclKind instead of argument. (#4028)

This commit is contained in:
Jon Ross-Perkins
2024-06-05 16:23:36 +00:00
committed by GitHub
parent a910eda020
commit 0ffa5bf659
13 changed files with 83 additions and 78 deletions
+6 -10
View File
@@ -189,14 +189,12 @@ static auto BuildClassDecl(Context& context, Parse::AnyClassDeclId node_id,
context.name_scopes().GetInstIfValid(name_context.parent_scope_id);
auto introducer =
context.decl_introducer_state_stack().Pop(DeclIntroducerState::Class);
CheckAccessModifiersOnDecl(context, introducer, Lex::TokenKind::Class,
parent_scope_inst);
CheckAccessModifiersOnDecl(context, introducer, parent_scope_inst);
LimitModifiersOnDecl(context, introducer,
KeywordModifierSet::Class | KeywordModifierSet::Access |
KeywordModifierSet::Extern,
Lex::TokenKind::Class);
RestrictExternModifierOnDecl(context, introducer, Lex::TokenKind::Class,
parent_scope_inst, is_definition);
KeywordModifierSet::Extern);
RestrictExternModifierOnDecl(context, introducer, parent_scope_inst,
is_definition);
if (introducer.modifier_set.HasAnyOf(KeywordModifierSet::Access)) {
context.TODO(introducer.modifier_node_id(ModifierOrder::Access),
@@ -368,8 +366,7 @@ auto HandleAdaptDecl(Context& context, Parse::AdaptDeclId node_id) -> bool {
// Process modifiers. `extend` is permitted, no others are allowed.
auto introducer =
context.decl_introducer_state_stack().Pop(DeclIntroducerState::Adapt);
LimitModifiersOnDecl(context, introducer, KeywordModifierSet::Extend,
Lex::TokenKind::Adapt);
LimitModifiersOnDecl(context, introducer, KeywordModifierSet::Extend);
auto parent_class_decl =
GetCurrentScopeAsClassOrDiagnose(context, node_id, Lex::TokenKind::Adapt);
@@ -499,8 +496,7 @@ auto HandleBaseDecl(Context& context, Parse::BaseDeclId node_id) -> bool {
// Process modifiers. `extend` is required, no others are allowed.
auto introducer =
context.decl_introducer_state_stack().Pop(DeclIntroducerState::Base);
LimitModifiersOnDecl(context, introducer, KeywordModifierSet::Extend,
Lex::TokenKind::Base);
LimitModifiersOnDecl(context, introducer, KeywordModifierSet::Extend);
if (!introducer.modifier_set.HasAnyOf(KeywordModifierSet::Extend)) {
CARBON_DIAGNOSTIC(BaseMissingExtend, Error,
"Missing `extend` before `base` declaration in class.");