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]

C++ PATCH: PR 12397


This patch fixes PR c++/12397, a name-lookup failure in templates.

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++/12397
	* typeck.c (finish_class_member_access_expr): Don't tree
	IDENTIFIER_NODEs as non-dependent expressions.

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

	PR c++/12397
	* g++.dg/template/lookup3.C: New test.

Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.516
diff -c -5 -p -r1.516 typeck.c
*** cp/typeck.c	21 Dec 2003 21:07:31 -0000	1.516
--- cp/typeck.c	22 Dec 2003 20:46:25 -0000
*************** finish_class_member_access_expr (tree ob
*** 1807,1816 ****
--- 1807,1819 ----
  
    if (processing_template_decl)
      {
        if (/* If OBJECT_TYPE is dependent, so is OBJECT.NAME.  */
  	  dependent_type_p (object_type)
+ 	  /* If NAME is just an IDENTIFIER_NODE, then the expression
+ 	     is dependent.  */
+ 	  || TREE_CODE (object) == IDENTIFIER_NODE
  	  /* If NAME is "f<args>", where either 'f' or 'args' is
  	     dependent, then the expression is dependent.  */
  	  || (TREE_CODE (name) == TEMPLATE_ID_EXPR
  	      && dependent_template_id_p (TREE_OPERAND (name, 0),
  					  TREE_OPERAND (name, 1)))
Index: testsuite/g++.dg/template/lookup3.C
===================================================================
RCS file: testsuite/g++.dg/template/lookup3.C
diff -N testsuite/g++.dg/template/lookup3.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/lookup3.C	22 Dec 2003 20:49:01 -0000
***************
*** 0 ****
--- 1,16 ----
+ // PR c++/12397
+ 
+ struct foo { }; 
+  
+ template <typename T> struct bar 
+ { 
+   bar(){} 
+   int i; 
+   bar (const bar<T>& foo) : i (foo.i) {} 
+ }; 
+  
+ int main() 
+ { 
+   bar<int> b1; 
+   bar<int> b2(b1); 
+ } 


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