Hi,
this issue is very easy to explain and the testcase minimal:
check_special_function_return_type ICEs on a TEMPLATE_TEMPLATE_PARM as
optype, because it tries to use CLASSTYPE_TI_TEMPLATE on it. Today,
triangulating with other compilers too, I came to believe that here
essentially we only have to provide sensible diagnostic and below is
what I'm finishing testing on x86_64-linux (what about an additional
inform using DECL_SOURCE_LOCATION (TYPE_STUB_DECL (optype))? I'm not
sure, the rest of the function emits quite terse messages).
Thanks! Paolo.
/////////////////////////
/cp
2018-02-15 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/82468
* decl.c (check_special_function_return_type): Reject template
template parameter in deduction guide.
/testsuite
2018-02-15 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/82468
* g++.dg/cpp1z/class-deduction47.C: New.
Index: cp/decl.c
===================================================================
--- cp/decl.c (revision 257712)
+++ cp/decl.c (working copy)
@@ -9834,7 +9834,14 @@ check_special_function_return_type (special_functi
error_at (smallest_type_quals_location (type_quals, locations),
"qualifiers are not allowed on declaration of "
"deduction guide");
- type = make_template_placeholder (CLASSTYPE_TI_TEMPLATE (optype));
+ if (TREE_CODE (optype) == TEMPLATE_TEMPLATE_PARM)
+ {
+ error ("template template parameter %qT in declaration of "
+ "deduction guide", optype);
+ type = error_mark_node;
+ }
+ else
+ type = make_template_placeholder (CLASSTYPE_TI_TEMPLATE (optype));
for (int i = 0; i < ds_last; ++i)
if (i != ds_explicit && locations[i])
error_at (locations[i],
Index: testsuite/g++.dg/cpp1z/class-deduction47.C
===================================================================
--- testsuite/g++.dg/cpp1z/class-deduction47.C (nonexistent)
+++ testsuite/g++.dg/cpp1z/class-deduction47.C (working copy)
@@ -0,0 +1,5 @@
+// PR c++/82468
+// { dg-options -std=c++17 }
+
+template <template <class> class TT>
+TT(double) -> TT<int>; // { dg-error "template template" }