cppexp.c (eval_token): Permit true and false even if pedantic.
authorNeil Booth <neil@daikokuya.co.uk>
Sat, 19 Apr 2003 10:04:47 +0000 (10:04 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sat, 19 Apr 2003 10:04:47 +0000 (10:04 +0000)
* cppexp.c (eval_token): Permit true and false even if pedantic.
testsuite:
* gcc.dg/cpp/truefalse.cpp: New test.
* gcc.dg/cpp/cpp.exp: Update.

From-SVN: r65811

gcc/ChangeLog
gcc/cppexp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/cpp.exp
gcc/testsuite/gcc.dg/cpp/truefalse.cpp [new file with mode: 0644]

index 2ff09ffacad26621b18f9f78f35931689acfbc94..5be40867c900da5f3c8f87180f0b842e849692a6 100644 (file)
@@ -1,3 +1,7 @@
+2003-04-19  Neil Booth  <neil@daikokuya.co.uk>
+
+       * cppexp.c (eval_token): Permit true and false even if pedantic.
+
 2003-04-19  Neil Booth  <neil@daikokuya.co.uk>
 
        * cpplex.c (skip_whitespace): Rearrange to avoid stage1 ICE.
index 59a08e90a672063d78a258a856adece3b6913731..9ab7b5fa14bea09d56416357e63d35d07e7843b9 100644 (file)
@@ -590,14 +590,6 @@ eval_token (pfile, token)
        {
          result.high = 0;
          result.low = (token->val.node == pfile->spec_nodes.n_true);
-
-         /* Warn about use of true or false in #if when pedantic
-            and stdbool.h has not been included.  */
-         if (CPP_PEDANTIC (pfile)
-             && ! cpp_defined (pfile, DSC("__bool_true_false_are_defined")))
-           cpp_error (pfile, DL_PEDWARN,
-                      "ISO C++ does not permit \"%s\" in #if",
-                      NODE_NAME (token->val.node));
        }
       else
        {
index fc71e0cf9c389f05c6c72c3e836470ef97d346c8..0eae036feb31075192b7cd8cd23913720d874135 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-19  Neil Booth  <neil@daikokuya.co.uk>
+
+       * gcc.dg/cpp/truefalse.cpp: New test.
+       * gcc.dg/cpp/cpp.exp: Update.
+
 2003-04-19  Neil Booth  <neil@daikokuya.co.uk>
 
        * gcc.dg/cpp/_Pragma4.c: Remove stray space.
index d477433c3b27f00a8c3e8112fcbe103229257b95..47c20ffb201bc42d26b000d774ee7282994fcd5a 100644 (file)
@@ -36,7 +36,7 @@ if ![info exists DEFAULT_CFLAGS] then {
 dg-init
 
 # Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{c,cpp,S} ]] \
        "" $DEFAULT_CFLAGS
 
 # All done.
diff --git a/gcc/testsuite/gcc.dg/cpp/truefalse.cpp b/gcc/testsuite/gcc.dg/cpp/truefalse.cpp
new file mode 100644 (file)
index 0000000..d852d4e
--- /dev/null
@@ -0,0 +1,17 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.  */
+
+/* Source: Neil Booth, 18 Apr 2003.  */
+
+/* { dg-do preprocess } */
+/* { dg-options "-ansi -pedantic -Wundef" } */
+
+/* Check that for C++ we handle true and false correctly, and do not
+   treat them as undefined identifiers.  */
+
+#if true               /* { dg-bogus "is not defined" } */
+#error foo             /* { dg-error "foo" } */
+#endif
+
+#if false              /* { dg-bogus "is not defined" } */
+#error foo             /* { dg-bogus "foo" } */
+#endif