From: Martin Liska Date: Tue, 22 May 2018 10:50:43 +0000 (+0200) Subject: Do not ICE for incomplete types in ICF (PR ipa/85607). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a6df9d9044965e3a265ead57bc516a450ad87bf6;p=gcc.git Do not ICE for incomplete types in ICF (PR ipa/85607). 2018-05-22 Martin Liska PR ipa/85607 * ipa-icf.c (sem_item::add_type): Do not ICE for incomplete types. 2018-05-22 Martin Liska PR ipa/85607 * g++.dg/ipa/pr85607.C: New test. From-SVN: r260502 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c3ecb0be3a2..5ef5cbae541 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-05-22 Martin Liska + + PR ipa/85607 + * ipa-icf.c (sem_item::add_type): Do not ICE for incomplete types. + 2018-05-22 Richard Biener PR tree-optimization/85863 diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index f974d9f769f..37e63fc2ba8 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -1580,7 +1580,13 @@ sem_item::add_type (const_tree type, inchash::hash &hstate) } else if (RECORD_OR_UNION_TYPE_P (type)) { - gcc_checking_assert (COMPLETE_TYPE_P (type)); + /* Incomplete types must be skipped here. */ + if (!COMPLETE_TYPE_P (type)) + { + hstate.add_int (RECORD_TYPE); + return; + } + hashval_t *val = optimizer->m_type_hash_cache.get (type); if (!val) @@ -1591,8 +1597,6 @@ sem_item::add_type (const_tree type, inchash::hash &hstate) hashval_t hash; hstate2.add_int (RECORD_TYPE); - gcc_assert (COMPLETE_TYPE_P (type)); - for (f = TYPE_FIELDS (type), nf = 0; f; f = TREE_CHAIN (f)) if (TREE_CODE (f) == FIELD_DECL) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 939702c3187..0f109eb4a53 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-05-22 Martin Liska + + PR ipa/85607 + * g++.dg/ipa/pr85607.C: New test. + 2018-05-22 Richard Biener PR tree-optimization/85863 diff --git a/gcc/testsuite/g++.dg/ipa/pr85607.C b/gcc/testsuite/g++.dg/ipa/pr85607.C new file mode 100644 index 00000000000..b47aba2167d --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr85607.C @@ -0,0 +1,14 @@ +// { dg-do compile } +/* { dg-options "-O2" } */ + +class A; // { dg-message "forward declaration of 'class A'" } + +A *a; // { dg-warning "'a' has incomplete type" } + +int +main (int argc, char **argv) +{ + delete a; // { dg-warning "delete" "warn" } + // { dg-message "note" "note" { target *-*-* } .-1 } + return 0; +}