summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/cpp')
-rw-r--r--gcc/testsuite/gcc.dg/cpp/19990703-1.c24
-rw-r--r--gcc/testsuite/gcc.dg/cpp/20000625-2.c5
-rw-r--r--gcc/testsuite/gcc.dg/cpp/macro10.c25
-rw-r--r--gcc/testsuite/gcc.dg/cpp/spacing1.c11
-rw-r--r--gcc/testsuite/gcc.dg/cpp/strify3.c29
5 files changed, 66 insertions, 28 deletions
diff --git a/gcc/testsuite/gcc.dg/cpp/19990703-1.c b/gcc/testsuite/gcc.dg/cpp/19990703-1.c
deleted file mode 100644
index c3ac2330055..00000000000
--- a/gcc/testsuite/gcc.dg/cpp/19990703-1.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/* { dg-do run } */
-
-/* Test of obscure case in token pasting in the preprocessor.
- I can't think of any way to make this problem provoke a syntax error.
- Based on a bug report by Manfred Hollstein. */
-
-#include <string.h>
-
-#define SP1(x, y) SP2(x, y)
-#define SP2(x, y) SP3(x##y)
-#define SP3(x) #x
-#define MZ -0
-
-int
-main(void)
-{
- char *x = SP1(0,MZ); /* { dg-warning "valid preprocessing token" "" } */
- char *y = "0-0"; /* should be the expansion of SP1(0,MZ) */
-
- if(strcmp(x, y))
- return 1;
- else
- return 0;
-}
diff --git a/gcc/testsuite/gcc.dg/cpp/20000625-2.c b/gcc/testsuite/gcc.dg/cpp/20000625-2.c
index fb458984b8c..c9e3fe23b9c 100644
--- a/gcc/testsuite/gcc.dg/cpp/20000625-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/20000625-2.c
@@ -8,7 +8,10 @@
#define str(x) xstr(x)
#define xstr(x) #x
-const char a[] = str(symbol_version(getrlimit, GLIBC_2.0));
+/* This testcase is bogus, as it testing undefined behaviour. We can
+ get the behaviour GLIBC desires by removing the space before
+ GCLIB_2.0 in this line. */
+const char a[] = str(symbol_version(getrlimit,GLIBC_2.0));
/* { dg-warning "valid preprocessing token" "" { target *-*-* } 11 } */
const char b[] = str(getrlimit@GLIBC_2.0);
const char c[] = "getrlimit@GLIBC_2.0";
diff --git a/gcc/testsuite/gcc.dg/cpp/macro10.c b/gcc/testsuite/gcc.dg/cpp/macro10.c
new file mode 100644
index 00000000000..20d4911e648
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/macro10.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+
+/* Source: Neil Booth, 23 Sep 2001.
+
+ A tricky, pathological corner case we used to get wrong. Expansion
+ should go as follows. The asterisk indicates the token has "blue
+ paint" can no longer be macro expanded. We used to lose that
+ information when parsing arguments and dropping to the lexer to get
+ the ')'.
+
+ foo )
+ bar foo* )
+ func (foo* )
+ foo*
+
+ If we try and expand the final foo, we get an "unterminated
+ argument list invoking macro <func>" error. If we do the right
+ thing and leave it as is, no diagnostics are emitted. */
+
+#define func(x) x
+#define bar func(
+#define foo bar foo
+foo )
diff --git a/gcc/testsuite/gcc.dg/cpp/spacing1.c b/gcc/testsuite/gcc.dg/cpp/spacing1.c
index 55a8f967c81..9a3933b7308 100644
--- a/gcc/testsuite/gcc.dg/cpp/spacing1.c
+++ b/gcc/testsuite/gcc.dg/cpp/spacing1.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 Free Software Foundation, Inc. */
+/* Copyright (C) 2000, 2001 Free Software Foundation, Inc. */
/* { dg-do preprocess } */
@@ -8,20 +8,24 @@
not be a macro invocation. Also, multiple macro invocations spread
across many lines.
- Neil Booth, 1 Dec 2000. */
+ Neil Booth, 1 Dec 2000, 23 Sep 2001. */
#define str(x) #x
#define f(x) x
+#define glue(x, y) x ## y
+#define EMPTY
/* The correct output is shown here. Note the spaces, and the way
everything after the invocation of f appears on the same line.
+ 44 ;
f
bar
g "1 2" bam baz
*/
+glue (EMPTY 4, 4) EMPTY;
f
bar
f (g) str
@@ -33,9 +37,10 @@ f (g) str
/*
{ dg-final { if ![file exists spacing1.i] { return } } }
+ { dg-final { if \{ [grep spacing1.i " 44 ;"] != "" \} \{ } }
{ dg-final { if \{ [grep spacing1.i "f.*bar"] == "" \} \{ } }
{ dg-final { if \{ [grep spacing1.i "^bar"] != "" \} \{ } }
{ dg-final { if \{ [grep spacing1.i "g \"1 2\" bam baz"] != "" \} \{ } }
- { dg-final { return \} \} \} } }
+ { dg-final { return \} \} \} \} } }
{ dg-final { fail "spacing1.c: spacing and new-line preservation" } }
*/
diff --git a/gcc/testsuite/gcc.dg/cpp/strify3.c b/gcc/testsuite/gcc.dg/cpp/strify3.c
new file mode 100644
index 00000000000..5d76b5e750f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/strify3.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc. */
+
+/* { dg-do run } */
+
+/* Tests we stringify without inserting a space. GCC 2.95.x and
+ earlier would insert a bogus space before bar in the string, simply
+ because a space was there in the invocation.
+
+ Neil Booth, 24 Sep 2001. */
+
+extern int strcmp (const char *, const char *);
+extern int puts (const char *);
+extern void abort (void);
+#define err(str) do { puts(str); abort(); } while (0)
+
+#define str(x) #x
+#define xstr(x) str(x)
+#define glibc_hack(x, y) x@y
+
+int main (int argc, char *argv[])
+{
+ /* The space before "bar" here is vital. */
+ char a[] = xstr(glibc_hack(foo, bar));
+
+ if (strcmp (a, "foo@bar"))
+ err ("stringification without spaces");
+
+ return 0;
+}