OSDN Git Service

* cppmacro.c (funlike_invocation_p): Move some logic to caller
[pf3gnuchains/gcc-fork.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 /* These are based on PR 4492, we mustn't lose padding tokens when
18    scanning ahead for a '(' and failing to find it.  */
19 #define A(x) B x
20 #define B(x)
21 #define C A
22 #define D() A
23
24 /* The correct output is shown here.  Note the spaces, and the way
25    everything after the invocation of f appears on the same line.
26
27  44 ;
28 B Q B Q A Q A:
29 f
30 bar
31 g "1 2" bam baz
32
33 */
34
35 glue (EMPTY 4, 4) EMPTY;
36 A(Q) C(Q) D()Q D():
37 f
38 bar
39 f (g) str
40 (
41 1
42 2
43 ) f
44 (bam) baz
45
46 /*
47    { dg-final { if ![file exists spacing1.i] { return }                   } }
48    { dg-final { if \{ [grep spacing1.i " 44 ;"] != "" \}              \{  } }
49    { dg-final { if \{ [grep spacing1.i "B Q B Q A Q A:"] != "" \}     \{  } }
50    { dg-final { if \{ [grep spacing1.i "f.*bar"] == "" \} \{              } }
51    { dg-final { if \{ [grep spacing1.i "^bar"] != "" \}   \{              } }
52    { dg-final { if \{ [grep spacing1.i "g \"1 2\" bam baz"] != "" \} \{   } }
53    { dg-final { return \} \} \} \} \}                                     } }
54    { dg-final { fail "spacing1.c: spacing and new-line preservation"      } }
55 */