This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix PR c++/13377, bad diagnostic for ambiguous name-lookup


On 29 Aug, Mark Mitchell wrote:
> Volker Reichelt wrote:
> 
>> 2005-08-29  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
>> 
>> 	PR c++/13377
>> 	* parser.c (cp_parser_lookup_name): Pass LOOKUP_COMPLAIN to
>> 	lookup_name_real on final parse.
> 
> OK.

Here's the 3.4-branch version of the patch.
Bootstrapped and regtested on i686-pc-linux-gnu.
Ok to commit?

Regards,
Volker


2005-08-31  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/13377
	* parser.c (cp_parser_lookup_name): Pass LOOKUP_COMPLAIN to
	lookup_name_real on final parse.

===================================================================
--- gcc/gcc/cp/parser.c	28 Jul 2005 10:22:09 -0000	1.157.2.58
+++ gcc/gcc/cp/parser.c	31 Aug 2005 11:59:58 -0000
@@ -13710,6 +13710,7 @@ cp_parser_lookup_name (cp_parser *parser
 		       bool is_type, bool is_template, bool is_namespace,
 		       bool check_dependency)
 {
+  int flags = 0;
   tree decl;
   tree object_type = parser->context->object_type;
 
@@ -13721,6 +13722,10 @@ cp_parser_lookup_name (cp_parser *parser
   if (name == error_mark_node)
     return error_mark_node;
 
+  if (!cp_parser_parsing_tentatively (parser)
+      || cp_parser_committed_to_tentative_parse (parser))
+    flags |= LOOKUP_COMPLAIN;
+
   /* A template-id has already been resolved; there is no lookup to
      do.  */
   if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
@@ -13834,8 +13839,7 @@ cp_parser_lookup_name (cp_parser *parser
 				     /*protect=*/0, is_type);
       /* Look it up in the enclosing context, too.  */
       decl = lookup_name_real (name, is_type, /*nonclass=*/0, 
-			       is_namespace,
-			       /*flags=*/0);
+			       is_namespace, flags);
       parser->object_scope = object_type;
       parser->qualifying_scope = NULL_TREE;
       if (object_decl)
@@ -13844,8 +13848,7 @@ cp_parser_lookup_name (cp_parser *parser
   else
     {
       decl = lookup_name_real (name, is_type, /*nonclass=*/0, 
-			       is_namespace,
-			       /*flags=*/0);
+			       is_namespace, flags);
       parser->qualifying_scope = NULL_TREE;
       parser->object_scope = NULL_TREE;
     }
===================================================================


2005-08-31  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/13377
	* g++.dg/lookup/ambig4.C: New test.
	* g++.dg/lookup/ambig5.C: New test.

===================================================================
--- gcc/gcc/testsuite/g++.dg/lookup/ambig4.C	2005-08-22 19:21:29 +0200
+++ gcc/gcc/testsuite/g++.dg/lookup/ambig4.C	2005-08-29 21:12:03 +0200
@@ -0,0 +1,14 @@
+// PR c++/13377
+// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+// { dg-do compile }
+
+namespace N
+{
+  int i;            // { dg-error "declared" }
+}
+
+int i;              // { dg-error "declared" }
+
+using namespace N;
+
+void foo() { i; }   // { dg-error "undeclared|ambiguous" }
===================================================================
--- gcc/gcc/testsuite/g++.dg/lookup/ambig5.C	2005-08-22 19:21:29 +0200
+++ gcc/gcc/testsuite/g++.dg/lookup/ambig5.C	2005-08-31 11:52:07 +0200
@@ -0,0 +1,13 @@
+// PR c++/13377
+// Origin: Boris Kolpackov <boris@kolpackov.net>
+// { dg-do compile }
+
+namespace N
+{
+  namespace M {}    // { dg-error "declared" }
+}
+
+namespace M {}      // { dg-error "declared" }
+
+using namespace N;
+using namespace M;  // { dg-error "namespace-name|ambiguous" }
===================================================================



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]