public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kriang Lerdsuwanakij <lerdsuwa@scf-fs.usc.edu>
To: egcs@cygnus.com
Cc: martin@mira.isdn.cs.tu-berlin.de
Subject: Re: Bug in coerce_template_parms (fixed patch)
Date: Tue, 17 Mar 1998 13:29:00 -0000	[thread overview]
Message-ID: <Pine.SV4.3.94.980317132239.17199A-100000@aludra.usc.edu> (raw)

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;
+ }


                 reply	other threads:[~1998-03-17 13:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.SV4.3.94.980317132239.17199A-100000@aludra.usc.edu \
    --to=lerdsuwa@scf-fs.usc.edu \
    --cc=egcs@cygnus.com \
    --cc=martin@mira.isdn.cs.tu-berlin.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).