OSDN Git Service

1999-09-03 19:31 -0700 Zack Weinberg <zack@bitmover.com>
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 4 Sep 1999 02:34:10 +0000 (02:34 +0000)
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 4 Sep 1999 02:34:10 +0000 (02:34 +0000)
* gcc.dg/cast-qual-1.c: Add missing dg-bogus tag.
* gcc.dg/compare1.c: Fix typo.
* gcc-dg/cpp-unc.c, cpp-unc1.c, cpp-unc2.c, cpp-unc3.c: New
files which test the preprocessor's unterminated conditional
diagnostics.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@29097 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/gcc.dg/cast-qual-1.c
gcc/testsuite/gcc.dg/compare1.c
gcc/testsuite/gcc.dg/cpp-unc.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp-unc1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp-unc2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp-unc3.c [new file with mode: 0644]

index a7a3470..464fd45 100644 (file)
@@ -20,7 +20,7 @@ bad_cast(const void *bar)
 void
 good_assign(const void *bar)
 {
-  char *const *foo = bar;
+  char *const *foo = bar; /* { dg-bogus "initialization discards" "discarding `const' warning" } */
 }
 
 void
index bba5f1d..3be9d95 100644 (file)
@@ -22,5 +22,5 @@ int main()
 {
   enum machine_mode mode = DImode;
 
-  return (mode == Pmode); /* dg-bogus "warning:" "comparison between signed and unsigned" } */
+  return (mode == Pmode); /* dg-bogus "warning:" "comparison between signed and unsigned" } */
 }
diff --git a/gcc/testsuite/gcc.dg/cpp-unc.c b/gcc/testsuite/gcc.dg/cpp-unc.c
new file mode 100644 (file)
index 0000000..4daddf6
--- /dev/null
@@ -0,0 +1,39 @@
+/* { dg-do preprocess } */
+
+/* Tests for un-terminated conditional diagnostics.
+   Copyright (c) 1999 Free Software Foundation.
+   Contributed by Zack Weinberg, who made it up all by himself.  */
+
+#endif /* { dg-error "#endif" "#endif without #if" } */
+
+#else  /* { dg-error "#else" "#else without #if" } */
+#endif /* { dg-error "#endif" "#endif after #else without #if" } */
+
+#elif 0 /* { dg-error "#elif" "#elif without #if" } */
+#endif  /* { dg-error "#endif" "#endif after #else without #if" } */
+
+#if 1  /* { dg-bogus "unterminated" "terminated true conditional" } */
+blah
+#endif
+
+#if 0  /* { dg-bogus "unterminated" "terminated false conditional" } */
+ignored
+#endif
+
+/* We shouldn't see unbalanced conditionals inside #if'ed out #includes.  */
+#if 0
+#include "cpp-unc1.c"
+#endif
+
+/* The ifdef below should not get an error just because there's a bad if
+   inside the included file.  
+   The odd dg-error tag on the include matches the "In file included from"
+   message.  */
+#define FOO
+#ifdef FOO  /* { dg-bogus "unterminated" "nested unterm" } */
+#include "cpp-unc1.c"  /* { dg-error "" } */
+#endif
+
+/* dg.exp doesn't read the included files for tags, so we have to
+   do them explicitly here.  */
+/* { dg-error "#if" "unc1.h: unterminated #if" { target native } 3 } */
diff --git a/gcc/testsuite/gcc.dg/cpp-unc1.c b/gcc/testsuite/gcc.dg/cpp-unc1.c
new file mode 100644 (file)
index 0000000..5059ae6
--- /dev/null
@@ -0,0 +1,13 @@
+/* Tests for un-terminated conditionals: 1.  */
+
+#if 1  /* { dg-error "unterminated" "unterminated #if" } */
+
+#ifdef notdef /* { dg-bogus "unterminated" "nested terminated #ifdef" } */
+
+blah blah blah
+
+#endif
+
+more text
+
+/* oops! */
diff --git a/gcc/testsuite/gcc.dg/cpp-unc2.c b/gcc/testsuite/gcc.dg/cpp-unc2.c
new file mode 100644 (file)
index 0000000..d9e3959
--- /dev/null
@@ -0,0 +1,11 @@
+/* Tests for unterminated conditionals: 2.  */
+
+#ifdef __sparc__  /* { dg-error "unterminated" "unterminated if-elif-elif..." } */
+sparc
+#elif defined __powerpc__
+ppc
+#elif defined __i386__
+i386
+#elif defined __vax__
+vax
+
diff --git a/gcc/testsuite/gcc.dg/cpp-unc3.c b/gcc/testsuite/gcc.dg/cpp-unc3.c
new file mode 100644 (file)
index 0000000..9a16bb3
--- /dev/null
@@ -0,0 +1,4 @@
+/* Tests for unterminated conditionals: 3.  */
+
+#if 1  /* { dg-error "#else" "unterminated #else" } */
+#else