pretty-print.h (pp_base): Remove.
[official-gcc.git] / gcc / testsuite / gcc.dg / c11-generic-1.c
blob60ef1f0eb692d6e416caeb9adb8aadddc8d60035
1 /* Test C11 _Generic. Valid uses. */
2 /* { dg-do run } */
3 /* { dg-options "-std=c11 -pedantic-errors" } */
5 _Noreturn extern void exit (int);
6 _Noreturn extern void abort (void);
8 void
9 check (int n)
11 if (n)
12 abort ();
15 int
16 main (void)
18 int n = 0;
20 check (_Generic (n++, int: 0));
21 /* _Generic should not evaluate its argument. */
22 check (n);
24 check (_Generic (n, double: n++, default: 0));
25 check (n);
27 /* Qualifiers are removed for the purpose of type matching. */
28 const int cn = 0;
29 check (_Generic (cn, int: 0, default: n++));
30 check (n);
31 check (_Generic ((const int) n, int: 0, default: n++));
32 check (n);
34 /* Arrays decay to pointers. */
35 int a[1];
36 const int ca[1];
37 check (_Generic (a, int *: 0, const int *: n++));
38 check (n);
39 check (_Generic (ca, const int *: 0, int *: n++));
40 check (n);
42 /* Functions decay to pointers. */
43 extern void f (void);
44 check (_Generic (f, void (*) (void): 0, default: n++));
45 check (n);
47 /* _Noreturn is not part of the function type. */
48 check (_Generic (&abort, void (*) (void): 0, default: n++));
49 check (n);
51 /* Integer promotions do not occur. */
52 short s;
53 check (_Generic (s, short: 0, int: n++));
54 check (n);
56 exit (0);