summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2019-03-26 22:31:04 +0100
committerChristoph Mallon <christoph.mallon@gmx.de>2019-03-27 06:38:24 +0100
commitb1763a764fdd6bbee339527ed9ee0dd487b5bd72 (patch)
tree39feb96181a0cb1442eb6ac0ced9829744c350c1
parenta7f87a84216f448a202ee367741f089763a23447 (diff)
Correctly detect named asm operands in the template.
[...] could be misidentified as named asm operand, even when it is not, e.g. "%%[foo]". This fixes C/gnu99/asm_no_name.c.
-rw-r--r--src/adt/util.h5
-rw-r--r--src/parser/parser.c8
2 files changed, 12 insertions, 1 deletions
diff --git a/src/adt/util.h b/src/adt/util.h
index 3900fc0..0e0f313 100644
--- a/src/adt/util.h
+++ b/src/adt/util.h
@@ -57,6 +57,11 @@
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
+static inline bool is_alpha(char const c)
+{
+ return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z');
+}
+
static inline bool is_digit(char const c)
{
return '0' <= c && c <= '9';
diff --git a/src/parser/parser.c b/src/parser/parser.c
index 9d936ec..7e01351 100644
--- a/src/parser/parser.c
+++ b/src/parser/parser.c
@@ -9274,8 +9274,14 @@ static void normalize_asm_text(asm_statement_t *asm_statement)
if (*c++ != '%')
continue;
+ if (*c == '%') {
+ /* Skip '%%'. */
+ obstack_1grow(&string_obst, *c++);
+ continue;
+ }
+
/* scan forward to see if we can find a [] */
- while (*c != '\0' && *c != '%' && *c != '[' && !is_digit(*c)) {
+ while (is_alpha(*c)) {
obstack_1grow(&string_obst, *c++);
}