9a3933b7308f18c35345de08af33cb075f1b5346
[gcc.git] / gcc / testsuite / gcc.dg / cpp / spacing1.c
1 /* Copyright (C) 2000, 2001 Free Software Foundation, Inc. */
2
3 /* { dg-do preprocess } */
4
5 /* This tests correct spacing of macro expansion output, as well as
6 the line it falls on. This is quite subtle; it involves newlines
7 within macro arguments becoming spaces, but not if it turns out to
8 not be a macro invocation. Also, multiple macro invocations spread
9 across many lines.
10
11 Neil Booth, 1 Dec 2000, 23 Sep 2001. */
12
13 #define str(x) #x
14 #define f(x) x
15 #define glue(x, y) x ## y
16 #define EMPTY
17
18 /* The correct output is shown here. Note the spaces, and the way
19 everything after the invocation of f appears on the same line.
20
21 44 ;
22 f
23 bar
24 g "1 2" bam baz
25
26 */
27
28 glue (EMPTY 4, 4) EMPTY;
29 f
30 bar
31 f (g) str
32 (
33 1
34 2
35 ) f
36 (bam) baz
37
38 /*
39 { dg-final { if ![file exists spacing1.i] { return } } }
40 { dg-final { if \{ [grep spacing1.i " 44 ;"] != "" \} \{ } }
41 { dg-final { if \{ [grep spacing1.i "f.*bar"] == "" \} \{ } }
42 { dg-final { if \{ [grep spacing1.i "^bar"] != "" \} \{ } }
43 { dg-final { if \{ [grep spacing1.i "g \"1 2\" bam baz"] != "" \} \{ } }
44 { dg-final { return \} \} \} \} } }
45 { dg-final { fail "spacing1.c: spacing and new-line preservation" } }
46 */