C++ PATCH: PR c++/12862

Mark Mitchell mark@codesourcery.com
Tue Dec 23 00:08:00 GMT 2003


This patch fixes a problem with name-lookup by removing some overly
defensive code.

Tested on i686-pc-linux-gnu, applied on the mainline.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2003-12-22  Mark Mitchell  <mark@codesourcery.com>

	PR c++/12862
	* name-lookup.c (pushdecl): Look up all namespace-scope entities
	in their corresponding namespace.

2003-12-22  Mark Mitchell  <mark@codesourcery.com>

	PR c++/12862
	* g++.dg/lookup/ns1.C: New test.

Index: cp/name-lookup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/name-lookup.c,v
retrieving revision 1.29
diff -c -5 -p -r1.29 name-lookup.c
*** cp/name-lookup.c	21 Dec 2003 21:07:30 -0000	1.29
--- cp/name-lookup.c	22 Dec 2003 23:37:31 -0000
*************** pushdecl (tree x)
*** 588,599 ****
        if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
  	name = TREE_OPERAND (name, 0);
  
        /* In case this decl was explicitly namespace-qualified, look it
  	 up in its namespace context.  */
!       if (TREE_CODE (x) == VAR_DECL && DECL_NAMESPACE_SCOPE_P (x)
! 	  && namespace_bindings_p ())
  	t = namespace_binding (name, DECL_CONTEXT (x));
        else
  	t = lookup_name_current_level (name);
  
        /* [basic.link] If there is a visible declaration of an entity
--- 588,598 ----
        if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
  	name = TREE_OPERAND (name, 0);
  
        /* In case this decl was explicitly namespace-qualified, look it
  	 up in its namespace context.  */
!       if (DECL_NAMESPACE_SCOPE_P (x) && namespace_bindings_p ())
  	t = namespace_binding (name, DECL_CONTEXT (x));
        else
  	t = lookup_name_current_level (name);
  
        /* [basic.link] If there is a visible declaration of an entity
Index: testsuite/g++.dg/lookup/ns1.C
===================================================================
RCS file: testsuite/g++.dg/lookup/ns1.C
diff -N testsuite/g++.dg/lookup/ns1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/lookup/ns1.C	22 Dec 2003 23:37:32 -0000
***************
*** 0 ****
--- 1,22 ----
+ // PR c++/12862
+ 
+ typedef int Thingo;
+   
+ namespace A
+ {
+     void
+     Thingo();
+ }
+   
+ void
+ A::Thingo()
+ {
+   ;
+ }
+   
+ int
+ main()
+ {
+   A::Thingo();
+   return 0;
+ }



More information about the Gcc-patches mailing list