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.
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:
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:
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.
--- /dev/null
+// 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;
+ }
+};
+