summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-02-11 23:50:45 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-02-11 23:50:45 +0000
commit638ed81f292c4f4bad9ba0a40b3b547965f81a32 (patch)
treea6b7a99780e0752da0df83d39dc326af2f9b8261
parentd3cd9bdec0a817502f9f19b48d5fb7699159077c (diff)
downloadppe42-gcc-638ed81f292c4f4bad9ba0a40b3b547965f81a32.tar.gz
ppe42-gcc-638ed81f292c4f4bad9ba0a40b3b547965f81a32.zip
PR c/456
* cppexp.c (num_binary_op): Don't allow comma operators in #if constant expressions at all outside C99 mode if pedantic. testsuite: * gcc.dg/cpp/c90-if-comma-1.c, gcc.dg/cpp/c99-if-comma-1.c: New tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@77676 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/cppexp.c3
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/cpp/c90-if-comma-1.c11
-rw-r--r--gcc/testsuite/gcc.dg/cpp/c99-if-comma-1.c11
5 files changed, 36 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 22d06d6ee8a..6f2774bd715 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2004-02-11 Joseph S. Myers <jsm@polyomino.org.uk>
+
+ PR c/456
+ * cppexp.c (num_binary_op): Don't allow comma operators in #if
+ constant expressions at all outside C99 mode if pedantic.
+
2004-02-11 Uros Bizjak <uros@kss-loka.si>
* optabs.h (enum optab_index): Add new OTI_log10 and OTI_log2.
diff --git a/gcc/cppexp.c b/gcc/cppexp.c
index c6f1f1d39a5..5603f5bd58a 100644
--- a/gcc/cppexp.c
+++ b/gcc/cppexp.c
@@ -1347,7 +1347,8 @@ num_binary_op (cpp_reader *pfile, cpp_num lhs, cpp_num rhs, enum cpp_ttype op)
/* Comma. */
default: /* case CPP_COMMA: */
- if (CPP_PEDANTIC (pfile) && !pfile->state.skip_eval)
+ if (CPP_PEDANTIC (pfile) && (!CPP_OPTION (pfile, c99)
+ || !pfile->state.skip_eval))
cpp_error (pfile, CPP_DL_PEDWARN,
"comma operator in operand of #if");
lhs = rhs;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7c1aa663a8f..140302bb11d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2004-02-11 Joseph S. Myers <jsm@polyomino.org.uk>
+
+ PR c/456
+ * gcc.dg/cpp/c90-if-comma-1.c, gcc.dg/cpp/c99-if-comma-1.c: New
+ tests.
+
2004-02-11 Uros Bizjak <uros@kss-loka.si>
* gcc.dg/builtins-33.c: New test.
diff --git a/gcc/testsuite/gcc.dg/cpp/c90-if-comma-1.c b/gcc/testsuite/gcc.dg/cpp/c90-if-comma-1.c
new file mode 100644
index 00000000000..c00403f16ad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/c90-if-comma-1.c
@@ -0,0 +1,11 @@
+/* Test for commas in constant expressions in #if: not permitted in C90
+ but permitted in unevaluated subexpressions in C99. */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do preprocess } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
+
+#if (1, 2) /* { dg-error "comma" "evaluated comma" } */
+#endif
+
+#if 1 || (1, 2) /* { dg-error "comma" "unevaluated comma" } */
+#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/c99-if-comma-1.c b/gcc/testsuite/gcc.dg/cpp/c99-if-comma-1.c
new file mode 100644
index 00000000000..cb8eb6f7363
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/c99-if-comma-1.c
@@ -0,0 +1,11 @@
+/* Test for commas in constant expressions in #if: not permitted in C90
+ but permitted in unevaluated subexpressions in C99. */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do preprocess } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+#if (1, 2) /* { dg-error "comma" "evaluated comma" } */
+#endif
+
+#if 1 || (1, 2)
+#endif
OpenPOWER on IntegriCloud