mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Support declaration modifier keywords (#3412)
Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
22dff46ed2
commit
fada410559
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "toolchain/check/context.h"
|
||||
#include "toolchain/check/convert.h"
|
||||
#include "toolchain/check/modifiers.h"
|
||||
#include "toolchain/sem_ir/inst.h"
|
||||
|
||||
namespace Carbon::Check {
|
||||
@@ -12,6 +13,7 @@ auto HandleVariableIntroducer(Context& context, Parse::NodeId parse_node)
|
||||
-> bool {
|
||||
// No action, just a bracketing node.
|
||||
context.node_stack().Push(parse_node);
|
||||
context.decl_state_stack().Push(DeclState::Var, parse_node);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -74,6 +76,18 @@ auto HandleVariableDecl(Context& context, Parse::NodeId parse_node) -> bool {
|
||||
context.node_stack()
|
||||
.PopAndDiscardSoloParseNode<Parse::NodeKind::VariableIntroducer>();
|
||||
|
||||
// Process declaration modifiers.
|
||||
CheckAccessModifiersOnDecl(context, Lex::TokenKind::Var);
|
||||
LimitModifiersOnDecl(context, KeywordModifierSet::Access,
|
||||
Lex::TokenKind::Var);
|
||||
auto modifiers = context.decl_state_stack().innermost().modifier_set;
|
||||
if (!!(modifiers & KeywordModifierSet::Access)) {
|
||||
context.TODO(context.decl_state_stack().innermost().saw_access_modifier,
|
||||
"access modifier");
|
||||
}
|
||||
|
||||
context.decl_state_stack().Pop(DeclState::Var);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user