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: Fix PR 11546


This patch fixes PR c++/11546 on the branch.  The problem is already
fixed on the mainline because the new parser takes responsibility for
figuring out what's a template and what's not, as it should.

Tested on i686-pc-linux-gnu.  Applied on the branch; test case applied
on the mainline.

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

2003-07-19  Mark Mitchell  <mark@codesourcery.com>

	PR c++/11546
	* pt.c (lookup_template_class): Treat TYPE_DECLs as TEMPLATE_DECLs
	where appropriate.

2003-07-19  Mark Mitchell  <mark@codesourcery.com>

	PR c++/11546
	* testsuite/g++.dg/template/lookup1.C: New test.

Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.635.2.34
diff -c -5 -p -r1.635.2.34 pt.c
*** cp/pt.c	14 Jul 2003 20:18:18 -0000	1.635.2.34
--- cp/pt.c	20 Jul 2003 04:39:35 -0000
*************** lookup_template_class (d1, arglist, in_d
*** 4085,4098 ****
  	  if (context)
  	    pop_decl_namespace ();
  	}
        if (template)
  	context = DECL_CONTEXT (template);
      }
    else if (TREE_CODE (d1) == TYPE_DECL && IS_AGGR_TYPE (TREE_TYPE (d1)))
      {
!       tree type = TREE_TYPE (d1);
  
        /* If we are declaring a constructor, say A<T>::A<T>, we will get
  	 an implicit typename for the second A.  Deal with it.  */
        if (TREE_CODE (type) == TYPENAME_TYPE && TREE_TYPE (type))
  	type = TREE_TYPE (type);
--- 4085,4108 ----
  	  if (context)
  	    pop_decl_namespace ();
  	}
        if (template)
  	context = DECL_CONTEXT (template);
+       if (template
+ 	  && TREE_CODE (template) == TYPE_DECL
+ 	  && IS_AGGR_TYPE (TREE_TYPE (template))
+ 	  && TREE_CODE (TREE_TYPE (template)) != TEMPLATE_TYPE_PARM)
+ 	{
+ 	  d1 = template;
+ 	  goto type_decl;
+ 	}
      }
    else if (TREE_CODE (d1) == TYPE_DECL && IS_AGGR_TYPE (TREE_TYPE (d1)))
      {
!       tree type;
!     type_decl:
!       type = TREE_TYPE (d1);
  
        /* If we are declaring a constructor, say A<T>::A<T>, we will get
  	 an implicit typename for the second A.  Deal with it.  */
        if (TREE_CODE (type) == TYPENAME_TYPE && TREE_TYPE (type))
  	type = TREE_TYPE (type);
Index: testsuite/g++.dg/template/lookup1.C
===================================================================
RCS file: testsuite/g++.dg/template/lookup1.C
diff -N testsuite/g++.dg/template/lookup1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/lookup1.C	20 Jul 2003 04:39:36 -0000
***************
*** 0 ****
--- 1,17 ----
+ template <class T0>
+ class A {
+ public:
+   class B;
+ };
+ 
+ template <class T0>
+ class A<T0>::B {
+ public:
+   class C;
+ };
+ 
+ template <class T0>
+ class A<T0>::B::C {
+ public:
+   A<T0> &a;
+ };


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