[PATCH 07/18] string: use string_expression() in parse_static_assert()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 parse.c                    | 9 ++-------
 validation/static_assert.c | 6 +++---
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/parse.c b/parse.c
index 795434322..401f91a1f 100644
--- a/parse.c
+++ b/parse.c
@@ -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 d9e96294f..dd5e0c08c 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
  */
-- 
2.23.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux