From 419e75eb2313b4910921185211201317cbbb400c Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 4 Feb 2017 21:49:27 -0500 Subject: remove volatileStore builtin; add volatile pointers closes #238 --- src/parser.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/parser.cpp') 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; } } -- cgit v1.2.3