aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/parse.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-04-03 17:07:15 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-11-08 21:42:55 +0100
commitffe9f9fef003d29b65d29b8da5416aff72baff5a (patch)
tree5d73f752a98a796a252b0bf920965d159782221f /parse.c
parent35db0f18f8153592ec8ed6ea0fa3650c2d3efded (diff)
downloadsparse-dev-ffe9f9fef003d29b65d29b8da5416aff72baff5a.tar.gz
add support for C11's _Atomic as type qualifier
This only add the parsing and checks as a type qualifier; there is no operational semantic associated with it. Note: this only support _Atomic as *type qualifier*, not as a *type specifier* (partly because there an ambiguity on how to parse '_Atomic' when followed by an open parenthesis (can be valid as qualifier and as specifier)). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/parse.c b/parse.c
index e6b40fc3..ab2e17da 100644
--- a/parse.c
+++ b/parse.c
@@ -59,6 +59,7 @@ static declarator_t
register_specifier, static_specifier, extern_specifier,
thread_specifier, const_qualifier, volatile_qualifier;
static declarator_t restrict_qualifier;
+static declarator_t atomic_qualifier;
static struct token *parse_if_statement(struct token *token, struct statement *stmt);
static struct token *parse_return_statement(struct token *token, struct statement *stmt);
@@ -178,6 +179,11 @@ static struct symbol_op restrict_op = {
.declarator = restrict_qualifier,
};
+static struct symbol_op atomic_op = {
+ .type = KW_QUALIFIER,
+ .declarator = atomic_qualifier,
+};
+
static struct symbol_op typeof_op = {
.type = KW_SPECIFIER,
.declarator = typeof_specifier,
@@ -427,6 +433,7 @@ static struct init_keyword {
{ "restrict", NS_TYPEDEF, .op = &restrict_op},
{ "__restrict", NS_TYPEDEF, .op = &restrict_op},
{ "__restrict__", NS_TYPEDEF, .op = &restrict_op},
+ { "_Atomic", NS_TYPEDEF, .op = &atomic_op},
/* Typedef.. */
{ "typedef", NS_TYPEDEF, .op = &typedef_op },
@@ -1473,6 +1480,12 @@ static struct token *restrict_qualifier(struct token *next, struct decl_state *c
return next;
}
+static struct token *atomic_qualifier(struct token *next, struct decl_state *ctx)
+{
+ apply_qualifier(&next->pos, &ctx->ctype, MOD_ATOMIC);
+ return next;
+}
+
static void apply_ctype(struct position pos, struct ctype *thistype, struct ctype *ctype)
{
unsigned long mod = thistype->modifiers;