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]

PATCH for crash on nested templates (crash11.C)



Jason --

  Here's a patch to avoid a crash.  OK?

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com

1998-06-30  Mark Mitchell  <mark@markmitchell.com>

	* pt.c (push_template_decl_real): Don't look at DECL_TEMPLATE_INFO
	for TYPE_DECLs.

Index: testsuite/g++.old-deja/g++.pt/crash11.C
===================================================================
RCS file: crash11.C
diff -N crash11.C
*** /dev/null	Mon Dec 31 20:00:00 1979
--- crash11.C	Wed Jul  1 16:17:43 1998
***************
*** 0 ****
--- 1,13 ----
+ // Build don't link:
+ 
+ class A
+ {
+       class A_impl;
+    public: 
+       A(){}
+ };
+ 
+ 
+ template <class j> class A::A_impl 
+ { // ERROR - does not declare a template
+ };
Index: cp/pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.159
diff -c -p -r1.159 pt.c
*** pt.c	1998/06/25 03:28:33	1.159
--- pt.c	1998/07/01 23:18:05
*************** push_template_decl_real (decl, is_friend
*** 1808,1815 ****
        if (CLASSTYPE_TEMPLATE_INSTANTIATION (ctx))
  	cp_error ("must specialize `%#T' before defining member `%#D'",
  		  ctx, decl);
!       if (TREE_CODE (decl) == TYPE_DECL && DECL_ARTIFICIAL (decl))
! 	tmpl = CLASSTYPE_TI_TEMPLATE (TREE_TYPE (decl));
        else if (! DECL_TEMPLATE_INFO (decl))
  	{
  	  cp_error ("template definition of non-template `%#D'", decl);
--- 1808,1825 ----
        if (CLASSTYPE_TEMPLATE_INSTANTIATION (ctx))
  	cp_error ("must specialize `%#T' before defining member `%#D'",
  		  ctx, decl);
!       if (TREE_CODE (decl) == TYPE_DECL)
! 	{
! 	  if (IS_AGGR_TYPE_CODE (TREE_CODE (TREE_TYPE (decl)))
! 	      && CLASSTYPE_TEMPLATE_INFO (TREE_TYPE (decl))
! 	      && CLASSTYPE_TI_TEMPLATE (TREE_TYPE (decl)))
! 	    tmpl = CLASSTYPE_TI_TEMPLATE (TREE_TYPE (decl));
! 	  else
! 	    {
! 	      cp_error ("`%D' does not declare a template type", decl);
! 	      return decl;
! 	    }
! 	}
        else if (! DECL_TEMPLATE_INFO (decl))
  	{
  	  cp_error ("template definition of non-template `%#D'", decl);


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