summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2019-03-08 08:54:50 +0100
committerChristoph Mallon <christoph.mallon@gmx.de>2019-03-13 21:13:13 +0100
commite25966c0bcbe137b19e4290a42a090778d10e1e5 (patch)
tree2fea63b4fc54c0413a6f27a08fdffe85613800d9
parent217ee4a08ab7c09a8666977c7e2963edc9a8776d (diff)
Accept asm qualifiers (goto, volatile) in arbitrary order, just like gcc.
-rw-r--r--NEWS.md1
-rw-r--r--src/parser/parser.c22
2 files changed, 20 insertions, 3 deletions
diff --git a/NEWS.md b/NEWS.md
index c4e81ec..ad40f80 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -17,6 +17,7 @@ cparser 1.22.1 (2016-01-23)
* Split `-Wparentheses` into `Wparentheses-assignment`, `Wparentheses-comparison`, `Wparentheses-else`, `Wparentheses-logical` and `Wparentheses-shift`
* Add target `mips`
* Add target `riscv32`
+* Accept asm qualifiers in arbitrary order
* Bugfixes
cparser 1.22.0 (2015-12-31)
diff --git a/src/parser/parser.c b/src/parser/parser.c
index e83e9d8..1e4e6b1 100644
--- a/src/parser/parser.c
+++ b/src/parser/parser.c
@@ -9335,10 +9335,26 @@ static statement_t *parse_gcc_asm_statement(void)
add_anchor_token(':');
add_anchor_token(T_STRING_LITERAL);
- if (accept(T_volatile))
- asm_statement->is_volatile = true;
+ bool asm_goto = false;
+ bool asm_volatile = false;
+ for (;; next_token()) {
+ switch (token.kind) {
+ bool* flag;
+ case T_goto: flag = &asm_goto; goto check_duplicate;
+ case T_volatile: flag = &asm_volatile; goto check_duplicate;
+check_duplicate:
+ if (*flag)
+ warningf(WARN_OTHER, HERE, "duplicate asm qualifier %K", &token);
+ *flag = true;
+ continue;
+
+ default:
+ break;
+ }
+ break;
+ }
- bool const asm_goto = accept(T_goto);
+ asm_statement->is_volatile = asm_volatile;
expect('(');
rem_anchor_token(T_STRING_LITERAL);