windelbouwman / ppci

A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python
https://ppci.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
337 stars 36 forks source link

ppci-cc: error when one argument of ## is empty #99

Open tstreiff opened 4 years ago

tstreiff commented 4 years ago

I suspect this one is derived from closed #52

define M(a, b) . a ## b ;

// should expand in '. name ;' M(, name) 2:#define M(a, b) . a ## b ; ^ Invalidly glued ".name"

// should expand in '. name ;' M(name,) 6:// should expand as '. name ;' ^ Invalidly glued "name;"

In both cases, the preprocessor does not mark that there is an empty token in the token sequence. When processing ##, it wrongly takes the nearest token (on the left in the 1st case, on the right in the 2nd case) and this raises an error because the token concatenation produces an invalid new token.

(this makes fail test 00202 of the C test suite)