aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--decl.c7
-rw-r--r--test/static-assert-concat.c1
-rw-r--r--test/static-assert-concat.qbe0
3 files changed, 6 insertions, 2 deletions
diff --git a/decl.c b/decl.c
index 11f7c12..cca767a 100644
--- a/decl.c
+++ b/decl.c
@@ -870,6 +870,7 @@ decl(struct scope *s, struct func *f)
int allowfunc = !f;
struct decl *d, *prior;
enum declkind kind;
+ struct expr *e;
uint64_t c;
int align;
@@ -877,9 +878,11 @@ decl(struct scope *s, struct func *f)
expect(TLPAREN, "after _Static_assert");
c = intconstexpr(s, true);
expect(TCOMMA, "after static assertion expression");
- expect(TSTRINGLIT, "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"); // XXX: add string here
+ error(&tok.loc, "static assertion failed: %.*s", (int)e->base->string.size, e->base->string.data);
expect(TRPAREN, "after static assertion message");
expect(TSEMICOLON, "after static assertion");
return true;
diff --git a/test/static-assert-concat.c b/test/static-assert-concat.c
new file mode 100644
index 0000000..7dd6f65
--- /dev/null
+++ b/test/static-assert-concat.c
@@ -0,0 +1 @@
+_Static_assert(1, "abc" "def");
diff --git a/test/static-assert-concat.qbe b/test/static-assert-concat.qbe
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/static-assert-concat.qbe