This is the mail archive of the gcc@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]

g++ Regression egcs-970901 -> 970904



Jody --

>>>>> "Jody" == Jody Goldberg <jodygold@sanwafp.COM> writes:

    Jody> 970904 generates : Internal compiler error 243.  970901
    Jody> doesn't

    Jody> -----------------------------------------------------
    Jody> template<int N_length> struct B { B(); ~B(); };
    Jody> template<class P, int N> struct D { D(int r0); D(B<N-1> &,
    Jody> int); }; template<class T> void func() { D<T,1> tmp; }

  Funny, I was just looking at a case like this.  I've appended a
patch, below.  I don't know how this worked in 970901.  Jason, does
this look like the right fix?  Was it 970904 with or without my
patches that crashed? 

-- 
Mark Mitchell		mmitchell@usa.net
Stanford University	http://www.stanford.edu

Index: pt.c
===================================================================
RCS file: /home/mitchell/Repository/egcs/gcc/cp/pt.c,v
retrieving revision 1.9
diff -c -p -r1.9 pt.c
*** pt.c	1997/09/08 16:41:27	1.9
--- pt.c	1997/09/08 18:50:56
*************** tsubst (t, args, nargs, in_decl)
*** 1624,1630 ****
        if (uses_template_parms (t))
	{
	  tree argvec = tsubst (CLASSTYPE_TI_ARGS (t), args, nargs,
in_decl);
!	  tree r = lookup_template_class (t, argvec, in_decl);
	  return cp_build_type_variant (r, TYPE_READONLY (t),
					TYPE_VOLATILE (t));
	}
--- 1624,1656 ----
        if (uses_template_parms (t))
	{
	  tree argvec = tsubst (CLASSTYPE_TI_ARGS (t), args, nargs,
in_decl);
!	  tree r;
!	  int i;
! 
!	  for (i = 0; i < TREE_VEC_LENGTH (argvec); ++i) 
!	    {
!	      if (TREE_CODE_CLASS (TREE_CODE (TREE_VEC_ELT (argvec,
i))) != 't'
!		  && !uses_template_parms (TREE_VEC_ELT (argvec, i)))
!		{
!		  /* Sometimes, one of the args was an expression
involving
!		     a template constant parameter, like N - 1.  Now
that
!		     we've tsubst'd, we might have something like 2 -
1.  This
!		     will confuse lookup_template_class, so we do
constant
!		     here.  We have to unset processing_template_decl,
to fool
!		     tsbust_expr() into building an actual tree. */
!		  int saved_processing_template_decl =
!		    processing_template_decl; 
!		  tree e;
! 
!		  processing_template_decl = 0;
!		  e = build_expr_from_tree (TREE_VEC_ELT (argvec, i));
!		  e = fold (e);
!		  TREE_VEC_ELT (argvec, i) = e;
!		  processing_template_decl =
saved_processing_template_decl; 
!		}
!	    }
! 
!	  r = lookup_template_class (t, argvec, in_decl);
	  return cp_build_type_variant (r, TYPE_READONLY (t),
					TYPE_VOLATILE (t));
	}
cvs diff: Diffing inc


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