cparser icon indicating copy to clipboard operation
cparser copied to clipboard

Incorrect double-expansion of renamed macro

Open ludocode opened this issue 5 years ago • 0 comments

#define foo(x) x
#define bar foo

int main(void) {
    return bar(bar(0));
}

This fails under cparser 8ec1a761bf62be1028632e5eceda425d9fbeb039 with warning "implicit declaration of function 'foo'" and linker error "undefined reference to `foo'".

It compiles correctly under GCC 10.2.0, Clang 10.0.1, MSVC 19.27.29111 and TinyCC 0.9.27. It also compiles correctly with cparser if you replace #define bar foo with #define bar(x) foo(x).

ludocode avatar Sep 25 '20 04:09 ludocode