aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 7b7126ca40..aa0d7ddff3 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -996,7 +996,7 @@ static PrefixOp tok_to_prefix_op(Token *token) {
/*
PrefixOpExpression : PrefixOp PrefixOpExpression | SuffixOpExpression
-PrefixOp = "!" | "-" | "~" | "*" | ("&" option("const")) | "?" | "%" | "%%" | "??" | "-%"
+PrefixOp = "!" | "-" | "~" | "*" | ("&" option("const") option("volatile")) | "?" | "%" | "%%" | "??" | "-%"
*/
static AstNode *ast_parse_prefix_op_expr(ParseContext *pc, size_t *token_index, bool mandatory) {
Token *token = &pc->tokens->at(*token_index);
@@ -1036,10 +1036,19 @@ static AstNode *ast_parse_prefix_op_expr(ParseContext *pc, size_t *token_index,
}
if (prefix_op == PrefixOpAddressOf) {
- Token *token = &pc->tokens->at(*token_index);
- if (token->id == TokenIdKeywordConst) {
+ Token *const_or_volatile_tok = &pc->tokens->at(*token_index);
+ if (const_or_volatile_tok->id == TokenIdKeywordConst) {
+ *token_index += 1;
+ Token *volatile_token = &pc->tokens->at(*token_index);
+ if (volatile_token->id == TokenIdKeywordVolatile) {
+ *token_index += 1;
+ prefix_op = PrefixOpConstVolatileAddressOf;
+ } else {
+ prefix_op = PrefixOpConstAddressOf;
+ }
+ } else if (const_or_volatile_tok->id == TokenIdKeywordVolatile) {
+ prefix_op = PrefixOpVolatileAddressOf;
*token_index += 1;
- prefix_op = PrefixOpConstAddressOf;
}
}