diff options
author | Michael Forney <mforney@mforney.org> | 2019-08-13 17:48:27 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-08-13 17:48:27 -0700 |
commit | 515034ef3bb5651f1ab376ca5ec9d843b3ac3503 (patch) | |
tree | db7a326ded2a064ce6b27a9d90fe505327c06d90 | |
parent | a27be60802bbb0ec692c2f92b4b29b856bc55b58 (diff) |
decl: Allow _Static_assert with no message
This is accepted for C2X[0].
[0] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2265.pdf
-rw-r--r-- | decl.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -874,13 +874,16 @@ staticassert(struct scope *s) return false; expect(TLPAREN, "after _Static_assert"); c = intconstexpr(s, true); - expect(TCOMMA, "after static assertion expression"); - e = assignexpr(s); - if (!e->decayed || e->base->kind != EXPRSTRING) - error(&tok.loc, "expected string literal after static assertion expression"); - if (!c) - error(&tok.loc, "static assertion failed: %.*s", (int)e->base->string.size, e->base->string.data); - expect(TRPAREN, "after static assertion message"); + if (consume(TCOMMA)) { + e = assignexpr(s); + if (!e->decayed || e->base->kind != EXPRSTRING) + error(&tok.loc, "expected string literal after static assertion expression"); + if (!c) + error(&tok.loc, "static assertion failed: %.*s", (int)e->base->string.size, e->base->string.data); + } else if (!c) { + error(&tok.loc, "static assertion failed"); + } + expect(TRPAREN, "after static assertion"); expect(TSEMICOLON, "after static assertion"); return true; } |