diff options
author | Michael Forney <mforney@mforney.org> | 2021-06-28 20:31:11 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2021-06-28 20:31:11 -0700 |
commit | c16f07acf655b9f4fb006d8256b4027fb5a13aa8 (patch) | |
tree | 7b272c7a4db339ba87e4a2cd20c455e582eb05b0 /decl.c | |
parent | fb10b3671f41a3e09837fd07b90da9c25a1bbf57 (diff) |
Add stringconcat function to concatenate adjacent string literals
This function also ensures that the string prefixes (if any) are
compatible. It should make it easier to implement wide string
support.
Diffstat (limited to 'decl.c')
-rw-r--r-- | decl.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -753,19 +753,18 @@ 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)) { - e = assignexpr(s); - if (!e->decayed || e->base->kind != EXPRSTRING) - error(&tok.loc, "expected string literal after static assertion expression"); + tokencheck(&tok, TSTRINGLIT, "after static assertion expression"); + msg = stringconcat(); if (!c) - error(&tok.loc, "static assertion failed: %.*s", (int)e->base->string.size, e->base->string.data); + error(&tok.loc, "static assertion failed: %s", msg + (*msg != '"')); } else if (!c) { error(&tok.loc, "static assertion failed"); } |