re PR c++/84972 (ICE: tree check: expected class 'type', have 'exceptional' (error_ma...
authorPaolo Carlini <paolo@gcc.gnu.org>
Wed, 21 Mar 2018 21:19:03 +0000 (21:19 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 21 Mar 2018 21:19:03 +0000 (21:19 +0000)
/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.

From-SVN: r258746

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/desig10.C [new file with mode: 0644]

index fd2f371e836f56630e0c3b419d017f25738ef9ab..aa8ba26959b9195811bd0cf473403a5759b3b51c 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2018-03-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/84961
index 5f181a5da723f49bda203822a35d443342393a73..0aa4ac20b53bbb76b181715e1e90b07a10204531 100644 (file)
@@ -5467,7 +5467,9 @@ maybe_deduce_size_from_array_init (tree decl, tree init)
              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 cc81884b4f3a5bba08baf04b7af0f3c92fad977c..4c88b114fb371b516632dd08dc0b39882582824e 100644 (file)
@@ -1,5 +1,10 @@
+2018-03-21  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84972
+       * g++.dg/ext/desig10.C: New.
+
 2018-03-21  Thomas Koenig  <tkoenig@gcc.gnu.org>
-       Harald Anlauf  <anlauf@gmx.de>
+           Harald Anlauf  <anlauf@gmx.de>
 
        PR fortran/84957
        * gfortran.dg/pr84957.f90: New test.
diff --git a/gcc/testsuite/g++.dg/ext/desig10.C b/gcc/testsuite/g++.dg/ext/desig10.C
new file mode 100644 (file)
index 0000000..24057dd
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/84972
+// { dg-additional-options "-w" }
+
+char(a[])({.a = 0});  // { dg-error "designated initializer" }