diff options
Diffstat (limited to 'gcc/testsuite/c-c++-common/cpp')
-rw-r--r-- | gcc/testsuite/c-c++-common/cpp/va-opt-5.c | 67 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/cpp/va-opt-6.c | 17 |
2 files changed, 84 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/cpp/va-opt-5.c b/gcc/testsuite/c-c++-common/cpp/va-opt-5.c new file mode 100644 index 0000000..b687ced --- /dev/null +++ b/gcc/testsuite/c-c++-common/cpp/va-opt-5.c @@ -0,0 +1,67 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" { target c } } */ +/* { dg-options "-std=c++20" { target c++ } } */ + +#define lparen ( +#define a0 fooa0 +#define a1 fooa1 a0 +#define a2 fooa2 a1 +#define a3 fooa3 a2 +#define a() b lparen ) +#define b() c lparen ) +#define c() d lparen ) +#define g h +#define i(j) j +#define f(...) #__VA_OPT__(g i(0)) +#define k(x,...) # __VA_OPT__(x) #x #__VA_OPT__(__VA_ARGS__) +#define l(x,...) #__VA_OPT__(a1 x) +#define m(x,...) "a()" #__VA_OPT__(a3 __VA_ARGS__ x ## __VA_ARGS__ ## x ## c a3) "a()" +#define n(x,...) = #__VA_OPT__(a3 __VA_ARGS__ x ## __VA_ARGS__ ## x ## c a3) #x #__VA_OPT__(a0 __VA_ARGS__ x ## __VA_ARGS__ ## x ## c a0) ; +#define o(x, ...) #__VA_OPT__(x##x x##x) +#define p(x, ...) #__VA_OPT__(_Pragma ("foobar")) +#define q(...) #__VA_OPT__(/* foo */x/* bar */) +const char *v1 = f(); +const char *v2 = f(123); +const char *v3 = k(1); +const char *v4 = k(1, 2, 3 ); +const char *v5 = l(a()); +const char *v6 = l(a1 a(), 1); +const char *v7 = m(); +const char *v8 = m(,); +const char *v9 = m(,a3); +const char *v10 = m(a3,a(),a0); +const char *v11 n() +const char *v12 n(,) +const char *v13 n(,a0) +const char *v14 n(a0, a(),a0) +const char *v15 = o(, 0); +const char *v16 = p(0); +const char *v17 = p(0, 1); +const char *v18 = q(); +const char *v19 = q(1); + +int +main () +{ + if (__builtin_strcmp (v1, "") + || __builtin_strcmp (v2, "g i(0)") + || __builtin_strcmp (v3, "1") + || __builtin_strcmp (v4, "112, 3") + || __builtin_strcmp (v5, "") + || __builtin_strcmp (v6, "a1 fooa1 fooa0 b ( )") + || __builtin_strcmp (v7, "a()a()") + || __builtin_strcmp (v8, "a()a()") + || __builtin_strcmp (v9, "a()a3 fooa3 fooa2 fooa1 fooa0 a3c a3a()") + || __builtin_strcmp (v10, "a()a3 b ( ),fooa0 a3a(),a0a3c a3a()") + || __builtin_strcmp (v11, "") + || __builtin_strcmp (v12, "") + || __builtin_strcmp (v13, "a3 fooa0 a0c a3a0 fooa0 a0c a0") + || __builtin_strcmp (v14, "a3 b ( ),fooa0 a0a(),a0a0c a3a0a0 b ( ),fooa0 a0a(),a0a0c a0") + || __builtin_strcmp (v15, "") + || __builtin_strcmp (v16, "") + || __builtin_strcmp (v17, "_Pragma (\"foobar\")") + || __builtin_strcmp (v18, "") + || __builtin_strcmp (v19, "x")) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/c-c++-common/cpp/va-opt-6.c b/gcc/testsuite/c-c++-common/cpp/va-opt-6.c new file mode 100644 index 0000000..8a7761b --- /dev/null +++ b/gcc/testsuite/c-c++-common/cpp/va-opt-6.c @@ -0,0 +1,17 @@ +/* { dg-do preprocess } */ +/* { dg-options "-std=gnu99" { target c } } */ +/* { dg-options "-std=c++20" { target c++ } } */ + +#define a "" +#define b(...) a ## #__VA_OPT__(1) /* { dg-error "pasting \"a\" and \"\"\"\" does not give a valid preprocessing token" } */ +#define c(...) a ## #__VA_OPT__(1) /* { dg-error "pasting \"a\" and \"\"1\"\" does not give a valid preprocessing token" } */ +#define d(...) #__VA_OPT__(1) ## ! +#define e(...) #__VA_OPT__(1) ## ! +#define f(...) #__VA_OPT__(. ## !) +#define g(...) #__VA_OPT__(. ## !) +b() +c(1) +d( ) /* { dg-error "pasting \"\"\"\" and \"!\" does not give a valid preprocessing token" } */ +e( 1 ) /* { dg-error "pasting \"\"1\"\" and \"!\" does not give a valid preprocessing token" } */ +f() +g(0) /* { dg-error "pasting \".\" and \"!\" does not give a valid preprocessing token" } */ |