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.carl...@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.carl...@oracle.com>
PR c++/84972
* g++.dg/ext/desig10.C: New.
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" }