re PR c++/17395 (Incorrect lookup for parameters)

2009-05-06  Dodji Seketeli  <dodji@redhat.com>

    gcc/cp/ChangeLog:
    	PR c++/17395
    	* pt.c (tsubst_copy) <case PARM_DECL>: We don't want to tsubst the
    	whole list of PARM_DECLs, just the current one.
    
    gcc/testsuite/ChangeLog:
    	PR c++/17395
    	* g++.dg/template/call7.C: New test.

From-SVN: r147202
This commit is contained in:
Dodji Seketeli 2009-05-06 20:43:41 +00:00 committed by Dodji Seketeli
parent 9e249cbac5
commit a968a68675
4 changed files with 35 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2009-05-06 Dodji Seketeli <dodji@redhat.com>
PR c++/17395
* pt.c (tsubst_copy) <case PARM_DECL>: We don't want to tsubst the
whole list of PARM_DECLs, just the current one.
2009-05-05 Jakub Jelinek <jakub@redhat.com>
PR c++/40013

View File

@ -9982,11 +9982,15 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
if (r == NULL)
{
tree c;
/* This can happen for a parameter name used later in a function
declaration (such as in a late-specified return type). Just
make a dummy decl, since it's only used for its type. */
gcc_assert (skip_evaluation);
r = tsubst_decl (t, args, complain);
/* We copy T because want to tsubst the PARM_DECL only,
not the following PARM_DECLs that are chained to T. */
c = copy_node (t);
r = tsubst_decl (c, args, complain);
/* Give it the template pattern as its context; its true context
hasn't been instantiated yet and this is good enough for
mangling. */

View File

@ -1,3 +1,8 @@
2009-05-06 Dodji Seketeli <dodji@redhat.com>
PR c++/17395
* g++.dg/template/call7.C: New test.
2009-05-06 H.J. Lu <hongjiu.lu@intel.com>
Backport from mainline:

View File

@ -0,0 +1,19 @@
// Contributed by Dodji Seketeli <dodji@redhat.com>
// Origin: PR c++/17395
// { dg-do "compile" }
template<int> struct X { };
void fu(int a, X<sizeof(a)>) { }
template<class T>
void bhar(T a, X<sizeof(a)>) { }
int
main()
{
int x;
X<sizeof(int)> y;
fu(x, y);
bhar(x, y);
}