diff options
author | Michael Forney <mforney@mforney.org> | 2021-09-13 18:37:41 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2021-09-13 18:37:41 -0700 |
commit | 0e9e97e37571c913864cc4d8d986fa9fda964e8a (patch) | |
tree | 7283c0dab3d675a3662dd8df4ea7b35ebd61d8b2 /decl.c | |
parent | 38d906288b70102cf869a9cbb433ddc1fbf23efb (diff) |
Revert "Add stringconcat function to concatenate adjacent string literals"
This reverts commit c16f07acf655b9f4fb006d8256b4027fb5a13aa8.
This incorrectly allows octal escapes to span between adjacent
string literals (e.g. "\0" "1" is not the same as "\01").
Diffstat (limited to 'decl.c')
-rw-r--r-- | decl.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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"); } |