re PR c++/16002 (Strange error message with new parser)
PR c++/16002 * parser.c (cp_parser_simple_declaration): Commit to tentative parses after seeing a decl-specifier. (cp_parser_simple_declaration): Eliminate spurious message. (cp_parser_init_declarator): Adjust error message. PR c++/16029 * lex.c (unqualified_name_lookup_error): Mark the dummy declaration as used. PR c++/16002 * g++.dg/template/error18.C: New test. PR c++/16029 * g++.dg/warn/Wunused-8.C: New test. From-SVN: r87633
This commit is contained in:
parent
275a418708
commit
996c2b5248
|
@ -1,5 +1,15 @@
|
||||||
2004-09-16 Mark Mitchell <mark@codesourcery.com>
|
2004-09-16 Mark Mitchell <mark@codesourcery.com>
|
||||||
|
|
||||||
|
PR c++/16002
|
||||||
|
* parser.c (cp_parser_simple_declaration): Commit to tentative
|
||||||
|
parses after seeing a decl-specifier.
|
||||||
|
(cp_parser_simple_declaration): Eliminate spurious message.
|
||||||
|
(cp_parser_init_declarator): Adjust error message.
|
||||||
|
|
||||||
|
PR c++/16029
|
||||||
|
* lex.c (unqualified_name_lookup_error): Mark the dummy
|
||||||
|
declaration as used.
|
||||||
|
|
||||||
PR c++/17501
|
PR c++/17501
|
||||||
* parser.c (cp_parser_nested_name_specifier): Do not resolve
|
* parser.c (cp_parser_nested_name_specifier): Do not resolve
|
||||||
typename types if the user explicitly said "typename".
|
typename types if the user explicitly said "typename".
|
||||||
|
|
|
@ -572,6 +572,9 @@ unqualified_name_lookup_error (tree name)
|
||||||
decl = build_decl (VAR_DECL, name, error_mark_node);
|
decl = build_decl (VAR_DECL, name, error_mark_node);
|
||||||
DECL_CONTEXT (decl) = current_function_decl;
|
DECL_CONTEXT (decl) = current_function_decl;
|
||||||
push_local_binding (name, decl, 0);
|
push_local_binding (name, decl, 0);
|
||||||
|
/* Mark the variable as used so that we do not get warnings
|
||||||
|
about it being unused later. */
|
||||||
|
TREE_USED (decl) = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7026,6 +7026,13 @@ cp_parser_simple_declaration (cp_parser* parser,
|
||||||
/* Give up. */
|
/* Give up. */
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we have seen at least one decl-specifier, and the next token
|
||||||
|
is not a parenthesis, then we must be looking at a declaration.
|
||||||
|
(After "int (" we might be looking at a functional cast.) */
|
||||||
|
if (decl_specifiers.any_specifiers_p
|
||||||
|
&& cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_PAREN))
|
||||||
|
cp_parser_commit_to_tentative_parse (parser);
|
||||||
|
|
||||||
/* Keep going until we hit the `;' at the end of the simple
|
/* Keep going until we hit the `;' at the end of the simple
|
||||||
declaration. */
|
declaration. */
|
||||||
|
@ -7079,7 +7086,12 @@ cp_parser_simple_declaration (cp_parser* parser,
|
||||||
/* Anything else is an error. */
|
/* Anything else is an error. */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cp_parser_error (parser, "expected `,' or `;'");
|
/* If we have already issued an error message we don't need
|
||||||
|
to issue another one. */
|
||||||
|
if (decl != error_mark_node
|
||||||
|
|| (cp_parser_parsing_tentatively (parser)
|
||||||
|
&& !cp_parser_committed_to_tentative_parse (parser)))
|
||||||
|
cp_parser_error (parser, "expected `,' or `;'");
|
||||||
/* Skip tokens until we reach the end of the statement. */
|
/* Skip tokens until we reach the end of the statement. */
|
||||||
cp_parser_skip_to_end_of_statement (parser);
|
cp_parser_skip_to_end_of_statement (parser);
|
||||||
/* If the next token is now a `;', consume it. */
|
/* If the next token is now a `;', consume it. */
|
||||||
|
@ -10641,7 +10653,7 @@ cp_parser_init_declarator (cp_parser* parser,
|
||||||
&& token->type != CPP_COMMA
|
&& token->type != CPP_COMMA
|
||||||
&& token->type != CPP_SEMICOLON)
|
&& token->type != CPP_SEMICOLON)
|
||||||
{
|
{
|
||||||
cp_parser_error (parser, "expected init-declarator");
|
cp_parser_error (parser, "expected initializer");
|
||||||
return error_mark_node;
|
return error_mark_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
2004-09-17 Mark Mitchell <mark@codesourcery.com>
|
||||||
|
|
||||||
|
PR c++/16002
|
||||||
|
* g++.dg/template/error18.C: New test.
|
||||||
|
|
||||||
|
PR c++/16029
|
||||||
|
* g++.dg/warn/Wunused-8.C: New test.
|
||||||
|
|
||||||
2004-09-17 Steven Bosscher <stevenb@suse.de>
|
2004-09-17 Steven Bosscher <stevenb@suse.de>
|
||||||
|
|
||||||
PR tree-optimization/17513
|
PR tree-optimization/17513
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
// PR c++/16002
|
||||||
|
|
||||||
|
void f()
|
||||||
|
{
|
||||||
|
double Q *= 5.0; // { dg-error "initializer" }
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
// PR c++/16029
|
||||||
|
// { dg-options "-Wunused" }
|
||||||
|
|
||||||
|
int main ()
|
||||||
|
{
|
||||||
|
// We should not see an "unused" warning about "whatever" on the
|
||||||
|
// next line.
|
||||||
|
return whatever (); // { dg-error "declared" }
|
||||||
|
}
|
Loading…
Reference in New Issue