diff mbox

[C++] PR 71577 ("[6/7/8 regression] ICE on invalid C++11 code (with extra struct initializer): in digest_init_r...")

Message ID 0e71a2d6-ae7b-36dd-a9e5-c50c207f8a35@oracle.com
State New
Headers show

Commit Message

Paolo Carlini April 28, 2017, 10:58 a.m. UTC
Hi,

now that 7.1.0 is almost out of the door, I'm sending a few simple 
patches which I have been testing for a while in my trees. This one is 
about an error recovery regression: I think it's correct to handle it by 
simply returning unconditionally error_mark_node upon "too many 
initializers" error. Tested x86_64-linux.

Thanks, Paolo.

//////////////////
/cp
2017-04-28  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/71577
	* decl.c (reshape_init): Unconditionally return error_mark_node
	upon error about too many initializers.

/testsuite
2017-04-28  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/71577
	* g++.dg/cpp0x/pr71577.C: New.

Comments

Nathan Sidwell April 28, 2017, 2:34 p.m. UTC | #1
On 04/28/2017 06:58 AM, Paolo Carlini wrote:
> Hi,
> 
> now that 7.1.0 is almost out of the door, I'm sending a few simple 
> patches which I have been testing for a while in my trees. This one is 
> about an error recovery regression: I think it's correct to handle it by 
> simply returning unconditionally error_mark_node upon "too many 
> initializers" error. Tested x86_64-linux.

	PR c++/71577
	* decl.c (reshape_init): Unconditionally return error_mark_node
	upon error about too many initializers.

ok
diff mbox

Patch

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 247273)
+++ cp/decl.c	(working copy)
@@ -6118,8 +6118,7 @@  reshape_init (tree type, tree init, tsubst_flags_t
     {
       if (complain & tf_error)
 	error ("too many initializers for %qT", type);
-      else
-	return error_mark_node;
+      return error_mark_node;
     }
 
   if (CONSTRUCTOR_IS_DIRECT_INIT (init)
Index: testsuite/g++.dg/cpp0x/pr71577.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr71577.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/pr71577.C	(working copy)
@@ -0,0 +1,4 @@ 
+// PR c++/71577
+// { dg-do compile { target c++11 } }
+
+struct { int a; } s1, s2 = { s1, 0 };  // { dg-error "too many initializers" }