aboutsummaryrefslogtreecommitdiff
path: root/decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'decl.c')
-rw-r--r--decl.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/decl.c b/decl.c
index 3aa720a..2483a47 100644
--- a/decl.c
+++ b/decl.c
@@ -748,18 +748,19 @@ addmember(struct structbuilder *b, struct qualtype mt, char *name, int align, ui
static bool
staticassert(struct scope *s)
{
+ struct expr *e;
uint64_t c;
- char *msg;
if (!consume(T_STATIC_ASSERT))
return false;
expect(TLPAREN, "after _Static_assert");
c = intconstexpr(s, true);
if (consume(TCOMMA)) {
- tokencheck(&tok, TSTRINGLIT, "after static assertion expression");
- msg = stringconcat();
+ 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", msg + (*msg != '"'));
+ 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");
}