re PR c++/23333 (accepts invalid pure specifier)
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. From-SVN: r108947
This commit is contained in:
parent
110eec241d
commit
ab84748af1
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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" }
|
||||
};
|
||||
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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. */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user