]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
N3472 binary constants
authorJakub Jelinek <jakub@redhat.com>
Sun, 28 Apr 2013 21:36:57 +0000 (23:36 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 28 Apr 2013 21:36:57 +0000 (23:36 +0200)
N3472 binary constants
* include/cpplib.h (struct cpp_options): Fix a typo in user_literals
field comment.  Add binary_constants field.
* init.c (struct lang_flags): Add binary_constants field.
(lang_defaults): Add bin_cst column to the table.
(cpp_set_lang): Initialize CPP_OPTION (pfile, binary_constants).
* expr.c (cpp_classify_number): Talk about C++11 instead of C++0x
in diagnostics.  Accept binary constants if
CPP_OPTION (pfile, binary_constants) even when pedantic.  Adjust
pedwarn message.

* g++.dg/cpp/limits.C: Adjust warning wording.
* g++.dg/system-binary-constants-1.C: Likewise.
* g++.dg/cpp1y/system-binary-constants-1.C: New test.

From-SVN: r198380

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp/limits.C
gcc/testsuite/g++.dg/cpp1y/system-binary-constants-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/system-binary-constants-1.C
libcpp/ChangeLog
libcpp/expr.c
libcpp/include/cpplib.h
libcpp/init.c

index 36ce9f0f06bc9538b97325c1a1e9fb42e98ed84e..cf3465728c06e45767b87ee72a944e5507b87e4f 100644 (file)
@@ -1,3 +1,10 @@
+2013-04-28  Jakub Jelinek  <jakub@redhat.com>
+
+       N3472 binary constants
+       * g++.dg/cpp/limits.C: Adjust warning wording.
+       * g++.dg/system-binary-constants-1.C: Likewise.
+       * g++.dg/cpp1y/system-binary-constants-1.C: New test.
+
 2013-04-28  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/57093
index b64e1e2eecbd1ada28f70135c02e79ae702f2dc3..5824e01931280e11e4978e04b0e1bd40b932b743 100644 (file)
@@ -4,13 +4,13 @@
 #include <limits>
 
 // Compiling this with -pedantic was wrongly triggering this error:
-// libstdc++-v3/include/limits:1269:45: warning : use of C++0x long long integer constant [-Wlong-long]
+// libstdc++-v3/include/limits:1269:45: warning : use of C++11 long long integer constant [-Wlong-long]
 //       min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_LONG_MAX__ - 1; }
 //                                             ^
-// libstdc++-v3/include/limits:1272:44: warning : use of C++0x long long integer constant [-Wlong-long]
+// libstdc++-v3/include/limits:1272:44: warning : use of C++11 long long integer constant [-Wlong-long]
 //       max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__; }
 //                                            ^
-// libstdc++-v3/include/limits:1342:44: warning : use of C++0x long long integer constant [-Wlong-long]
+// libstdc++-v3/include/limits:1342:44: warning : use of C++11 long long integer constant [-Wlong-long]
 //       max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__ * 2ULL + 1
 //                                            ^
 
diff --git a/gcc/testsuite/g++.dg/cpp1y/system-binary-constants-1.C b/gcc/testsuite/g++.dg/cpp1y/system-binary-constants-1.C
new file mode 100644 (file)
index 0000000..fe97127
--- /dev/null
@@ -0,0 +1,14 @@
+// Origin: Dodji Seketeli <dodji@redhat.com>
+// { dg-options "-std=c++1y -pedantic-errors" }
+// { dg-do compile } 
+
+#include "../system-binary-constants-1.h"
+
+int
+foo (void)
+{
+#if BINARY_INT_CONSTANT_IN_SYSTEM_HEADER
+  return 23;
+#endif
+  return 0b1101; // { dg-bogus "binary constants are a C..1y feature or GCC extension" }
+}
index 7ef26f7f011ac5fecde514bab198f890fe08c1dd..fbf8bb2c96d037fe898ce7c377dc74fff9d47ede 100644 (file)
@@ -14,5 +14,5 @@ foo (void)
                                            warning.  */
   return 23;
 #endif
-  return 0b1101; /* { dg-warning "binary constants are a GCC extension" } */
+  return 0b1101; /* { dg-warning "binary constants are a C..1y feature or GCC extension" } */
 }
index 329f5e0b9384cae5c7a9002295987af1340289fd..da68e5210a9c1628d6c9dd50698bf87a89b6063e 100644 (file)
@@ -1,3 +1,16 @@
+2013-04-28  Jakub Jelinek  <jakub@redhat.com>
+
+       N3472 binary constants
+       * include/cpplib.h (struct cpp_options): Fix a typo in user_literals
+       field comment.  Add binary_constants field.
+       * init.c (struct lang_flags): Add binary_constants field.
+       (lang_defaults): Add bin_cst column to the table.
+       (cpp_set_lang): Initialize CPP_OPTION (pfile, binary_constants).
+       * expr.c (cpp_classify_number): Talk about C++11 instead of C++0x
+       in diagnostics.  Accept binary constants if
+       CPP_OPTION (pfile, binary_constants) even when pedantic.  Adjust
+       pedwarn message.
+
 2013-04-24  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * include/cpplib.h (enum c_lang): Add CLK_GNUCXX1Y and CLK_CXX1Y.
index 46d9fd386ab7c3a2d71ebed5098063b759b2bbf6..0eb6c13c2f0720344f114d68506494f752217b74 100644 (file)
@@ -621,7 +621,7 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
          && CPP_OPTION (pfile, cpp_warn_long_long))
         {
           const char *message = CPP_OPTION (pfile, cplusplus) 
-                               ? N_("use of C++0x long long integer constant")
+                               ? N_("use of C++11 long long integer constant")
                                : N_("use of C99 long long integer constant");
 
          if (CPP_OPTION (pfile, c99))
@@ -639,9 +639,14 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
   if ((result & CPP_N_IMAGINARY) && CPP_PEDANTIC (pfile))
     cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
                         "imaginary constants are a GCC extension");
-  if (radix == 2 && CPP_PEDANTIC (pfile))
+  if (radix == 2
+      && !CPP_OPTION (pfile, binary_constants)
+      && CPP_PEDANTIC (pfile))
     cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
-                        "binary constants are a GCC extension");
+                        CPP_OPTION (pfile, cplusplus)
+                        ? "binary constants are a C++1y feature "
+                          "or GCC extension"
+                        : "binary constants are a GCC extension");
 
   if (radix == 10)
     result |= CPP_N_DECIMAL;
index 3084a11a8538dfcf3afbe58e5a1b044663f558b9..76c297acdcbd4b77149dedd769af54d69b570004 100644 (file)
@@ -423,7 +423,7 @@ struct cpp_options
   /* True for traditional preprocessing.  */
   unsigned char traditional;
 
-  /* Nonzero for C++ 2011 Standard user-defnied literals.  */
+  /* Nonzero for C++ 2011 Standard user-defined literals.  */
   unsigned char user_literals;
 
   /* Nonzero means warn when a string or character literal is followed by a
@@ -434,6 +434,9 @@ struct cpp_options
      literal number suffixes as user-defined literal number suffixes.  */
   unsigned char ext_numeric_literals;
 
+  /* Nonzero for C++ 2014 Standard binary constants.  */
+  unsigned char binary_constants;
+
   /* Holds the name of the target (execution) character set.  */
   const char *narrow_charset;
 
index c3fa4af178beba492fc963ea8f38e1980cb660d8..97510003dd813358ea10315dd95c20720e310309 100644 (file)
@@ -83,24 +83,25 @@ struct lang_flags
   char uliterals;
   char rliterals;
   char user_literals;
+  char binary_constants;
 };
 
 static const struct lang_flags lang_defaults[] =
-{ /*              c99 c++ xnum xid std  //   digr ulit rlit user_literals */
-  /* GNUC89   */  { 0,  0,  1,   0,  0,   1,   1,   0,   0,    0 },
-  /* GNUC99   */  { 1,  0,  1,   0,  0,   1,   1,   1,   1,    0 },
-  /* GNUC11   */  { 1,  0,  1,   0,  0,   1,   1,   1,   1,    0 },
-  /* STDC89   */  { 0,  0,  0,   0,  1,   0,   0,   0,   0,    0 },
-  /* STDC94   */  { 0,  0,  0,   0,  1,   0,   1,   0,   0,    0 },
-  /* STDC99   */  { 1,  0,  1,   0,  1,   1,   1,   0,   0,    0 },
-  /* STDC11   */  { 1,  0,  1,   0,  1,   1,   1,   1,   0,    0 },
-  /* GNUCXX   */  { 0,  1,  1,   0,  0,   1,   1,   0,   0,    0 },
-  /* CXX98    */  { 0,  1,  1,   0,  1,   1,   1,   0,   0,    0 },
-  /* GNUCXX11 */  { 1,  1,  1,   0,  0,   1,   1,   1,   1,    1 },
-  /* CXX11    */  { 1,  1,  1,   0,  1,   1,   1,   1,   1,    1 },
-  /* GNUCXX1Y */  { 1,  1,  1,   0,  0,   1,   1,   1,   1,    1 },
-  /* CXX1Y    */  { 1,  1,  1,   0,  1,   1,   1,   1,   1,    1 },
-  /* ASM      */  { 0,  0,  1,   0,  0,   1,   0,   0,   0,    0 }
+{ /*              c99 c++ xnum xid std  //   digr ulit rlit udlit bin_cst */
+  /* GNUC89   */  { 0,  0,  1,   0,  0,   1,   1,   0,   0,   0,    0 },
+  /* GNUC99   */  { 1,  0,  1,   0,  0,   1,   1,   1,   1,   0,    0 },
+  /* GNUC11   */  { 1,  0,  1,   0,  0,   1,   1,   1,   1,   0,    0 },
+  /* STDC89   */  { 0,  0,  0,   0,  1,   0,   0,   0,   0,   0,    0 },
+  /* STDC94   */  { 0,  0,  0,   0,  1,   0,   1,   0,   0,   0,    0 },
+  /* STDC99   */  { 1,  0,  1,   0,  1,   1,   1,   0,   0,   0,    0 },
+  /* STDC11   */  { 1,  0,  1,   0,  1,   1,   1,   1,   0,   0,    0 },
+  /* GNUCXX   */  { 0,  1,  1,   0,  0,   1,   1,   0,   0,   0,    0 },
+  /* CXX98    */  { 0,  1,  1,   0,  1,   1,   1,   0,   0,   0,    0 },
+  /* GNUCXX11 */  { 1,  1,  1,   0,  0,   1,   1,   1,   1,   1,    0 },
+  /* CXX11    */  { 1,  1,  1,   0,  1,   1,   1,   1,   1,   1,    0 },
+  /* GNUCXX1Y */  { 1,  1,  1,   0,  0,   1,   1,   1,   1,   1,    1 },
+  /* CXX1Y    */  { 1,  1,  1,   0,  1,   1,   1,   1,   1,   1,    1 },
+  /* ASM      */  { 0,  0,  1,   0,  0,   1,   0,   0,   0,   0,    0 }
   /* xid should be 1 for GNUC99, STDC99, GNUCXX, CXX98, GNUCXX11, CXX11,
      GNUCXX1Y, and CXX1Y when no longer experimental (when all uses of
      identifiers in the compiler have been audited for correct handling
@@ -126,6 +127,7 @@ cpp_set_lang (cpp_reader *pfile, enum c_lang lang)
   CPP_OPTION (pfile, uliterals)                         = l->uliterals;
   CPP_OPTION (pfile, rliterals)                         = l->rliterals;
   CPP_OPTION (pfile, user_literals)             = l->user_literals;
+  CPP_OPTION (pfile, binary_constants)          = l->binary_constants;
 }
 
 /* Initialize library global state.  */