remove volatileStore builtin; add volatile pointers

closes #238
This commit is contained in:
Andrew Kelley
2017-02-04 21:49:27 -05:00
parent 0d7abc6368
commit 419e75eb23
10 changed files with 219 additions and 178 deletions

View File

@@ -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;
}
}