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]

Patch



Todd --

  Here's a patch (to be applied after the patches I have already
sent) that fixes the remaining bugs in your giant Blitz++ testcase.
(The file you sent me contained one "using" directive, which had to be
removed since g++ doesn't yet support namespaces.)

  Here's the output of your program, which looks right to me:

supernova% ./a.out
B = 4 x 4
      0.55      0.35      0.85      0.25
      0.15      0.35      0.25      0.95
      0.05      0.05      0.75      0.45
      0.25      0.35      0.85      0.45

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

Mon Sep  8 01:21:43 1997  Mark Mitchell  <mmitchell@usa.net>

	* pt.c (coerce_template_parms): Avoid looking at the
	TYPE_LANG_DECL portion of a typename type, since there won't be
	one. 
	(tsubst): Do constant folding as necessary to make sure that
	arguments passed to lookup_template_class really are constants. 
	(tsubst): Do not attempt to make a typename type when the context
	is a template parm; it will be impossible to lookup the member
	type. 

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 21:24:18
*************** coerce_template_parms (parms, arglist, i
*** 658,664 ****
  	  if (! processing_template_decl)
  	    {
  	      tree t = target_type (val);
! 	      if (IS_AGGR_TYPE (t)
  		  && decl_function_context (TYPE_MAIN_DECL (t)))
  		{
  		  cp_error ("type `%T' composed from a local class is not a valid template-argument", val);
--- 658,665 ----
  	  if (! processing_template_decl)
  	    {
  	      tree t = target_type (val);
! 	      if (TREE_CODE (t) != TYPENAME_TYPE 
! 		  && IS_AGGR_TYPE (t)
  		  && decl_function_context (TYPE_MAIN_DECL (t)))
  		{
  		  cp_error ("type `%T' composed from a local class is not a valid template-argument", val);
*************** 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));
  	}
--- 1625,1659 ----
        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 folding here.  We have to unset
! 		     processing_template_decl, to fool
! 		     build_expr_from_tree() 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));
  	}
*************** tsubst (t, args, nargs, in_decl)
*** 2253,2262 ****
      case TYPENAME_TYPE:
        {
  	tree ctx = tsubst (TYPE_CONTEXT (t), args, nargs, in_decl);
! 	tree f = make_typename_type (ctx, TYPE_IDENTIFIER (t));
! 	return cp_build_type_variant
! 	  (f, TYPE_READONLY (f) || TYPE_READONLY (t),
! 	   TYPE_VOLATILE (f) || TYPE_VOLATILE (t));
        }
  
      case INDIRECT_REF:
--- 2282,2296 ----
      case TYPENAME_TYPE:
        {
  	tree ctx = tsubst (TYPE_CONTEXT (t), args, nargs, in_decl);
! 	if (TREE_CODE (ctx) != TEMPLATE_TYPE_PARM)
! 	  {
! 	    tree f = make_typename_type (ctx, TYPE_IDENTIFIER (t));
! 	    return cp_build_type_variant
! 	      (f, TYPE_READONLY (f) || TYPE_READONLY (t),
! 	       TYPE_VOLATILE (f) || TYPE_VOLATILE (t));
! 	  }
! 	else
! 	  return t;
        }
  
      case INDIRECT_REF:


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