aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2003-04-15 20:23:36 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2003-04-15 20:23:36 +0000
commit5eb106287bbb5cba374b3a6666ce40685a33e900 (patch)
tree8187fbf0bd1bb690a6a10b2f1cf5858182c6f6e2
parent98475c572e3d589811aa15cf17184dcd5e265db2 (diff)
downloadgcc-5eb106287bbb5cba374b3a6666ce40685a33e900.zip
gcc-5eb106287bbb5cba374b3a6666ce40685a33e900.tar.gz
gcc-5eb106287bbb5cba374b3a6666ce40685a33e900.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c67
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/lookup3.C12
-rw-r--r--gcc/testsuite/lib/prune.exp2
5 files changed, 62 insertions, 30 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3c1055b..7ce1498 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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>
* decl2.c (mark_used): Don't instantiate anything if
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 8f992c5..7515089 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -2558,43 +2558,52 @@ cp_parser_primary_expression (cp_parser *parser,
}
}
- if (!parser->scope
- && decl == error_mark_node
- && processing_template_decl)
+ if (decl == error_mark_node)
{
- /* Unqualified name lookup failed while processing a
- template. */
- *idk = CP_PARSER_ID_KIND_UNQUALIFIED;
- /* If the next token is a parenthesis, assume that
- Koenig lookup will succeed when instantiating the
- template. */
- if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN))
- return build_min_nt (LOOKUP_EXPR, id_expression);
- /* If we're not doing Koenig lookup, issue an error. */
- error ("`%D' has not been declared", id_expression);
- return error_mark_node;
- }
- else if (decl == error_mark_node
- && !processing_template_decl)
- {
- if (!parser->scope)
+ /* Name lookup failed. */
+ if (!parser->scope
+ && processing_template_decl)
+ {
+ /* Unqualified name lookup failed while processing a
+ template. */
+ *idk = CP_PARSER_ID_KIND_UNQUALIFIED;
+ /* If the next token is a parenthesis, assume that
+ Koenig lookup will succeed when instantiating the
+ template. */
+ if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN))
+ return build_min_nt (LOOKUP_EXPR, id_expression);
+ /* If we're not doing Koenig lookup, issue an error. */
+ error ("`%D' has not been declared", id_expression);
+ return error_mark_node;
+ }
+ 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
call. */
*idk = CP_PARSER_ID_KIND_UNQUALIFIED;
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
will succeed. Issue a diagnostic here. */
else
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index dcdfea4..7cce917 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+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>
* gcc.c-torture/compile/20030415-1.c : New test.
diff --git a/gcc/testsuite/g++.dg/parse/lookup3.C b/gcc/testsuite/g++.dg/parse/lookup3.C
new file mode 100644
index 0000000..d4bf798
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/lookup3.C
@@ -0,0 +1,12 @@
+struct X {};
+
+template <int>
+struct Base {
+ static void foo () {
+ X::NONEXISTENT (); // { dg-error "" }
+ }
+};
+
+int main () {
+ Base<2>::foo ();
+}
diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp
index a2861c0..8105340 100644
--- a/gcc/testsuite/lib/prune.exp
+++ b/gcc/testsuite/lib/prune.exp
@@ -19,7 +19,7 @@
proc prune_gcc_output { text } {
#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)collect2: ld returned \[^\n\]*" $text "" text
regsub -all "(^|\n)Please submit.*instructions\[^\n\]*" $text "" text