public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Bug in coerce_template_parms (fixed patch)
@ 1998-03-17 13:29 Kriang Lerdsuwanakij
  0 siblings, 0 replies; only message in thread
From: Kriang Lerdsuwanakij @ 1998-03-17 13:29 UTC (permalink / raw)
  To: egcs; +Cc: martin

I think this patch is good now.  It passes all testcases include the new one
which can catch the bad memory access and bad use of tsubst.

Kriang

	* pt.c (coerce_template_parms): Correctly access 
	arguments inside TREE_VEC when NARGS < NPARMS.
	Don't call tsubst and friends if is_tmpl_parm is true.

diff -cprN gcc-stock-980315/cp/pt.c gcc-980317/cp/pt.c
*** gcc-stock-980315/cp/pt.c	Tue Mar 17 09:16:38 1998
--- gcc-980317/cp/pt.c	Tue Mar 17 12:54:18 1998
*************** coerce_template_parms (parms, arglist, i
*** 1951,1957 ****
  	  tree arg;
  	  tree parm = TREE_VEC_ELT (parms, i);
  
! 	  if (arglist)
  	    {
  	      arg = arglist;
  	      arglist = TREE_CHAIN (arglist);
--- 1951,1957 ----
  	  tree arg;
  	  tree parm = TREE_VEC_ELT (parms, i);
  
! 	  if (arglist && TREE_CODE (arglist) == TREE_LIST)
  	    {
  	      arg = arglist;
  	      arglist = TREE_CHAIN (arglist);
*************** coerce_template_parms (parms, arglist, i
*** 1961,1967 ****
  	      else
  		arg = TREE_VALUE (arg);
  	    }
! 	  else if (is_tmpl_parm && i < nargs)
  	    {
  	      arg = TREE_VEC_ELT (arglist, i);
  	      if (arg == error_mark_node)
--- 1961,1967 ----
  	      else
  		arg = TREE_VALUE (arg);
  	    }
! 	  else if (i < nargs)
  	    {
  	      arg = TREE_VEC_ELT (arglist, i);
  	      if (arg == error_mark_node)
*************** coerce_template_parms (parms, arglist, i
*** 1972,1977 ****
--- 1972,1980 ----
  	      my_friendly_assert (!require_all_arguments, 0);
  	      break;
  	    }
+ 	  else if (is_tmpl_parm)
+ 	    /* VEC is not in the form that can be handled by tsubst.  */
+ 	    arg = TREE_PURPOSE (parm);
  	  else if (TREE_CODE (TREE_VALUE (parm)) == TYPE_DECL)
  	    arg = tsubst (TREE_PURPOSE (parm), vec, in_decl);
  	  else
*************** coerce_template_parms (parms, arglist, i
*** 2096,2101 ****
--- 2099,2106 ----
  	}
        if (is_tmpl_parm)
  	{
+ 	  /* FIXME: add checks for default arguments and nontype template
+ 	     parameters here.  */
  	  if (requires_tmpl_type)
  	    {
  	      cp_error ("nested template template parameter not implemented");
diff -cprN gcc-stock-980315/testsuite/g++.old-deja/g++.pt/ttp45.C gcc-980317/testsuite/g++.old-deja/g++.pt/ttp45.C
*** gcc-stock-980315/testsuite/g++.old-deja/g++.pt/ttp45.C	Wed Dec 31 16:00:00 1969
--- gcc-980317/testsuite/g++.old-deja/g++.pt/ttp45.C	Tue Mar 17 12:55:36 1998
***************
*** 0 ****
--- 1,13 ----
+ template<class E, int i, class F, class G=int, int j=i, class H=E> class D
+ {
+ };
+ 
+ template<template<class,int,class,class> class D,class E> class C
+ {
+ 	D<E,2,char,bool>	d;
+ };
+ 
+ int main()
+ {
+ 	C<D,int> c;
+ }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-03-17 13:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-17 13:29 Bug in coerce_template_parms (fixed patch) Kriang Lerdsuwanakij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).