re PR c++/47904 (ICE with DECL_PARM_INDEX (this) in cp_tree_equal)
PR c++/47904 * tree.c (cp_tree_equal): Compare DECL_PARM_LEVEL. * pt.c (iterative_hash_template_arg): And hash it. From-SVN: r170533
This commit is contained in:
parent
acfd3fffee
commit
e7dc5734a8
5 changed files with 46 additions and 7 deletions
|
@ -1,5 +1,9 @@
|
|||
2011-02-26 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/47904
|
||||
* tree.c (cp_tree_equal): Compare DECL_PARM_LEVEL.
|
||||
* pt.c (iterative_hash_template_arg): And hash it.
|
||||
|
||||
PR c++/47897
|
||||
* semantics.c (non_const_var_error): Split out from...
|
||||
(cxx_eval_constant_expression): ...here.
|
||||
|
|
|
@ -1533,7 +1533,10 @@ iterative_hash_template_arg (tree arg, hashval_t val)
|
|||
|
||||
case PARM_DECL:
|
||||
if (!DECL_ARTIFICIAL (arg))
|
||||
val = iterative_hash_object (DECL_PARM_INDEX (arg), val);
|
||||
{
|
||||
val = iterative_hash_object (DECL_PARM_INDEX (arg), val);
|
||||
val = iterative_hash_object (DECL_PARM_LEVEL (arg), val);
|
||||
}
|
||||
return iterative_hash_template_arg (TREE_TYPE (arg), val);
|
||||
|
||||
case TARGET_EXPR:
|
||||
|
|
|
@ -2154,12 +2154,19 @@ cp_tree_equal (tree t1, tree t2)
|
|||
|
||||
case PARM_DECL:
|
||||
/* For comparing uses of parameters in late-specified return types
|
||||
with an out-of-class definition of the function. */
|
||||
if (same_type_p (TREE_TYPE (t1), TREE_TYPE (t2))
|
||||
&& DECL_PARM_INDEX (t1) == DECL_PARM_INDEX (t2))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
with an out-of-class definition of the function, but can also come
|
||||
up for expressions that involve 'this' in a member function
|
||||
template. */
|
||||
if (same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
|
||||
{
|
||||
if (DECL_ARTIFICIAL (t1) ^ DECL_ARTIFICIAL (t2))
|
||||
return false;
|
||||
if (DECL_ARTIFICIAL (t1)
|
||||
|| (DECL_PARM_LEVEL (t1) == DECL_PARM_LEVEL (t2)
|
||||
&& DECL_PARM_INDEX (t1) == DECL_PARM_INDEX (t2)))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
case VAR_DECL:
|
||||
case CONST_DECL:
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
2011-02-26 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* g++.dg/template/this-targ1.C: New.
|
||||
|
||||
* g++.dg/cpp0x/regress/template-const1.C: New.
|
||||
* g++.dg/cpp0x/regress/template-function1.C: Adjust.
|
||||
* g++.dg/template/function1.C: Adjust.
|
||||
|
|
23
gcc/testsuite/g++.dg/template/this-targ1.C
Normal file
23
gcc/testsuite/g++.dg/template/this-targ1.C
Normal file
|
@ -0,0 +1,23 @@
|
|||
// PR c++/47904
|
||||
|
||||
template <bool>
|
||||
struct S
|
||||
{
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class U
|
||||
{
|
||||
T t;
|
||||
int foo () const
|
||||
{
|
||||
S <sizeof (t) == 1> s;
|
||||
return 1;
|
||||
}
|
||||
int bar () const
|
||||
{
|
||||
S <sizeof (t) == 1> s;
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
Loading…
Add table
Reference in a new issue