diff mbox series

[C++] PR 84972 ("[6/7/8 Regression] ICE: tree check: expected class 'type', have 'exceptional' (error_mark)...")

Message ID 15cda01c-f6ca-9f33-f9fb-11d5b50b937b@oracle.com
State New
Headers show
Series [C++] PR 84972 ("[6/7/8 Regression] ICE: tree check: expected class 'type', have 'exceptional' (error_mark)...") | expand

Commit Message

Paolo Carlini March 21, 2018, 9:28 a.m. UTC
Hi,

as I told Marek in the audit trail, I'm working on a more complete patch 
consistently changing maybe_deduce_size_from_array_init for various 
error recovery issues (see the trail of c++/84632 too), but since this 
specific regression ultimately started with a previous change of mine 
and it's very simple I decided to send it now, for 8.1.0. Essentially, 
the idea is setting TREE_TYPE (decl) to error_mark_node - the normal 
error recovery mechanism in this function via cp_complete_array_type - 
also when the early check_array_designated_initializer fails.

Tested x86_64-linux, Paolo.

//////////////////////////
/cp
2018-03-21  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84972
	* decl.c (maybe_deduce_size_from_array_init): Set TREE_TYPE to
	error_mark_node when check_array_designated_initializer fails.

/testsuite
2018-03-21  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84972
	* g++.dg/ext/desig10.C: New.

Comments

Jason Merrill March 21, 2018, 5:52 p.m. UTC | #1
OK.

On Wed, Mar 21, 2018 at 5:28 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> Hi,
>
> as I told Marek in the audit trail, I'm working on a more complete patch
> consistently changing maybe_deduce_size_from_array_init for various error
> recovery issues (see the trail of c++/84632 too), but since this specific
> regression ultimately started with a previous change of mine and it's very
> simple I decided to send it now, for 8.1.0. Essentially, the idea is setting
> TREE_TYPE (decl) to error_mark_node - the normal error recovery mechanism in
> this function via cp_complete_array_type - also when the early
> check_array_designated_initializer fails.
>
> Tested x86_64-linux, Paolo.
>
> //////////////////////////
>
diff mbox series

Patch

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 258706)
+++ cp/decl.c	(working copy)
@@ -5467,7 +5467,9 @@  maybe_deduce_size_from_array_init (tree decl, tree
 	      failure = 1;
 	}
 
-      if (!failure)
+      if (failure)
+	TREE_TYPE (decl) = error_mark_node;
+      else
 	{
 	  failure = cp_complete_array_type (&TREE_TYPE (decl), initializer,
 					    do_default);
Index: testsuite/g++.dg/ext/desig10.C
===================================================================
--- testsuite/g++.dg/ext/desig10.C	(nonexistent)
+++ testsuite/g++.dg/ext/desig10.C	(working copy)
@@ -0,0 +1,4 @@ 
+// PR c++/84972
+// { dg-additional-options "-w" }
+
+char(a[])({.a = 0});  // { dg-error "designated initializer" }