From 5a0101856b66bdeb542ad8ead5173fbafa81cfab Mon Sep 17 00:00:00 2001 From: matthias Date: Sun, 28 Apr 2019 01:07:01 +0200 Subject: [PATCH] add C11 _Static_assert support --- tccgen.c | 13 +++++++++++++ tcctok.h | 1 + 2 files changed, 14 insertions(+) diff --git a/tccgen.c b/tccgen.c index 2c411b6..ebb4f7f 100644 --- a/tccgen.c +++ b/tccgen.c @@ -7445,6 +7445,19 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym) AttributeDef ad, adbase; while (1) { + if (tok == TOK_STATIC_ASSERT) { + int c; + + next(); + skip('('); + c = expr_const(); + skip(','); + if (c == 0) + tcc_error("%s", get_tok_str(tok, &tokc)); + next(); + skip(')'); + continue; + } if (!parse_btype(&btype, &adbase)) { if (is_for_loop_init) return 0; diff --git a/tcctok.h b/tcctok.h index a3befd6..5ab235f 100644 --- a/tcctok.h +++ b/tcctok.h @@ -38,6 +38,7 @@ DEF(TOK_EXTENSION, "__extension__") /* gcc keyword */ DEF(TOK_GENERIC, "_Generic") + DEF(TOK_STATIC_ASSERT, "_Static_assert") DEF(TOK_FLOAT, "float") DEF(TOK_DOUBLE, "double")