llvm-capstone/clang/test/Preprocessor/macro_paste_empty.c
Argyrios Kyrtzidis 977026c5f5 [Preprocessor] Prevent expansion of y in x ## y when x is empty
When x is empty, x ## is suppressed, and when y gets expanded, the fact that it follows ## is not
available in the macro expansion result. The macro definition can be checked instead, the ## will
be available there regardless of what x expands to.

Fixes http://llvm.org/PR12767

Patch by Harald van Dijk!

llvm-svn: 182699
2013-05-25 01:35:18 +00:00

18 lines
281 B
C

// RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
#define FOO(X) X ## Y
a:FOO()
// CHECK: a:Y
#define FOO2(X) Y ## X
b:FOO2()
// CHECK: b:Y
#define FOO3(X) X ## Y ## X ## Y ## X ## X
c:FOO3()
// CHECK: c:YY
#define FOO4(X, Y) X ## Y
d:FOO4(,FOO4(,))
// CHECK: d:FOO4