diff mbox series

[C++] PR 80449 ("[7/8 Regression] ICE reporting failed partial class template specialization class template argument deduction")

Message ID f1e5f6d4-0710-512c-ac5a-ae9a705b5661@oracle.com
State New
Headers show
Series [C++] PR 80449 ("[7/8 Regression] ICE reporting failed partial class template specialization class template argument deduction") | expand

Commit Message

Paolo Carlini Oct. 23, 2017, 8:36 p.m. UTC
Hi,

this issue is by and large a duplicate of C++/79790, which I already 
fixed. There is a minor remaining nit: for the testcase, after the correct:

     error: cannot deduce template arguments of ‘C<S>’, as it has no 
viable deduction guides

we also emit the meaningless:

     error: too many initializers for ‘<type error>’

only because in finish_compound_literal we don't check - as we do in 
most other places - the return value of do_auto_deduction for 
error_mark_node and it filters through until reshape_init. Tested 
x86_64-linux.

Thanks, Paolo.

////////////////////
/cp
2017-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/80449
	* semantics.c (finish_compound_literal): Check do_auto_deduction
	return value for error_mark_node.

/testsuite
2017-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/80449
	* g++.dg/cpp1z/class-deduction46.C: New.

Comments

Jason Merrill Oct. 23, 2017, 9:28 p.m. UTC | #1
OK.

On Mon, Oct 23, 2017 at 4:36 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> Hi,
>
> this issue is by and large a duplicate of C++/79790, which I already fixed.
> There is a minor remaining nit: for the testcase, after the correct:
>
>     error: cannot deduce template arguments of ‘C<S>’, as it has no viable
> deduction guides
>
> we also emit the meaningless:
>
>     error: too many initializers for ‘<type error>’
>
> only because in finish_compound_literal we don't check - as we do in most
> other places - the return value of do_auto_deduction for error_mark_node and
> it filters through until reshape_init. Tested x86_64-linux.
>
> Thanks, Paolo.
>
> ////////////////////
>
diff mbox series

Patch

Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 254005)
+++ cp/semantics.c	(working copy)
@@ -2711,8 +2711,12 @@  finish_compound_literal (tree type, tree compound_
 
   if (tree anode = type_uses_auto (type))
     if (CLASS_PLACEHOLDER_TEMPLATE (anode))
-      type = do_auto_deduction (type, compound_literal, anode, complain,
-				adc_variable_type);
+      {
+	type = do_auto_deduction (type, compound_literal, anode, complain,
+				  adc_variable_type);
+	if (type == error_mark_node)
+	  return error_mark_node;
+      }
 
   if (processing_template_decl)
     {
Index: testsuite/g++.dg/cpp1z/class-deduction46.C
===================================================================
--- testsuite/g++.dg/cpp1z/class-deduction46.C	(nonexistent)
+++ testsuite/g++.dg/cpp1z/class-deduction46.C	(working copy)
@@ -0,0 +1,6 @@ 
+// PR c++/80449
+// { dg-options -std=c++17 }
+
+template<class S> struct C;
+template<> struct C<int> { C(int, int) {} };
+auto k = C{0, 0};  // { dg-error "cannot deduce" }