fix(parser): reject macro parameter lists the toolchain rejects
The C variadic spellings ("..." and the GNU "name..."), an empty or
trailing parameter, a missing comma, a stray token and an unterminated
list all parsed silently before: non-identifier tokens were skipped, so
"#define M(...)" defined a zero-parameter macro and invocations were
diagnosed only by argument count, if at all. The toolchain rejects the
definition itself ("bad definition for macro"), and so does the
preprocessor now: the parameter list must be identifiers separated by
single commas and closed by the parenthesis, and a rejected definition
leaves the name unbound. The spellings join the fuzz corpus.
Assisted-by: GLM 5.3
This commit is contained in:
1 parent
373ec51061
commit
63ed141522
3 files changed
+102
-14
No files matched your search
@@ -94,6 +94,8 @@ func FuzzParseExpand(f *testing.F) {
|
||||
f.Add("#include \"no/such/header.h\"\n")
|
||||
f.Add("#line 7 \"f.s\"\n")
|
||||
f.Add("#define M(x) \\\n\tADD $x, R0 \\\n\tSUB $x, R1\nM(1)\n") // continuations
|
||||
f.Add("#define M(...) x\nM(1)\n") // the C variadic spelling, a bad definition
|
||||
f.Add("#define M(args...) x\nM(1)\n") // the GNU variadic spelling, one dotted name
|
||||
// A body that repeats its argument multiplies every nesting level; the
|
||||
// expansion must stop at the work budget, not produce the exponential
|
||||
// result it names.
|
||||
|
||||
Reference in new issue
Block a user