2005-12-22 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
authorreichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Dec 2005 12:01:44 +0000 (12:01 +0000)
committerreichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Dec 2005 12:01:44 +0000 (12:01 +0000)
PR c++/23333
* include/cpplib.h: Add PURE_ZERO to flags for the cpp_token structure.

* c-lex.c (c_lex_with_flags): Add PURE_ZERO to cpp_flags if
number is a single digit '0'.

* parser.c (cp_parser_pure_specifier): Check for PURE_ZERO to
identify a single '0'.

* g++.dg/parse/error25.C: Add more tests.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108947 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-lex.c
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/error25.C
libcpp/ChangeLog
libcpp/include/cpplib.h

index b1b50aa..abed9bd 100644 (file)
@@ -1,3 +1,9 @@
+2005-12-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/23333
+       * c-lex.c (c_lex_with_flags): Add PURE_ZERO to cpp_flags if
+       number is a single digit '0'.
+
 2005-12-22  Kazu Hirata  <kazu@codesourcery.com>
 
        PR tree-optimization/23518
index e745388..af3695f 100644 (file)
@@ -333,6 +333,7 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags)
   static bool no_more_pch;
   const cpp_token *tok;
   enum cpp_ttype type;
+  unsigned char add_flags = 0;
 
   timevar_push (TV_CPP);
  retry:
@@ -366,6 +367,10 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags)
            break;
 
          case CPP_N_INTEGER:
+           /* C++ uses '0' to mark virtual functions as pure.
+              Set PURE_ZERO to pass this information to the C++ parser.  */
+           if (tok->val.str.len == 1 && *tok->val.str.text == '0')
+             add_flags = PURE_ZERO;
            *value = interpret_integer (tok, flags);
            break;
 
@@ -472,7 +477,7 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags)
     }
 
   if (cpp_flags)
-    *cpp_flags = tok->flags;
+    *cpp_flags = tok->flags | add_flags;
 
   if (!no_more_pch)
     {
index 766fbd5..361202e 100644 (file)
@@ -1,3 +1,9 @@
+2005-12-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/23333
+       * parser.c (cp_parser_pure_specifier): Check for PURE_ZERO to
+       identify a single '0'.
+
 2005-12-20  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/21228
index 3079faa..ca56176 100644 (file)
@@ -13648,18 +13648,13 @@ cp_parser_pure_specifier (cp_parser* parser)
     return error_mark_node;
   /* Look for the `0' token.  */
   token = cp_lexer_consume_token (parser->lexer);
-  if (token->type != CPP_NUMBER || !integer_zerop (token->value))
-    {
-      cp_parser_error (parser,
-                      "invalid pure specifier (only `= 0' is allowed)");
-      cp_parser_skip_to_end_of_statement (parser);
-      return error_mark_node;
-    }
+  /* c_lex_with_flags marks a single digit '0' with PURE_ZERO.  */
+  if (token->type == CPP_NUMBER && (token->flags & PURE_ZERO))
+    return integer_zero_node;
 
-  /* FIXME: Unfortunately, this will accept `0L' and `0x00' as well.
-     We need to get information from the lexer about how the number
-     was spelled in order to fix this problem.  */
-  return integer_zero_node;
+  cp_parser_error (parser, "invalid pure specifier (only `= 0' is allowed)");
+  cp_parser_skip_to_end_of_statement (parser);
+  return error_mark_node;
 }
 
 /* Parse a constant-initializer.
index 4734f81..089e088 100644 (file)
@@ -1,3 +1,8 @@
+2005-12-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/23333
+       * g++.dg/parse/error25.C: Add more tests.
+
 2005-12-22  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
 
        PR fortran/18990
index a726a17..360b40f 100644 (file)
@@ -11,6 +11,7 @@ class foo
   virtual void bar2 () = __null;  // { dg-error "invalid pure specifier" }
   virtual void bar3 () = 4;       // { dg-error "invalid pure specifier" }
   virtual void bar4 () = A::f;    // { dg-error "invalid pure specifier" }
+  virtual void bar5 () = 0l;      // { dg-error "invalid pure specifier" }
+  virtual void bar6 () = 00;      // { dg-error "invalid pure specifier" }
+  virtual void bar7 () = 0x0;     // { dg-error "invalid pure specifier" }
 };
-
-
index d96b55f..e21ea6d 100644 (file)
@@ -1,3 +1,8 @@
+2005-12-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/23333
+       * include/cpplib.h: Add PURE_ZERO to flags for the cpp_token structure.
+
 2005-12-07  Jon Grimm  <jgrimm2@us.ibm.com>
            Ben Elliston  <bje@au.ibm.com>
 
index b5bece5..0ab6635 100644 (file)
@@ -172,6 +172,8 @@ struct cpp_string GTY(())
 #define NAMED_OP       (1 << 4) /* C++ named operators.  */
 #define NO_EXPAND      (1 << 5) /* Do not macro-expand this token.  */
 #define BOL            (1 << 6) /* Token at beginning of line.  */
+#define PURE_ZERO      (1 << 7) /* Single 0 digit, used by the C++ frontend,
+                                   set in c-lex.c.  */
 
 /* Specify which field, if any, of the cpp_token union is used.  */