re PR preprocessor/7263 (__extension__ keyword doesn't suppress warning on LL or...
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Mon, 18 Aug 2008 11:30:32 +0000 (11:30 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Mon, 18 Aug 2008 11:30:32 +0000 (11:30 +0000)
2008-08-18  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

PR cpp/7263
* c-opts.c (cpp_opts): Remove static.
* c-parser.c (cpp_opts): Declare it extern.
(disable_extension_diagnostics): Handle cpp options.
(enable_extension_diagnostics): Likewise.
testsuite/
* gcc.dg/cpp/pr7263-2.c: New.
* gcc.dg/cpp/pr7263-2.h: New.
* gcc.dg/cpp/pr7263-3.c: New.
* gcc.dg/cpp/pr7263-3.h: New.

From-SVN: r139194

gcc/ChangeLog
gcc/c-opts.c
gcc/c-parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/pr7263-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/pr7263-2.h [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/pr7263-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/pr7263-3.h [new file with mode: 0644]

index 514915f..747e45b 100644 (file)
@@ -1,5 +1,13 @@
 2008-08-18  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
 
+       PR cpp/7263
+       * c-opts.c (cpp_opts): Remove static.
+       * c-parser.c (cpp_opts): Declare it extern.
+       (disable_extension_diagnostics): Handle cpp options.
+       (enable_extension_diagnostics): Likewise.
+
+2008-08-18  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
        * diagnostics.c (permerror_at): Rename as permerror.
        (permerror): Delete.
        * toplev.h: Likewise.
index 300bf14..dccb45e 100644 (file)
@@ -54,7 +54,7 @@ along with GCC; see the file COPYING3.  If not see
 #endif
 
 /* CPP's options.  */
-static cpp_options *cpp_opts;
+cpp_options *cpp_opts;
 
 /* Input filename.  */
 static const char *this_input_filename;
index 1ea9d07..ccec660 100644 (file)
@@ -805,6 +805,9 @@ c_parser_skip_to_end_of_block_or_statement (c_parser *parser)
   parser->error = false;
 }
 
+/* CPP's options (initialized by c-opts.c).  */
+extern cpp_options *cpp_opts;
+
 /* Save the warning flags which are controlled by __extension__.  */
 
 static inline int
@@ -813,11 +816,15 @@ disable_extension_diagnostics (void)
   int ret = (pedantic
             | (warn_pointer_arith << 1)
             | (warn_traditional << 2)
-            | (flag_iso << 3));
-  pedantic = 0;
+            | (flag_iso << 3)
+            | (warn_long_long << 4)
+            | (cpp_opts->warn_long_long << 5));
+  cpp_opts->pedantic = pedantic = 0;
   warn_pointer_arith = 0;
-  warn_traditional = 0;
+  cpp_opts->warn_traditional = warn_traditional = 0;
   flag_iso = 0;
+  warn_long_long = 0;
+  cpp_opts->warn_long_long = 0;
   return ret;
 }
 
@@ -827,10 +834,12 @@ disable_extension_diagnostics (void)
 static inline void
 restore_extension_diagnostics (int flags)
 {
-  pedantic = flags & 1;
+  cpp_opts->pedantic = pedantic = flags & 1;
   warn_pointer_arith = (flags >> 1) & 1;
-  warn_traditional = (flags >> 2) & 1;
+  cpp_opts->warn_traditional = warn_traditional = (flags >> 2) & 1;
   flag_iso = (flags >> 3) & 1;
+  warn_long_long = (flags >> 4) & 1;
+  cpp_opts->warn_long_long = (flags >> 5) & 1;
 }
 
 /* Possibly kinds of declarator to parse.  */
index 56cd326..ff5dcd9 100644 (file)
@@ -1,3 +1,11 @@
+2008-08-18  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
+       PR cpp/7263
+       * gcc.dg/cpp/pr7263-2.c: New.
+       * gcc.dg/cpp/pr7263-2.h: New.
+       * gcc.dg/cpp/pr7263-3.c: New.
+       * gcc.dg/cpp/pr7263-3.h: New.
+
 2008-08-18  Robert Dewar  <dewar@adacore.com>
 
        PR ada/30827
diff --git a/gcc/testsuite/gcc.dg/cpp/pr7263-2.c b/gcc/testsuite/gcc.dg/cpp/pr7263-2.c
new file mode 100644 (file)
index 0000000..5ed10d0
--- /dev/null
@@ -0,0 +1,28 @@
+/* PR 7263:  __extension__ keyword doesn't suppress warning on LL or ULL constants.  */
+/* { dg-do compile } */
+/* { dg-options "-std=c89 -pedantic-errors" } */
+#include "pr7263-2.h"
+unsigned long long /* { dg-error "ISO C90 does not support .long long." } */
+bar ()
+{
+  return BIG_EXT;
+}
+
+unsigned long long /* { dg-error "ISO C90 does not support .long long." } */
+bar2 ()
+{
+  return 0x1b27da572ef3cd86ULL; /* { dg-error "use of C99 long long integer constant" } */
+}
+
+
+unsigned long long /* { dg-error "ISO C90 does not support .long long." } */
+bar3 ()
+{
+  return __extension__ (0x1b27da572ef3cd86ULL);
+}
+
+__extension__ unsigned long long 
+bar4 ()
+{
+  return BIG; 
+}
diff --git a/gcc/testsuite/gcc.dg/cpp/pr7263-2.h b/gcc/testsuite/gcc.dg/cpp/pr7263-2.h
new file mode 100644 (file)
index 0000000..54f1757
--- /dev/null
@@ -0,0 +1,4 @@
+#define BIG_EXT  __extension__(0x1b27da572ef3cd86ULL)
+
+#define BIG  0x1b27da572ef3cd86ULL
+
diff --git a/gcc/testsuite/gcc.dg/cpp/pr7263-3.c b/gcc/testsuite/gcc.dg/cpp/pr7263-3.c
new file mode 100644 (file)
index 0000000..efa619a
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR 7263:  __extension__ keyword doesn't suppress warning on LL or ULL constants.  */
+/* { dg-do compile } */
+/* { dg-options "-std=c99 -pedantic-errors" } */
+#include "pr7263-3.h"
+__complex__  bar () /* { dg-error "ISO C does not support plain .complex. meaning .double complex." } */
+{
+  return _Complex_I_ext;
+}
+
+__extension__ __complex__ 
+bar2 ()
+{
+  return _Complex_I;
+}
+
+__complex__ bar3 () /* { dg-error "ISO C does not support plain .complex. meaning .double complex." } */
+{
+  return _Complex_I; /* { dg-error "imaginary constants are a GCC extension" } */
+}
diff --git a/gcc/testsuite/gcc.dg/cpp/pr7263-3.h b/gcc/testsuite/gcc.dg/cpp/pr7263-3.h
new file mode 100644 (file)
index 0000000..ad6690e
--- /dev/null
@@ -0,0 +1,3 @@
+#define _Complex_I_ext      (__extension__ 1.0iF)
+
+#define _Complex_I      (1.0iF)