mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-02 16:23:56 +08:00
re PR c++/10603 (failing to print problematic token upon parse error)
PR c++/10603 PR c++/12827 * parser.c (cp_parser_error): Help c_parse_error print good messages if the next token is a keyword. (cp_parser_parameter_declaration_list): When resynchronizing after a bad parameter declaration, stop if a comma is found. (cp_parser_parameter_declaration): Avoid backtracking. PR c++/10603 * g++.dg/parse/error6.C: New test. PR c++/12827 * g++.dg/parse/error7.C: New test. From-SVN: r74743
This commit is contained in:
parent
8f0f6aa1fd
commit
5c832178f8
@ -1,3 +1,13 @@
|
||||
2003-12-17 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
PR c++/10603
|
||||
PR c++/12827
|
||||
* parser.c (cp_parser_error): Help c_parse_error print good
|
||||
messages if the next token is a keyword.
|
||||
(cp_parser_parameter_declaration_list): When resynchronizing after
|
||||
a bad parameter declaration, stop if a comma is found.
|
||||
(cp_parser_parameter_declaration): Avoid backtracking.
|
||||
|
||||
2003-12-16 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
PR c++/12696
|
||||
|
@ -1771,7 +1771,12 @@ cp_parser_error (cp_parser* parser, const char* message)
|
||||
{
|
||||
cp_token *token;
|
||||
token = cp_lexer_peek_token (parser->lexer);
|
||||
c_parse_error (message, token->type, token->value);
|
||||
c_parse_error (message,
|
||||
/* Because c_parser_error does not understand
|
||||
CPP_KEYWORD, keywords are treated like
|
||||
identifiers. */
|
||||
(token->type == CPP_KEYWORD ? CPP_NAME : token->type),
|
||||
token->value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10804,7 +10809,7 @@ cp_parser_parameter_declaration_list (cp_parser* parser)
|
||||
|| cp_parser_committed_to_tentative_parse (parser))
|
||||
cp_parser_skip_to_closing_parenthesis (parser,
|
||||
/*recovering=*/true,
|
||||
/*or_comma=*/true,
|
||||
/*or_comma=*/false,
|
||||
/*consume_paren=*/false);
|
||||
break;
|
||||
}
|
||||
@ -10900,6 +10905,16 @@ cp_parser_parameter_declaration (cp_parser *parser,
|
||||
bool saved_default_arg_ok_p = parser->default_arg_ok_p;
|
||||
parser->default_arg_ok_p = false;
|
||||
|
||||
/* After seeing a decl-specifier-seq, if the next token is not a
|
||||
"(", there is no possibility that the code is a valid
|
||||
expression initializer. Therefore, if parsing tentatively,
|
||||
we commit at this point. */
|
||||
if (!parser->in_template_argument_list_p
|
||||
&& cp_parser_parsing_tentatively (parser)
|
||||
&& !cp_parser_committed_to_tentative_parse (parser)
|
||||
&& cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_PAREN))
|
||||
cp_parser_commit_to_tentative_parse (parser);
|
||||
/* Parse the declarator. */
|
||||
declarator = cp_parser_declarator (parser,
|
||||
CP_PARSER_DECLARATOR_EITHER,
|
||||
/*ctor_dtor_or_conv_p=*/NULL,
|
||||
|
@ -1,3 +1,11 @@
|
||||
2003-12-17 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
PR c++/10603
|
||||
* g++.dg/parse/error6.C: New test.
|
||||
|
||||
PR c++/12827
|
||||
* g++.dg/parse/error7.C: New test.
|
||||
|
||||
2003-12-17 Eric Botcazou <ebotcazou@libertysurf.fr>
|
||||
|
||||
* lib/gcc-dg.exp (gcc-dg-debug-runtest): Do not run debug-[12].c
|
||||
|
@ -3,4 +3,4 @@
|
||||
static void InstantiateConstraint(const float&, unsigned,
|
||||
void(*AddFunction)(const TYPE&,bool&, // { dg-error "" }
|
||||
char*, char*,
|
||||
unsigned*));
|
||||
unsigned*)); // { dg-error "" }
|
||||
|
6
gcc/testsuite/g++.dg/parse/error6.C
Normal file
6
gcc/testsuite/g++.dg/parse/error6.C
Normal file
@ -0,0 +1,6 @@
|
||||
// PR c++/10603
|
||||
|
||||
int f(int not) { // { dg-error "!" }
|
||||
return 1-not; // { dg-error "" }
|
||||
}
|
||||
|
4
gcc/testsuite/g++.dg/parse/error7.C
Normal file
4
gcc/testsuite/g++.dg/parse/error7.C
Normal file
@ -0,0 +1,4 @@
|
||||
// PR c++/12827
|
||||
|
||||
void f(int x
|
||||
int y); // { dg-error "," }
|
Loading…
Reference in New Issue
Block a user