Commit b491c59f by Jason Merrill Committed by Jason Merrill

PR c++/86946 - ICE with function call in template argument.

DR 1321 clarified that two dependent names are equivalent if the names are
the same, even if the result of name lookup is different.  We need to
implement that in hashing like we already do in comparison and mangling.

	* pt.c (iterative_hash_template_arg) [CALL_EXPR]: Use
	dependent_name.

From-SVN: r270068
parent b33ef29f
2019-04-01 Jason Merrill <jason@redhat.com>
PR c++/86946 - ICE with function call in template argument.
DR 1321
* pt.c (iterative_hash_template_arg) [CALL_EXPR]: Use
dependent_name.
2019-04-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/62207
......
......@@ -1862,6 +1862,23 @@ iterative_hash_template_arg (tree arg, hashval_t val)
/* Now hash operands as usual. */
break;
case CALL_EXPR:
{
tree fn = CALL_EXPR_FN (arg);
if (tree name = dependent_name (fn))
{
if (TREE_CODE (fn) == TEMPLATE_ID_EXPR)
val = iterative_hash_template_arg (TREE_OPERAND (fn, 1), val);
fn = name;
}
val = iterative_hash_template_arg (fn, val);
call_expr_arg_iterator ai;
for (tree x = first_call_expr_arg (arg, &ai); x;
x = next_call_expr_arg (&ai))
val = iterative_hash_template_arg (x, val);
return val;
}
default:
break;
}
......
// PR c++/86946, DR 1321
// { dg-do compile { target c++11 } }
int d(int, int);
template <long> class e {};
template <unsigned long f, unsigned b, typename> e<sizeof(d(f, b))> d();
template <unsigned long f, unsigned b, typename> e<d(f, b)> d();
template <class T, class U> constexpr T d2(T, U) { return 42; }
template <unsigned long f, unsigned b, typename> e<d2(f, b)> d2();
template <unsigned long f, unsigned b, typename> e<d2(f, b)> d2();
template <typename a, typename c> a d3(a, c);
template <unsigned long f, unsigned b, typename> e<sizeof(d3(f, b))> d3();
template <unsigned long f, unsigned b, typename> e<sizeof(d3(f, b))> d3();
int main()
{
d<1,2,int>();
d2<1,2,int>();
d3<1,2,int>();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment