@@ -73,6 +73,8 @@ static struct token *parse_context_statement(struct token *token, struct stateme
static struct token *parse_range_statement(struct token *token, struct statement *stmt);
static struct token *parse_asm_statement(struct token *token, struct statement *stmt);
static struct token *toplevel_asm_declaration(struct token *token, struct symbol_list **list);
+static struct token *parse_static_assert_statement(struct token *token, struct statement *stmt);
+static struct token *toplevel_static_assert_declaration(struct token *token, struct symbol_list **list);
typedef struct token *attr_t(struct token *, struct symbol *,
struct decl_state *);
@@ -308,6 +310,11 @@ static struct symbol_op asm_op = {
.toplevel = toplevel_asm_declaration,
};
+static struct symbol_op static_assert_op = {
+ .statement = parse_static_assert_statement,
+ .toplevel = toplevel_static_assert_declaration,
+};
+
static struct symbol_op packed_op = {
.attribute = attribute_packed,
};
@@ -460,6 +467,8 @@ static struct init_keyword {
{ "asm", NS_KEYWORD, .op = &asm_op },
{ "__asm", NS_KEYWORD, .op = &asm_op },
{ "__asm__", NS_KEYWORD, .op = &asm_op },
+ { "static_assert", NS_KEYWORD, .op = &static_assert_op },
+ { "_Static_assert", NS_KEYWORD, .op = &static_assert_op },
/* Attribute */
{ "packed", NS_KEYWORD, .op = &packed_op },
@@ -2003,6 +2012,29 @@ static struct token *parse_asm_declarator(struct token *token, struct decl_state
return token;
}
+static struct token *parse_static_assert(struct token * token)
+{
+ struct expression *expr = NULL;
+
+ token = expect(token->next, '(', "after static assert");
+ token = conditional_expression(token, &expr);
+ token = expect(token, ',', "after constant expression of static assert");
+ token = parse_expression(token, &expr);
+ token = expect(token, ')', "after static assert");
+ return expect(token, ';', "at end of static assert");
+}
+
+static struct token *parse_static_assert_statement(struct token *token, struct statement *stmt)
+{
+ return parse_static_assert(token);
+}
+
+static struct token *toplevel_static_assert_declaration(struct token *token, struct symbol_list **list)
+{
+ return parse_static_assert(token);
+}
+
+
/* Make a statement out of an expression */
static struct statement *make_statement(struct expression *expr)
{