brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 2377724 Raw
45 lines · c
1// RUN: %clang_cc1 -Eonly -verify -pedantic %s2// pasting ""x"" and ""+"" does not give a valid preprocessing token3#define XYZ  x ## + 4XYZ   // expected-error {{pasting formed 'x+', an invalid preprocessing token}}5#define XXYZ  . ## test6XXYZ   // expected-error {{pasting formed '.test', an invalid preprocessing token}}7 8// GCC PR 200779 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}}14 15 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}}22 23// Invalid token pasting.24// PR391825 26// When pasting creates poisoned identifiers, we error.27#pragma GCC poison BLARG28BLARG  // expected-error {{attempt to use a poisoned identifier}}29#define XX BL ## ARG30XX     // expected-error {{attempt to use a poisoned identifier}}31 32#define VA __VA_ ## ARGS__33int VA;   // expected-warning {{__VA_ARGS__ can only appear in the expansion of a C99 variadic macro}}34 35#define LOG_ON_ERROR(x) x ## #y; // expected-error {{'#' is not followed by a macro parameter}}36LOG_ON_ERROR(0);37 38#define PR21379A(x) printf ##x // expected-note {{macro 'PR21379A' defined here}}39PR21379A(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}}41 42#define PR21379B(x) printf #x // expected-note {{macro 'PR21379B' defined here}}43PR21379B(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}}45