summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorreichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4>2005-12-22 12:01:44 +0000
committerreichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4>2005-12-22 12:01:44 +0000
commit8dba02f779af476cdaf6c33c05eb0d7480acec95 (patch)
treeb94f65ebd41d3c48ba009c669b5ad7aae0e5fc93
parentac42ecbd18cab1fdfb50ad161d437f2edf14f2b0 (diff)
downloadgcc-8dba02f779af476cdaf6c33c05eb0d7480acec95.tar.gz
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. * 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
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/c-lex.c7
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c17
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/error25.C5
-rw-r--r--libcpp/ChangeLog5
-rw-r--r--libcpp/include/cpplib.h2
8 files changed, 39 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b1b50aa7398..abed9bd23ef 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index e745388bc59..af3695f6e5a 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -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)
{
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 766fbd52763..361202edb41 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 3079faa6b94..ca561768ff0 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4734f8150bd..089e08802be 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/g++.dg/parse/error25.C b/gcc/testsuite/g++.dg/parse/error25.C
index a726a174bb4..360b40f2e7e 100644
--- a/gcc/testsuite/g++.dg/parse/error25.C
+++ b/gcc/testsuite/g++.dg/parse/error25.C
@@ -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" }
};
-
-
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index d96b55f07a6..e21ea6dc524 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -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>
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index b5bece5e5d6..0ab66357341 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -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. */