2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / cpp / macro6.c
blob0fe52ee43f20117b13081b6a1c329062c965cf3e
1 /* { dg-do run } */
3 /* Test that, when a macro expansion spills into the source file, we
4 expand macros we suck in from there, as the standard clearly states
5 they are not nested.
7 Submitter: Neil Booth, with minor modifications to the originals. 3
8 Dec 2000.
9 Source: PR 962 and Thomas Pornin. */
11 extern void abort (void);
12 int e = 10, f = 100;
14 #define e(n) 4 + n
15 #define X e
16 #define f(x) x
17 #define h(x) x + f
19 int
20 main ()
22 if (X(X) != 14) /* Should expand to "4 + e". */
23 abort ();
25 if (X(X(f)) != 108) /* Should expand to "4 + 4 + f". */
26 abort ();
28 if (h(e)(h(e)) != 120) /* Should expand to "e + e + f". */
29 abort ();
31 return 0;