aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2014-09-17 21:49:46 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2014-09-17 21:49:46 +0000
commit909eb89ca5b48b9a5645358e1cb5c949ec3f1edb (patch)
treed873bfc33c03e881e036aa4a39cd18516df27f6b /gcc
parent010718fc37a1e84698479677381e654169082cd0 (diff)
downloadgcc-909eb89ca5b48b9a5645358e1cb5c949ec3f1edb.zip
gcc-909eb89ca5b48b9a5645358e1cb5c949ec3f1edb.tar.gz
gcc-909eb89ca5b48b9a5645358e1cb5c949ec3f1edb.tar.bz2
re PR c/61854 (Warning single-line comment for -std=c89?)
PR c/61854 libcpp/ * init.c (struct lang_flags): Remove cplusplus_comments. (cpp_set_lang): Likewise. (post_options): Likewise. * lex.c (_cpp_lex_direct): Disallow C++ style comments in C90/C94. testsuite/ * gcc.dg/cpp/pr61854-1.c: New test. * gcc.dg/cpp/pr61854-2.c: New test. * gcc.dg/cpp/pr61854-3.c: New test. * gcc.dg/cpp/pr61854-3.h: New test. * gcc.dg/cpp/pr61854-4.c: New test. * gcc.dg/cpp/pr61854-5.c: New test. * gcc.dg/cpp/pr61854-6.c: New test. * gcc.dg/cpp/pr61854-7.c: New test. * gcc.dg/cpp/pr61854-c90.c: New test. * gcc.dg/cpp/pr61854-c94.c: New test. From-SVN: r215339
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog14
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr61854-1.c15
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr61854-2.c15
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr61854-3.c6
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr61854-3.h4
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr61854-4.c16
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr61854-5.c15
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr61854-6.c19
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr61854-7.c19
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr61854-c90.c13
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr61854-c94.c13
11 files changed, 149 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0362744..2815792 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,17 @@
+2014-09-17 Marek Polacek <polacek@redhat.com>
+
+ PR c/61854
+ * gcc.dg/cpp/pr61854-1.c: New test.
+ * gcc.dg/cpp/pr61854-2.c: New test.
+ * gcc.dg/cpp/pr61854-3.c: New test.
+ * gcc.dg/cpp/pr61854-3.h: New test.
+ * gcc.dg/cpp/pr61854-4.c: New test.
+ * gcc.dg/cpp/pr61854-5.c: New test.
+ * gcc.dg/cpp/pr61854-6.c: New test.
+ * gcc.dg/cpp/pr61854-7.c: New test.
+ * gcc.dg/cpp/pr61854-c90.c: New test.
+ * gcc.dg/cpp/pr61854-c94.c: New test.
+
2014-09-17 Jakub Jelinek <jakub@redhat.com>
PR debug/63284
diff --git a/gcc/testsuite/gcc.dg/cpp/pr61854-1.c b/gcc/testsuite/gcc.dg/cpp/pr61854-1.c
new file mode 100644
index 0000000..364a511
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr61854-1.c
@@ -0,0 +1,15 @@
+/* PR c/61854 */
+/* { dg-do run } */
+/* { dg-options "-std=c89" } */
+
+int
+main (void)
+{
+ int i = 1 //**/ 2
+ ;
+ int j = 1 //**/ 2
+ ;
+ if (i != 0 || j != 0)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/cpp/pr61854-2.c b/gcc/testsuite/gcc.dg/cpp/pr61854-2.c
new file mode 100644
index 0000000..883db21
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr61854-2.c
@@ -0,0 +1,15 @@
+/* PR c/61854 */
+/* { dg-do run } */
+/* { dg-options "-std=gnu89" } */
+
+int
+main (void)
+{
+ int i = 1 //**/ 2
+ ;
+ int j = 1 //**/ 2
+ ;
+ if (i != 1 || j != 1)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/cpp/pr61854-3.c b/gcc/testsuite/gcc.dg/cpp/pr61854-3.c
new file mode 100644
index 0000000..916c12e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr61854-3.c
@@ -0,0 +1,6 @@
+/* PR c/61854 */
+/* { dg-do preprocess } */
+/* { dg-options "-std=c89" } */
+
+#include "pr61854-3.h"
+int i;
diff --git a/gcc/testsuite/gcc.dg/cpp/pr61854-3.h b/gcc/testsuite/gcc.dg/cpp/pr61854-3.h
new file mode 100644
index 0000000..fd798bd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr61854-3.h
@@ -0,0 +1,4 @@
+#pragma GCC system_header
+// X
+// Y
+// Z
diff --git a/gcc/testsuite/gcc.dg/cpp/pr61854-4.c b/gcc/testsuite/gcc.dg/cpp/pr61854-4.c
new file mode 100644
index 0000000..5cfa5a7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr61854-4.c
@@ -0,0 +1,16 @@
+/* PR c/61854 */
+/* { dg-do preprocess } */
+/* { dg-options "-std=c89" } */
+
+void
+foo (void)
+{
+#if 0
+ // Do not error here.
+#endif
+#if 1
+ // But error here.
+#endif
+ /* { dg-error "C\\+\\+ style comments are not allowed in ISO C90" "comments" { target *-*-*} 12 } */
+ /* { dg-error "reported only once" "" { target *-*-*} 12 } */
+}
diff --git a/gcc/testsuite/gcc.dg/cpp/pr61854-5.c b/gcc/testsuite/gcc.dg/cpp/pr61854-5.c
new file mode 100644
index 0000000..a7628dc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr61854-5.c
@@ -0,0 +1,15 @@
+/* PR c/61854 */
+/* { dg-do run } */
+/* { dg-options "-std=c89" } */
+
+#define h(x) #x
+#define s(x) h(x)
+#define foo //
+
+int
+main (void)
+{
+ if (__builtin_memcmp (s(foo), "//", 3) != 0)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/cpp/pr61854-6.c b/gcc/testsuite/gcc.dg/cpp/pr61854-6.c
new file mode 100644
index 0000000..1b60cc3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr61854-6.c
@@ -0,0 +1,19 @@
+/* PR c/61854 */
+/* { dg-do run } */
+/* { dg-options "-std=gnu89" } */
+
+int
+main (void)
+{
+ int i = 0
+#if 0
+// /*
+#else
+// */
++1
+#endif
+;
+ if (i != 1)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/cpp/pr61854-7.c b/gcc/testsuite/gcc.dg/cpp/pr61854-7.c
new file mode 100644
index 0000000..8bf479b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr61854-7.c
@@ -0,0 +1,19 @@
+/* PR c/61854 */
+/* { dg-do run } */
+/* { dg-options "-std=c89" } */
+
+int
+main (void)
+{
+ int i = 0
+#if 0
+// /*
+#else
+// */
++1
+#endif
+;
+ if (i != 0)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/cpp/pr61854-c90.c b/gcc/testsuite/gcc.dg/cpp/pr61854-c90.c
new file mode 100644
index 0000000..37eecbe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr61854-c90.c
@@ -0,0 +1,13 @@
+/* PR c/61854 */
+/* { dg-do preprocess } */
+/* { dg-options "-std=iso9899:1990" } */
+
+void
+foo (void)
+{
+ // 1st
+ /* { dg-error "C\\+\\+ style comments are not allowed in ISO C90" "comments" { target *-*-*} 8 } */
+ /* { dg-error "reported only once" "" { target *-*-*} 8 } */
+ // 2nd
+ // 3rd
+}
diff --git a/gcc/testsuite/gcc.dg/cpp/pr61854-c94.c b/gcc/testsuite/gcc.dg/cpp/pr61854-c94.c
new file mode 100644
index 0000000..64f1e18
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr61854-c94.c
@@ -0,0 +1,13 @@
+/* PR c/61854 */
+/* { dg-do preprocess } */
+/* { dg-options "-std=iso9899:199409" } */
+
+void
+foo (void)
+{
+ // 1st
+ /* { dg-error "C\\+\\+ style comments are not allowed in ISO C90" "comments" { target *-*-*} 8 } */
+ /* { dg-error "reported only once" "" { target *-*-*} 8 } */
+ // 2nd
+ // 3rd
+}