20000625-1.c, [...]: New tests.
authorZack Weinberg <zack@wolery.cumb.org>
Sun, 25 Jun 2000 23:31:02 +0000 (23:31 +0000)
committerZack Weinberg <zack@gcc.gnu.org>
Sun, 25 Jun 2000 23:31:02 +0000 (23:31 +0000)
* gcc.dg/20000625-1.c, gcc.dg/20000625-2.c, gcc.dg/cpp-mi3.c:
        New tests.
* gcc.dg/cpp-mi3.def: New file.

* gcc.dg/cpp-as1.c: Also test that macro expansion does not occur
inside assertions.
* gcc.dg/cpp-as2.c: Make error regexps match either old or new
lexer's error messages.
* gcc.dg/cpp-mi.c: Use -H and examine the output, don't try to
divine anything from the linemarkers.
* gcc.dg/cpp-micc.h: Fix typo (declare int b, not int a);
* gcc.dg/poison-1.c: Preprocess only; apply -fno-show-column.

From-SVN: r34701

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20000625-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/20000625-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp-as1.c
gcc/testsuite/gcc.dg/cpp-as2.c
gcc/testsuite/gcc.dg/cpp-mi.c
gcc/testsuite/gcc.dg/cpp-mi3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp-mi3.def [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp-micc.h
gcc/testsuite/gcc.dg/poison-1.c

index 5b7babe..521e7ee 100644 (file)
@@ -1,3 +1,18 @@
+2000-06-25  Zack Weinberg  <zack@wolery.cumb.org>
+
+       * gcc.dg/20000625-1.c, gcc.dg/20000625-2.c, gcc.dg/cpp-mi3.c:
+        New tests.
+       * gcc.dg/cpp-mi3.def: New file.
+
+       * gcc.dg/cpp-as1.c: Also test that macro expansion does not occur
+       inside assertions.
+       * gcc.dg/cpp-as2.c: Make error regexps match either old or new
+       lexer's error messages.
+       * gcc.dg/cpp-mi.c: Use -H and examine the output, don't try to
+       divine anything from the linemarkers.
+       * gcc.dg/cpp-micc.h: Fix typo (declare int b, not int a);
+       * gcc.dg/poison-1.c: Preprocess only; apply -fno-show-column.
+
 2000-06-23  Geoffrey Keating  <geoffk@cygnus.com>
 
        * gcc.dg/20000623-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/20000625-1.c b/gcc/testsuite/gcc.dg/20000625-1.c
new file mode 100644 (file)
index 0000000..717ffb0
--- /dev/null
@@ -0,0 +1,18 @@
+/* Regression test for paste corner cases.  Distilled from
+   syscall stub logic in glibc.  */
+
+/* { dg-do run } */
+
+#include <stdlib.h>
+
+#define ENTRY(name)    name##:
+#define socket bind
+
+int
+main(void)
+{
+  goto socket;
+
+  ENTRY(socket)
+    return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/20000625-2.c b/gcc/testsuite/gcc.dg/20000625-2.c
new file mode 100644 (file)
index 0000000..e983450
--- /dev/null
@@ -0,0 +1,27 @@
+/* More paste corner cases from glibc.  */
+/* { dg-do run } */
+
+#define symbol_version(name, version) name##@##version
+
+#define str(x) xstr(x)
+#define xstr(x) #x
+
+const char a[] = str(symbol_version(getrlimit, GLIBC_2.0));
+const char b[] = str(getrlimit@GLIBC_2.0);
+const char c[] = "getrlimit@GLIBC_2.0";
+
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(void)
+{
+  if(strcmp(a, b))
+    abort();
+  if(strcmp(b, c))
+    abort();
+  if(strcmp(c, a))
+    abort();
+
+  return 0;
+}
index 6e8c0f8..ff7cc62 100644 (file)
@@ -2,6 +2,7 @@
 /* { dg-do compile } */
 /* { dg-options "" } */
 
+#define def unused expansion
 #define fail  int fail
 
 #assert abc (def)
index 2f40c28..26d3aad 100644 (file)
@@ -3,17 +3,17 @@
 /* { dg-options "-fno-show-column" } */
 
 #assert                /* { dg-error "without predicate" "assert w/o predicate" } */
-#assert %      /* { dg-error "not an identifier" "assert punctuation" } */
-#assert 12     /* { dg-error "not an identifier" "assert number" } */
-#assert abc    /* { dg-error "missing token-sequence" "assert w/o answer" } */
+#assert %      /* { dg-error "an identifier" "assert punctuation" } */
+#assert 12     /* { dg-error "an identifier" "assert number" } */
+#assert abc    /* { dg-error "missing" "assert w/o answer" } */
 
 #if #          /* { dg-error "without predicate" "test w/o predicate" } */
 #endif
 
-#if #%         /* { dg-error "not an identifier" "test punctuation" } */
+#if #%         /* { dg-error "an identifier" "test punctuation" } */
 #endif
 
-#if #12                /* { dg-error "not an identifier" "test number" } */
+#if #12                /* { dg-error "an identifier" "test number" } */
 #endif
 
 #if #abc
index f83a64d..3d05587 100644 (file)
@@ -1,9 +1,18 @@
 /* Test "ignore redundant include" facility.
    We must test with C and C++ comments outside the guard conditional;
-   also, we test guarding with #ifndef and #if !defined.  */
+   also, we test guarding with #ifndef and #if !defined.
+   -H is used because cpp might confuse the issue by optimizing out
+   #line markers.  This test only passes if each of the headers is
+   read exactly once.
 
-/* { dg-do preprocess }
-   { dg-options "" } */
+   The disgusting regexp in the dg-error line, when stuck into
+   dg.exp's compiler-output regexp, matches the correct -H output and
+   only the correct -H output.  It has to be all on one line because
+   otherwise it will not be interpreted all in one unit.  */
+
+/* { dg-do compile }
+   { dg-options "-H" }
+   { dg-error "mic\.h\n\[^\n\]*micc\.h\n\[^\n\]*mind\.h\n\[^\n\]*mindp\.h\n\[^\n\]*mix\.h" "redundant include check" { target native } 0 } */
 
 #include "cpp-mic.h"
 #include "cpp-mic.h"
@@ -26,15 +35,3 @@ main (void)
 {
   return a + b + c + d;
 }
-
-/*
-   { dg-final { if ![file exists cpp-mi.i] { return }          } }
-
-   { dg-final { set tmp [grep cpp-mi.i {cpp-mi.*\.h} line]     } }
-   { dg-final { # send_user "$tmp\n" } }
-   { dg-final { if [regexp "^{\[0-9\]+ cpp-mic\.h} {\[0-9\]+ cpp-micc\.h} {\[0-9\]+ cpp-mind\.h} {\[0-9\]+ cpp-mindp\.h} {\[0-9]+ cpp-mix\.h}$" $tmp] \{ } }
-   { dg-final {     pass "cpp-mi.c: redundant include check"   } }
-   { dg-final { \} else \{                                     } }
-   { dg-final {     fail "cpp-mi.c: redundant include check"   } }
-   { dg-final { \}                                             } }
-*/
diff --git a/gcc/testsuite/gcc.dg/cpp-mi3.c b/gcc/testsuite/gcc.dg/cpp-mi3.c
new file mode 100644 (file)
index 0000000..6055684
--- /dev/null
@@ -0,0 +1,17 @@
+/* Another test case for over-eager multiple include optimization.
+   This one distilled from glibc's setlocale.c and categories.def.  */
+/* { dg-do compile } */
+
+#define X a
+#include "cpp-mi3.def"
+#undef X
+
+#define X b
+#include "cpp-mi3.def"
+#undef X
+
+int
+main(void)
+{
+  return a + b;
+}
diff --git a/gcc/testsuite/gcc.dg/cpp-mi3.def b/gcc/testsuite/gcc.dg/cpp-mi3.def
new file mode 100644 (file)
index 0000000..375d9c7
--- /dev/null
@@ -0,0 +1,10 @@
+/* Another test case for over-eager multiple include optimization.    
+   This one distilled from glibc's setlocale.c and categories.def.
+   The #ifdef block doesn't cover the entire file, so it must not be
+   taken for a reinclude guard.  */
+
+#ifndef NO_POSTLOAD
+#define NO_POSTLOAD NULL
+#endif
+
+int X;
index 52c9dcc..46a38cd 100644 (file)
@@ -3,7 +3,7 @@
 #ifndef CPP_MICC_H
 #define CPP_MICC_H
 
-int a;
+int b;
 
 #endif
 
index 6aa57e6..79a910f 100644 (file)
@@ -1,3 +1,6 @@
+/* { dg-do preprocess }
+   { dg-options "-fno-show-column" } */
+
 #pragma poison foo
 foo                    /* { dg-error "foo" "use of foo" } */
 #pragma poison foo2 foo3