From e299d4fc1a9a3d30ed9c1b7df743b2fd84c9f03a Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 21 Mar 2018 21:19:03 +0000 Subject: [PATCH] re PR c++/84972 (ICE: tree check: expected class 'type', have 'exceptional' (error_mark) in extended_tree, at tree.h:5545) /cp 2018-03-21 Paolo Carlini 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 PR c++/84972 * g++.dg/ext/desig10.C: New. From-SVN: r258746 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 4 +++- gcc/testsuite/ChangeLog | 7 ++++++- gcc/testsuite/g++.dg/ext/desig10.C | 4 ++++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/desig10.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fd2f371e836..aa8ba26959b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-03-21 Paolo Carlini + + 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 PR c++/84961 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5f181a5da72..0aa4ac20b53 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cc81884b4f3..4c88b114fb3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ +2018-03-21 Paolo Carlini + + PR c++/84972 + * g++.dg/ext/desig10.C: New. + 2018-03-21 Thomas Koenig - Harald Anlauf + Harald Anlauf 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 index 00000000000..24057dd0ad6 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/desig10.C @@ -0,0 +1,4 @@ +// PR c++/84972 +// { dg-additional-options "-w" } + +char(a[])({.a = 0}); // { dg-error "designated initializer" } -- 2.30.2