* pt.c (unify): Allow COMPOUND_LITERAL_P in a non-deduced context.
* g++.dg/cpp0x/nondeduced1.C: New test.
* g++.dg/cpp0x/nondeduced2.C: New test.
* g++.dg/cpp0x/nondeduced3.C: New test.
* g++.dg/cpp0x/nondeduced4.C: New test.
From-SVN: r272571
2019-06-21 Marek Polacek <polacek@redhat.com>
+ PR c++/60223 - ICE with T{} in non-deduced context.
+ * pt.c (unify): Allow COMPOUND_LITERAL_P in a non-deduced context.
+
PR c++/64235 - missing syntax error with invalid alignas.
* parser.c (cp_parser_std_attribute_spec): Commit to tentative parse
if there's a missing close paren.
/* An unresolved overload is a nondeduced context. */
if (is_overloaded_fn (parm) || type_unknown_p (parm))
return unify_success (explain_p);
- gcc_assert (EXPR_P (parm) || TREE_CODE (parm) == TRAIT_EXPR);
+ gcc_assert (EXPR_P (parm)
+ || COMPOUND_LITERAL_P (parm)
+ || TREE_CODE (parm) == TRAIT_EXPR);
expr:
/* We must be looking at an expression. This can happen with
something like:
template <int I>
void foo(S<I>, S<I + 2>);
- This is a "nondeduced context":
+ or
+
+ template<typename T>
+ void foo(A<T, T{}>);
+
+ This is a "non-deduced context":
[deduct.type]
- The nondeduced contexts are:
+ The non-deduced contexts are:
- --A type that is a template-id in which one or more of
- the template-arguments is an expression that references
- a template-parameter.
+ --A non-type template argument or an array bound in which
+ a subexpression references a template parameter.
In these cases, we assume deduction succeeded, but don't
actually infer any unifications. */
-2019-06-19 Marek Polacek <polacek@redhat.com>
+2019-06-21 Marek Polacek <polacek@redhat.com>
+
+ PR c++/60223 - ICE with T{} in non-deduced context.
+ * g++.dg/cpp0x/nondeduced1.C: New test.
+ * g++.dg/cpp0x/nondeduced2.C: New test.
+ * g++.dg/cpp0x/nondeduced3.C: New test.
+ * g++.dg/cpp0x/nondeduced4.C: New test.
PR c++/64235 - missing syntax error with invalid alignas.
* g++.dg/parse/alignas1.C: New test.
--- /dev/null
+// PR c++/60223
+// { dg-do compile { target c++11 } }
+
+template<typename T, T = T{}>
+struct A { };
+
+template<typename T>
+void foo(A<T> a);
+
+void bar()
+{
+ foo(A<char, char{}>());
+ foo(A<char>());
+ foo<>(A<char>());
+ foo<>(A<char, char{}>());
+}
--- /dev/null
+// PR c++/60223
+// { dg-do compile { target c++11 } }
+
+template<typename T, T>
+struct A { };
+
+template<typename T>
+void foo(A<T, T{}>);
+
+void bar()
+{
+ foo(A<char, char{}>());
+ foo<>(A<char, char{}>());
+}
--- /dev/null
+// PR c++/60223
+// { dg-do compile { target c++11 } }
+
+template<typename T, T = T{1}>
+struct A { };
+
+template<typename T>
+void foo(A<T> a);
+
+void bar()
+{
+ foo(A<char>());
+ foo(A<char, char{1}>());
+ foo<>(A<char>());
+ foo<>(A<char, char{1}>());
+}
--- /dev/null
+// PR c++/60223
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+struct A { };
+
+template<typename T>
+void foo(A<T>, T = T{});
+
+void bar()
+{
+ foo(A<int>());
+}