lex.c (D_CPP0X): Rename.
authorDouglas Gregor <dgregor@osl.iu.edu>
Thu, 25 Jan 2007 04:02:36 +0000 (04:02 +0000)
committerDoug Gregor <dgregor@gcc.gnu.org>
Thu, 25 Jan 2007 04:02:36 +0000 (04:02 +0000)
2007-01-24  Douglas Gregor  <dgregor@osl.iu.edu>

* lex.c (D_CPP0X): Rename.
(D_CXX0X): To this.
(reswords): D_CPP0X -> D_CXX0X.
(init_reswords): Ditto.
* parser.c (cp_lexer_get_preprocessor_token): Warn about the use
of C++0x keywords as identifiers.

From-SVN: r121161

gcc/cp/ChangeLog
gcc/cp/lex.c
gcc/cp/parser.c

index afc66a88d3169f36d69178dba727d81f14a9c68e..e04ee5a4cc5e0cc72bf57f75f02e08c6e99f153e 100644 (file)
@@ -1,3 +1,12 @@
+2007-01-24  Douglas Gregor  <dgregor@osl.iu.edu>
+
+       * lex.c (D_CPP0X): Rename.
+       (D_CXX0X): To this.
+       (reswords): D_CPP0X -> D_CXX0X.
+       (init_reswords): Ditto.
+       * parser.c (cp_lexer_get_preprocessor_token): Warn about the use
+       of C++0x keywords as identifiers.
+
 2007-01-23  Simon Martin  <simartin@users.sourceforge.net>
 
        PR c++/27492
index 27a17c3d3feece8ea2891f4acd5c06fe116b395a..db78a474e5d44bf57c13ad31accd0c91dc6056d8 100644 (file)
@@ -176,7 +176,7 @@ struct resword
 #define D_EXT          0x01    /* GCC extension */
 #define D_ASM          0x02    /* in C99, but has a switch to turn it off */
 #define D_OBJC         0x04    /* Objective C++ only */
-#define D_CPP0X         0x08    /* C++0x only */
+#define D_CXX0X         0x08    /* C++0x only */
 
 CONSTRAINT(ridbits_fit, RID_LAST_MODIFIER < sizeof(unsigned long) * CHAR_BIT);
 
@@ -260,7 +260,7 @@ static const struct resword reswords[] =
   { "signed",          RID_SIGNED,     0 },
   { "sizeof",          RID_SIZEOF,     0 },
   { "static",          RID_STATIC,     0 },
-  { "static_assert",    RID_STATIC_ASSERT, D_CPP0X },
+  { "static_assert",    RID_STATIC_ASSERT, D_CXX0X },
   { "static_cast",     RID_STATCAST,   0 },
   { "struct",          RID_STRUCT,     0 },
   { "switch",          RID_SWITCH,     0 },
@@ -317,7 +317,7 @@ init_reswords (void)
   int mask = ((flag_no_asm ? D_ASM : 0)
              | D_OBJC
              | (flag_no_gnu_keywords ? D_EXT : 0)
-              | (flag_cpp0x ? 0 : D_CPP0X));
+              | (flag_cpp0x ? 0 : D_CXX0X));
 
   ridpointers = GGC_CNEWVEC (tree, (int) RID_MAX);
   for (i = 0; i < ARRAY_SIZE (reswords); i++)
index 40009c218bf6b7816fce51a86b1f63a2434ed19c..fa18e20b99e931d74dbe8582c9f2cbd466a1be0c 100644 (file)
@@ -443,6 +443,20 @@ cp_lexer_get_preprocessor_token (cp_lexer *lexer ATTRIBUTE_UNUSED ,
        }
       else
        {
+          if (warn_cxx0x_compat
+              && C_RID_CODE (token->u.value) >= RID_FIRST_CXX0X
+              && C_RID_CODE (token->u.value) <= RID_LAST_CXX0X)
+            {
+              /* Warn about the C++0x keyword (but still treat it as
+                 an identifier).  */
+              warning (0, "identifier %<%s%> will become a keyword in C++0x",
+                       IDENTIFIER_POINTER (token->u.value));
+
+              /* Clear out the C_RID_CODE so we don't warn about this
+                 particular identifier-turned-keyword again.  */
+              C_RID_CODE (token->u.value) = RID_MAX;
+            }
+
          token->ambiguous_p = false;
          token->keyword = RID_MAX;
        }