* gcc.dg/predict-12.c: New testcase.
[official-gcc.git] / gcc / testsuite / gcc.dg / cpp / macro3.c
blobe6a5ffc1ed40070fe43fc7cc4acec058231f895d
1 /* { dg-do run } */
2 /* { dg-options "-std=c99" } */
4 /* First two tests sourced from a bug report of Thomas Pornin.
5 Varargs test source Jamie Lokier.
6 All adapted for the testsuite by Neil Booth, Oct 2000. */
8 /* Tests various macro abuse is correctly expanded. */
9 static int d = 4;
10 #define c(x) d
11 #define d(x) c(2)
13 #if 0
14 /* This macro chain above sucks up the whole file once it starts, so
15 I've commented it out. The example is left for idle amusement :-) */
16 #define a(x) b(
17 #define b(x) a(
18 #endif
20 #define apply(...) apply2 (__VA_ARGS__)
21 #define half(x) ((x) / 2)
22 #define apply2(f,x) f (x)
24 extern void abort (void);
25 extern void exit (int);
27 int main()
29 /* Expands to c(2) then d. */
30 if (c(c)(c) != 4)
31 abort ();
33 if (apply (half, 200) != 100)
34 abort ();
36 exit (0);