aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2015-01-23 11:57:43 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2015-01-23 11:57:43 +0000
commit10ef8f287e92cad2f6963a9ee25d954c87567629 (patch)
treeb588bb547ecd04e5b2df8f148a1b0e9e0cdc32fc /gcc
parentb0edd457a1b282528b98cb56b153d049ad03542a (diff)
downloadgcc-10ef8f287e92cad2f6963a9ee25d954c87567629.zip
gcc-10ef8f287e92cad2f6963a9ee25d954c87567629.tar.gz
gcc-10ef8f287e92cad2f6963a9ee25d954c87567629.tar.bz2
re PR preprocessor/60570 (expression in 'elif' directive mis-diagnosed as error when group will be skipped)
DR#412 PR preprocessor/60570 * directives.c (do_elif): Don't evaluate #elif conditionals when they don't need to be. * gcc.dg/cpp/pr36320.c: Turn dg-error into dg-bogus. * gcc.dg/cpp/pr60570.c: New test. From-SVN: r220035
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr36320.c4
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr60570.c48
3 files changed, 56 insertions, 2 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 86753d6..cf9b478 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2015-01-23 Marek Polacek <polacek@redhat.com>
+
+ PR preprocessor/60570
+ * gcc.dg/cpp/pr36320.c: Turn dg-error into dg-bogus.
+ * gcc.dg/cpp/pr60570.c: New test.
+
2015-01-23 Richard Biener <rguenther@suse.de>
PR testsuite/63439
diff --git a/gcc/testsuite/gcc.dg/cpp/pr36320.c b/gcc/testsuite/gcc.dg/cpp/pr36320.c
index d136a69..cc2baa7 100644
--- a/gcc/testsuite/gcc.dg/cpp/pr36320.c
+++ b/gcc/testsuite/gcc.dg/cpp/pr36320.c
@@ -1,8 +1,8 @@
/* PR 36320 - #elif still requires valid expression. */
-
+/* DR#412: #elif doesn't have to be valid expression (PR60570). */
/* { dg-do preprocess } */
int z;
#if 1
-#elif /* { dg-error "with no expression" } */
+#elif /* { dg-bogus "with no expression" } */
#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/pr60570.c b/gcc/testsuite/gcc.dg/cpp/pr60570.c
new file mode 100644
index 0000000..4755206
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr60570.c
@@ -0,0 +1,48 @@
+/* PR preprocessor/60570 */
+/* { dg-do preprocess } */
+
+#if 1
+int i;
+#elif 1/0
+#endif
+
+#if 1
+int j;
+#elif
+#endif
+
+#if 0
+#elif 1/0 /* { dg-error "division by zero" } */
+int k;
+#endif
+
+#if 0
+#elif /* { dg-error "with no expression" } */
+int n;
+#endif
+
+#if 1
+# if 1
+int l;
+# elif 1/0
+# endif
+#endif
+
+#if 1
+# if 1
+int l;
+# elif
+# endif
+#endif
+
+#if 1
+# if 0
+# elif 1/0 /* { dg-error "division by zero" } */
+# endif
+#endif
+
+#if 1
+# if 0
+# elif /* { dg-error "with no expression" } */
+# endif
+#endif