summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/cpp/spacing1.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/cpp/spacing1.c
downloadcbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.bz2
cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/cpp/spacing1.c')
-rw-r--r--gcc/testsuite/gcc.dg/cpp/spacing1.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/cpp/spacing1.c b/gcc/testsuite/gcc.dg/cpp/spacing1.c
new file mode 100644
index 000000000..c21a6b515
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/spacing1.c
@@ -0,0 +1,66 @@
+/* Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+/* { dg-options "-P" } */
+
+/* This tests correct spacing of macro expansion output, as well as
+ the line it falls on. This is quite subtle; it involves newlines
+ within macro arguments becoming spaces, but not if it turns out to
+ not be a macro invocation. Also, multiple macro invocations spread
+ across many lines.
+
+ Neil Booth, 1 Dec 2000, 23 Sep 2001. */
+
+/* The actual location of the expansion of a multi-line macro
+ invocation is not defined: we might consider them to be in the same
+ line as the initial token of the invocation, or as the final token
+ of the invocation, or even anything in between. We choose to make
+ it the initial token, such that everything that is in a logical
+ line ends up in a single line after preprocessing.
+
+ Alexandre Oliva, Sept 13, 2003. */
+
+#define str(x) #x
+#define f(x) x
+#define glue(x, y) x ## y
+#define EMPTY
+/* These are based on PR 4492, we mustn't lose padding tokens when
+ scanning ahead for a '(' and failing to find it. */
+#define A(x) B x
+#define B(x)
+#define C A
+#define D() A
+
+/* The correct output is shown here. Note the spaces, and the way
+ everything after the invocation of f appears on the same line.
+
+ 44 ;
+B Q B Q A Q A:
+f
+bar
+A
+bad
+g "1 2" bam baz
+
+*/
+
+glue (EMPTY 4, 4) EMPTY;
+A(Q) C(Q) D()Q D():
+f
+bar
+A
+bad
+f (g) str
+(
+1
+2
+) f
+(bam) baz
+
+/* { dg-final { scan-file spacing1.i " 44 ;" } }
+ { dg-final { scan-file spacing1.i "B Q B Q A Q A:" } }
+ { dg-final { scan-file-not spacing1.i "f\[^\n\]*bar" } }
+ { dg-final { scan-file spacing1.i "(^|\n)bar" } }
+ { dg-final { scan-file spacing1.i "(^|\n)A($|\n)" } }
+ { dg-final { scan-file spacing1.i "(^|\n)bad($|\n)" } }
+ { dg-final { scan-file spacing1.i "g \"1 2\" bam baz" } } */