1 // RUN: %clang_cc1 -Eonly -verify -pedantic %s
2 // pasting ""x"" and ""+"" does not give a valid preprocessing token
4 XYZ
// expected-error {{pasting formed 'x+', an invalid preprocessing token}}
6 XXYZ
// expected-error {{pasting formed '.test', an invalid preprocessing token}}
10 #define a a ## ## // expected-error {{'##' cannot appear at end of macro expansion}}
11 #define b() b ## ## // expected-error {{'##' cannot appear at end of macro expansion}}
12 #define c c ## // expected-error {{'##' cannot appear at end of macro expansion}}
13 #define d() d ## // expected-error {{'##' cannot appear at end of macro expansion}}
16 #define e ## ## e // expected-error {{'##' cannot appear at start of macro expansion}}
17 #define f() ## ## f // expected-error {{'##' cannot appear at start of macro expansion}}
18 #define g ## g // expected-error {{'##' cannot appear at start of macro expansion}}
19 #define h() ## h // expected-error {{'##' cannot appear at start of macro expansion}}
20 #define i ## // expected-error {{'##' cannot appear at start of macro expansion}}
21 #define j() ## // expected-error {{'##' cannot appear at start of macro expansion}}
23 // Invalid token pasting.
26 // When pasting creates poisoned identifiers, we error.
27 #pragma GCC poison BLARG
28 BLARG
// expected-error {{attempt to use a poisoned identifier}}
30 XX
// expected-error {{attempt to use a poisoned identifier}}
32 #define VA __VA_ ## ARGS__
33 int VA
; // expected-warning {{__VA_ARGS__ can only appear in the expansion of a C99 variadic macro}}
35 #define LOG_ON_ERROR(x) x ## #y; // expected-error {{'#' is not followed by a macro parameter}}
38 #define PR21379A(x) printf ##x // expected-note {{macro 'PR21379A' defined here}}
39 PR21379A(0 {, }) // expected-error {{too many arguments provided to function-like macro invocation}}
40 // expected-note@-1 {{parentheses are required around macro argument containing braced initializer list}}
42 #define PR21379B(x) printf #x // expected-note {{macro 'PR21379B' defined here}}
43 PR21379B(0 {, }) // expected-error {{too many arguments provided to function-like macro invocation}}
44 // expected-note@-1 {{parentheses are required around macro argument containing braced initializer list}}