Commit 5eb10628 by Mark Mitchell Committed by Mark Mitchell

re PR c++/10381 (Accepts call to inexistent function)

	PR c++/10381
	* parser.c (cp_parser_primary_expression): Reorganize logic for
	dealing with name lookup failures.

	PR c++/10381
	* g++.dg/parse/lookup3.C: New test.

From-SVN: r65656
parent 98475c57
2003-04-15 Mark Mitchell <mark@codesourcery.com>
PR c++/10381
* parser.c (cp_parser_primary_expression): Reorganize logic for
dealing with name lookup failures.
2003-04-15 Jason Merrill <jason@redhat.com> 2003-04-15 Jason Merrill <jason@redhat.com>
* decl2.c (mark_used): Don't instantiate anything if * decl2.c (mark_used): Don't instantiate anything if
......
...@@ -2558,43 +2558,52 @@ cp_parser_primary_expression (cp_parser *parser, ...@@ -2558,43 +2558,52 @@ cp_parser_primary_expression (cp_parser *parser,
} }
} }
if (!parser->scope if (decl == error_mark_node)
&& decl == error_mark_node
&& processing_template_decl)
{ {
/* Unqualified name lookup failed while processing a /* Name lookup failed. */
template. */ if (!parser->scope
*idk = CP_PARSER_ID_KIND_UNQUALIFIED; && processing_template_decl)
/* If the next token is a parenthesis, assume that {
Koenig lookup will succeed when instantiating the /* Unqualified name lookup failed while processing a
template. */ template. */
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN)) *idk = CP_PARSER_ID_KIND_UNQUALIFIED;
return build_min_nt (LOOKUP_EXPR, id_expression); /* If the next token is a parenthesis, assume that
/* If we're not doing Koenig lookup, issue an error. */ Koenig lookup will succeed when instantiating the
error ("`%D' has not been declared", id_expression); template. */
return error_mark_node; if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN))
} return build_min_nt (LOOKUP_EXPR, id_expression);
else if (decl == error_mark_node /* If we're not doing Koenig lookup, issue an error. */
&& !processing_template_decl) error ("`%D' has not been declared", id_expression);
{ return error_mark_node;
if (!parser->scope) }
else if (parser->scope
&& (!TYPE_P (parser->scope)
|| !dependent_type_p (parser->scope)))
{
/* Qualified name lookup failed, and the
qualifying name was not a dependent type. That
is always an error. */
if (TYPE_P (parser->scope)
&& !COMPLETE_TYPE_P (parser->scope))
error ("incomplete type `%T' used in nested name "
"specifier",
parser->scope);
else if (parser->scope != global_namespace)
error ("`%D' is not a member of `%D'",
id_expression, parser->scope);
else
error ("`::%D' has not been declared", id_expression);
return error_mark_node;
}
else if (!parser->scope && !processing_template_decl)
{ {
/* It may be resolvable as a koenig lookup function /* It may be resolvable as a koenig lookup function
call. */ call. */
*idk = CP_PARSER_ID_KIND_UNQUALIFIED; *idk = CP_PARSER_ID_KIND_UNQUALIFIED;
return id_expression; return id_expression;
} }
else if (TYPE_P (parser->scope)
&& !COMPLETE_TYPE_P (parser->scope))
error ("incomplete type `%T' used in nested name specifier",
parser->scope);
else if (parser->scope != global_namespace)
error ("`%D' is not a member of `%D'",
id_expression, parser->scope);
else
error ("`::%D' has not been declared", id_expression);
} }
/* If DECL is a variable would be out of scope under /* If DECL is a variable that would be out of scope under
ANSI/ISO rules, but in scope in the ARM, name lookup ANSI/ISO rules, but in scope in the ARM, name lookup
will succeed. Issue a diagnostic here. */ will succeed. Issue a diagnostic here. */
else else
......
2003-04-15 Mark Mitchell <mark@codesourcery.com>
PR c++/10381
* g++.dg/parse/lookup3.C: New test.
2003-04-15 J"orn Rennecke <joern.rennecke@superh.com> 2003-04-15 J"orn Rennecke <joern.rennecke@superh.com>
* gcc.c-torture/compile/20030415-1.c : New test. * gcc.c-torture/compile/20030415-1.c : New test.
......
struct X {};
template <int>
struct Base {
static void foo () {
X::NONEXISTENT (); // { dg-error "" }
}
};
int main () {
Base<2>::foo ();
}
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
proc prune_gcc_output { text } { proc prune_gcc_output { text } {
#send_user "Before:$text\n" #send_user "Before:$text\n"
regsub -all "(^|\n)\[^\n\]*: In (function|member|method|(copy )?constructor|instantiation|program|subroutine|block-data) \[^\n\]*" $text "" text regsub -all "(^|\n)\[^\n\]*: In ((static member )?function|member|method|(copy )?constructor|instantiation|program|subroutine|block-data) \[^\n\]*" $text "" text
regsub -all "(^|\n)\[^\n\]*: At (top level|global scope):\[^\n\]*" $text "" text regsub -all "(^|\n)\[^\n\]*: At (top level|global scope):\[^\n\]*" $text "" text
regsub -all "(^|\n)collect2: ld returned \[^\n\]*" $text "" text regsub -all "(^|\n)collect2: ld returned \[^\n\]*" $text "" text
regsub -all "(^|\n)Please submit.*instructions\[^\n\]*" $text "" text regsub -all "(^|\n)Please submit.*instructions\[^\n\]*" $text "" text
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment