+2018-12-13 Marek Polacek <polacek@redhat.com>
+
+ PR c++/88216 - ICE with class type in non-type template parameter.
+ * mangle.c (write_expression): Handle TARGET_EXPR and
+ VIEW_CONVERT_EXPR.
+ * pt.c (convert_nontype_argument): Don't call
+ get_template_parm_object for value-dependent expressions.
+
2018-12-13 Nathan Sidwell <nathan@acm.org>
PR c++/87531
{
enum tree_code code = TREE_CODE (expr);
+ if (TREE_CODE (expr) == TARGET_EXPR)
+ {
+ expr = TARGET_EXPR_INITIAL (expr);
+ code = TREE_CODE (expr);
+ }
+
/* Skip NOP_EXPR and CONVERT_EXPR. They can occur when (say) a pointer
argument is converted (via qualification conversions) to another type. */
while (CONVERT_EXPR_CODE_P (code)
|| location_wrapper_p (expr)
/* Parentheses aren't mangled. */
|| code == PAREN_EXPR
- || code == NON_LVALUE_EXPR)
+ || code == NON_LVALUE_EXPR
+ || (code == VIEW_CONVERT_EXPR
+ && TREE_CODE (TREE_OPERAND (expr, 0)) == TEMPLATE_PARM_INDEX))
{
expr = TREE_OPERAND (expr, 0);
code = TREE_CODE (expr);
{
/* Replace the argument with a reference to the corresponding template
parameter object. */
- expr = get_template_parm_object (expr, complain);
+ if (!value_dependent_expression_p (expr))
+ expr = get_template_parm_object (expr, complain);
if (expr == error_mark_node)
return NULL_TREE;
}
+2018-12-13 Marek Polacek <polacek@redhat.com>
+
+ PR c++/88216 - ICE with class type in non-type template parameter.
+ * g++.dg/cpp2a/nontype-class9.C: New test.
+
2018-12-13 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/88416
--- /dev/null
+// PR c++/88216
+// { dg-do compile { target c++2a } }
+
+template <class T, class U> struct same;
+template <class T> struct same<T,T> {};
+
+struct T { };
+
+template <T t>
+struct U { };
+
+template <T t>
+void f (U<t>)
+{
+ same<T,decltype(t)> s;
+ same<const T&,decltype((t))> s2;
+}
+
+template<T t>
+U<t> u;
+
+T t;
+U<t> u2;
+
+void
+g ()
+{
+ f<t>(u2);
+}