aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2000-01-27 22:27:24 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-01-27 22:27:24 +0000
commit73b5cdf98ad368b41766577395b2a5bbd91e3f1b (patch)
tree3289ce56abd1bc315e175e229d5aed981b408477
parent35ac3890ec195a629b2562bcf43153eb4f75d2f9 (diff)
downloadgcc-73b5cdf98ad368b41766577395b2a5bbd91e3f1b.zip
gcc-73b5cdf98ad368b41766577395b2a5bbd91e3f1b.tar.gz
gcc-73b5cdf98ad368b41766577395b2a5bbd91e3f1b.tar.bz2
Test cases for c++ comments and endif labels in system headers.
I made them up all by myself. From-SVN: r31653
-rw-r--r--gcc/testsuite/gcc.dg/cxx-comments-1.c20
-rw-r--r--gcc/testsuite/gcc.dg/cxx-comments-2.c20
-rw-r--r--gcc/testsuite/gcc.dg/endif-label.c15
3 files changed, 55 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/cxx-comments-1.c b/gcc/testsuite/gcc.dg/cxx-comments-1.c
new file mode 100644
index 0000000..c7c51d6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cxx-comments-1.c
@@ -0,0 +1,20 @@
+/* { dg-do preprocess } */
+/* { dg-options "-pedantic -std=gnu89" } */
+
+/* You can't do this in your own code... */
+// C++ comment is not in C89 { dg-warning "style comment|reported only once" "good warning" }
+
+/* ...but we don't bitch about it more than once. */
+// C++ comment is not in C89 { dg-bogus "style comment" "bad warning" }
+
+/*
+ { dg-final { if ![file exists cxx-comments-1.i] { return } } }
+ { dg-final { set tmp [grep cxx-comments-1.i "is not in C89" line] } }
+ { dg-final { # send_user "$tmp\n" } }
+ { dg-final { if [regexp "is not in C89" $tmp] \{ } }
+ { dg-final { fail "cxx-comments-1: comment strip check" } }
+ { dg-final { \} else \{ } }
+ { dg-final { pass "cxx-comments-1: comment strip check" } }
+ { dg-final { \} } }
+*/
+
diff --git a/gcc/testsuite/gcc.dg/cxx-comments-2.c b/gcc/testsuite/gcc.dg/cxx-comments-2.c
new file mode 100644
index 0000000..7d0fe09
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cxx-comments-2.c
@@ -0,0 +1,20 @@
+/* { dg-do preprocess } */
+/* { dg-options "-pedantic -std=c89" } */
+
+/* This is an extension and therefore gets a warning. */
+#line 5 "cxx-comments-2.c" 3 /* { dg-warning "garbage at end" "#line extension" } */
+
+/* A system header may contain C++ comments irrespective of mode. */
+// C++ comment is not in C89 { dg-bogus "style comment" "bad warning" }
+
+/*
+ { dg-final { if ![file exists cxx-comments-2.i] { return } } }
+ { dg-final { set tmp [grep cxx-comments-2.i "is not in C89" line] } }
+ { dg-final { # send_user "$tmp\n" } }
+ { dg-final { if [regexp "is not in C89" $tmp] \{ } }
+ { dg-final { fail "cxx-comments-2: comment strip check" } }
+ { dg-final { \} else \{ } }
+ { dg-final { pass "cxx-comments-2: comment strip check" } }
+ { dg-final { \} } }
+*/
+
diff --git a/gcc/testsuite/gcc.dg/endif-label.c b/gcc/testsuite/gcc.dg/endif-label.c
new file mode 100644
index 0000000..95bd05d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/endif-label.c
@@ -0,0 +1,15 @@
+/* { dg-do preprocess } */
+/* { dg-options "-pedantic -Wall" } */
+
+/* You can't get away with this in your own code... */
+#ifdef KERNEL
+#define foo
+#endif KERNEL /* { dg-warning "text following" "good warning" } */
+
+/* This will provoke a warning because the '3' is an extension. */
+#line 10 "endif-label.c" 3 /* { dg-warning "garbage at end" "#line extension" } */
+
+/* ... but in a system header, it's acceptable. */
+#ifdef KERNEL
+#define foo
+#endif KERNEL /* { dg-bogus "text following" "bad warning" } */