This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: array deduction
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: mark at codesourcery dot com
- Date: Fri, 13 Sep 2002 21:59:20 +0100
- Subject: [C++ PATCH]: array deduction
- Organization: Codesourcery LLC
Hi,
I've installed the attached obvious patch, which fixes an array deduction.
We'd fail to deduce that 'T const (&)[I]' would match 'int [4]' for instance.
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
2002-09-13 Nathan Sidwell <nathan@codesourcery.com>
* pt.c (unify, ARRAY_TYPE): Element type can be more qualified.
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.611
diff -c -3 -p -r1.611 pt.c
*** cp/pt.c 22 Aug 2002 23:22:53 -0000 1.611
--- cp/pt.c 13 Sep 2002 20:10:34 -0000
*************** unify (tparms, targs, parm, arg, strict)
*** 8921,8927 ****
TYPE_DOMAIN (arg), UNIFY_ALLOW_NONE) != 0)
return 1;
return unify (tparms, targs, TREE_TYPE (parm), TREE_TYPE (arg),
! UNIFY_ALLOW_NONE);
case REAL_TYPE:
case COMPLEX_TYPE:
--- 8921,8927 ----
TYPE_DOMAIN (arg), UNIFY_ALLOW_NONE) != 0)
return 1;
return unify (tparms, targs, TREE_TYPE (parm), TREE_TYPE (arg),
! strict & UNIFY_ALLOW_MORE_CV_QUAL);
case REAL_TYPE:
case COMPLEX_TYPE:
// { dg-do run }
// Copyright (C) 2002 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 13 Sep 2002 <nathan@codesourcery.com>
template <typename T> int Foo (T const *)
{
return 1;
}
template <typename T> int Foo (T const &)
{
return 2;
}
template <typename T, __SIZE_TYPE__ I> int Foo (T const (&ref)[I])
{
return 0;
}
int main ()
{
static int array[4] = {};
return Foo (array);
}