diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-01-26 16:37:11 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-09-26 18:11:32 +0200 |
commit | d765800ade9ccb195c1b45033573dcaeec4e3f46 (patch) | |
tree | 9902db794d74fd670422f1259272f80412988d93 | |
parent | ddebbc1dff5701d2c97562de0f91e51cd5544382 (diff) | |
download | sparse-d765800ade9ccb195c1b45033573dcaeec4e3f46.tar.gz |
string: use string_expression() in parse_static_assert()
The error handling during the parsing of _Static_assert()'s
message string is relatively complex.
Simplify this by using the new helper string_expression().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | parse.c | 9 | ||||
-rw-r--r-- | validation/static_assert.c | 6 |
2 files changed, 5 insertions, 10 deletions
@@ -2132,14 +2132,9 @@ static struct token *parse_static_assert(struct token *token, struct symbol_list if (!cond) sparse_error(token->pos, "Expected constant expression"); token = expect(token, ',', "after conditional expression in _Static_assert"); - token = parse_expression(token, &message); - if (!message || message->type != EXPR_STRING) { - struct position pos; - - pos = message ? message->pos : token->pos; - sparse_error(pos, "bad or missing string literal"); + token = string_expression(token, &message, "_Static_assert()"); + if (!message) cond = NULL; - } token = expect(token, ')', "after diagnostic message in _Static_assert"); token = expect(token, ';', "after _Static_assert()"); diff --git a/validation/static_assert.c b/validation/static_assert.c index d9e96294..dd5e0c08 100644 --- a/validation/static_assert.c +++ b/validation/static_assert.c @@ -61,11 +61,11 @@ static_assert.c:19:16: error: static assertion failed: "expected assertion failu static_assert.c:22:16: error: bad constant expression static_assert.c:25:16: error: bad constant expression static_assert.c:27:16: error: bad constant expression -static_assert.c:35:19: error: bad or missing string literal +static_assert.c:35:19: error: string literal expected for _Static_assert() static_assert.c:37:18: error: bad constant expression -static_assert.c:52:19: error: bad or missing string literal +static_assert.c:52:19: error: string literal expected for _Static_assert() static_assert.c:53:16: error: Expected constant expression static_assert.c:54:16: error: Expected constant expression -static_assert.c:54:17: error: bad or missing string literal +static_assert.c:54:17: error: string literal expected for _Static_assert() * check-error-end */ |