diff options
author | Martin Liska <mliska@suse.cz> | 2018-05-22 12:50:43 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2018-05-22 10:50:43 +0000 |
commit | a6df9d9044965e3a265ead57bc516a450ad87bf6 (patch) | |
tree | 99721d9fc15d919307a2430eef9cd7dbb11042a7 | |
parent | 4515e413cb72d3a71b41d3e85da1be03fa88677d (diff) | |
download | gcc-a6df9d9044965e3a265ead57bc516a450ad87bf6.zip gcc-a6df9d9044965e3a265ead57bc516a450ad87bf6.tar.gz gcc-a6df9d9044965e3a265ead57bc516a450ad87bf6.tar.bz2 |
Do not ICE for incomplete types in ICF (PR ipa/85607).
2018-05-22 Martin Liska <mliska@suse.cz>
PR ipa/85607
* ipa-icf.c (sem_item::add_type): Do not ICE for incomplete types.
2018-05-22 Martin Liska <mliska@suse.cz>
PR ipa/85607
* g++.dg/ipa/pr85607.C: New test.
From-SVN: r260502
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ipa-icf.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ipa/pr85607.C | 14 |
4 files changed, 31 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c3ecb0b..5ef5cba 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-05-22 Martin Liska <mliska@suse.cz> + + PR ipa/85607 + * ipa-icf.c (sem_item::add_type): Do not ICE for incomplete types. + 2018-05-22 Richard Biener <rguenther@suse.de> PR tree-optimization/85863 diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index f974d9f..37e63fc 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 939702c..0f109eb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-05-22 Martin Liska <mliska@suse.cz> + + PR ipa/85607 + * g++.dg/ipa/pr85607.C: New test. + 2018-05-22 Richard Biener <rguenther@suse.de> 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 0000000..b47aba2 --- /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; +} |