diff mbox series

[C++] PR 82468 ("[7/8 Regression] ICE with deduction guide template")

Message ID b19c1f5f-3583-2a20-c543-4d83429a2fb6@oracle.com
State New
Headers show
Series [C++] PR 82468 ("[7/8 Regression] ICE with deduction guide template") | expand

Commit Message

Paolo Carlini Feb. 15, 2018, 10:56 p.m. UTC
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.carlini@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.carlini@oracle.com>

	PR c++/82468
	* g++.dg/cpp1z/class-deduction47.C: New.

Comments

Jason Merrill Feb. 16, 2018, 1:55 p.m. UTC | #1
On Thu, Feb 15, 2018 at 5:56 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> 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).

No need for an inform, I think.  The patch is OK.
diff mbox series

Patch

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" }