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]

[C++ PATCH] fix bugs 59 & 79


Hi,
I've installed the attached patch under the obvious rule.
It fixes a deduction failure where a non-type template parameter
is based on an earlier type template parm. Before comparison to
an argument, it must be tsubst'd. This fixes bugs 59 and 79.

Also changed an obfustcated switch into an if.

built & tested on i686-pc-linux-gnu

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-09-06  Nathan Sidwell  <nathan@codesourcery.com>

	* pt.c (type_unification_real): Replace switch with if.
	(unify): Tsubst non-type parms before comparing.

Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/pt.c,v
retrieving revision 1.464
diff -c -3 -p -r1.464 pt.c
*** pt.c	2000/09/05 07:31:27	1.464
--- pt.c	2000/09/06 08:29:30
*************** type_unification_real (tparms, targs, pa
*** 7830,7842 ****
        if (!subr)
  	maybe_adjust_types_for_deduction (strict, &parm, &arg);
  
!       switch (unify (tparms, targs, parm, arg, sub_strict))
! 	{
! 	case 0:
! 	  break;
! 	case 1:
! 	  return 1;
! 	}
      }
    /* Fail if we've reached the end of the parm list, and more args
       are present, and the parm list isn't variadic.  */
--- 7830,7837 ----
        if (!subr)
  	maybe_adjust_types_for_deduction (strict, &parm, &arg);
  
!       if (unify (tparms, targs, parm, arg, sub_strict))
!         return 1;
      }
    /* Fail if we've reached the end of the parm list, and more args
       are present, and the parm list isn't variadic.  */
*************** unify (tparms, targs, parm, arg, strict)
*** 8450,8457 ****
  	 parameter-list and, if the corresponding template-argument is
  	 deduced, the template-argument type shall match the type of the
  	 template-parameter exactly, except that a template-argument
! 	 deduced from an array bound may be of any integral type.  */
!       if (same_type_p (TREE_TYPE (arg), TREE_TYPE (parm)))
  	/* OK */;
        else if ((strict & UNIFY_ALLOW_INTEGER)
  	       && (TREE_CODE (TREE_TYPE (parm)) == INTEGER_TYPE
--- 8445,8454 ----
  	 parameter-list and, if the corresponding template-argument is
  	 deduced, the template-argument type shall match the type of the
  	 template-parameter exactly, except that a template-argument
! 	 deduced from an array bound may be of any integral type. 
! 	 The non-type parameter might use already deduced type parameters.  */
!       if (same_type_p (TREE_TYPE (arg),
!                        tsubst (TREE_TYPE (parm), targs, 0, NULL_TREE)))
  	/* OK */;
        else if ((strict & UNIFY_ALLOW_INTEGER)
  	       && (TREE_CODE (TREE_TYPE (parm)) == INTEGER_TYPE
// Build don't link:
// 
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 5 Sept 2000 <nathan@codesourcery.com>

// bug 79 & 59. We failed to tsubst non-type template parms which used
// (previously deduced) type parms.

struct C {};  

template< class T, T *G > struct S {};
template< class T, T *G > void boz ( S<T,G> s1);

C c1Gen;

void foo ()
{
  S< C, &c1Gen > s1;

  boz (s1);
}

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