[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
muscles: fix handling of the "@'" escape
From: |
Akim Demaille |
Subject: |
muscles: fix handling of the "@'" escape |
Date: |
Sun, 4 Sep 2022 08:58:58 +0200 |
Another reachable assertion uncovered by fuzzing.
commit 637636412037d1fc2079f81260b19de5d0dab199
Author: Akim Demaille <akim.demaille@gmail.com>
Date: Sun Sep 4 08:34:11 2022 +0200
muscles: fix handling of the "@'" escape
When we use `b4_` or `m4_` somewhere in the input, it is escaped as
`b4@'_`/`m4@'_` so that the warning about unexpanded b4_foo/m4_foo
macros does not fire.
But in the case of muscles, the `@'` escape was not recognized, and an
assertion was triggered.
Reported by Han Zheng.
<https://github.com/akimd/bison/issues/91>
* src/muscle-tab.c (COMMON_DECODE): Handle `@'`.
* tests/skeletons.at (Suspicious sequences): Check that case.
diff --git a/src/muscle-tab.c b/src/muscle-tab.c
index 43911d3e..0945d609 100644
--- a/src/muscle-tab.c
+++ b/src/muscle-tab.c
@@ -294,10 +294,11 @@ muscle_location_grow (char const *key, location loc)
case '@': \
switch (*++(Value)) \
{ \
+ case '\'': /* Ignore "@'" */ break; \
case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
default: aver (false); break; \
} \
break; \
default: \
diff --git a/tests/skeletons.at b/tests/skeletons.at
index e1b86514..13f796b5 100644
--- a/tests/skeletons.at
+++ b/tests/skeletons.at
@@ -369,5 +369,20 @@ AT_SETUP([[Suspicious sequences]])
input1.tab.c:13: warning: suspicious sequence in the output: m4@&t@_poison
[-Wother]
]])
+# Regression test for <https://github.com/akimd/bison/issues/91>.
+AT_DATA([[input2.y]],
+[[%define parse.trace {m4@&t@_foo}
+%debug
+%%
+exp:
+]])
+
+AT_BISON_CHECK([[input2.y]], [1], [],
+[[input2.y:1.1-28: warning: %define variable 'parse.trace' requires keyword
values [-Wdeprecated]
+input2.y:1.1-28: error: invalid value for %define Boolean variable
'parse.trace'
+input2.y:2.1-6: error: %define variable 'parse.trace' redefined
+input2.y:1.1-28: note: previous definition
+input2.y: warning: fix-its can be applied. Rerun with option '--update'.
[-Wother]
+]])
AT_CLEANUP
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- muscles: fix handling of the "@'" escape,
Akim Demaille <=