Hi.

It's removal of an assert at place where we calculate hash of a type.
For incomplete types, let's skip it.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Martin


gcc/ChangeLog:

2018-05-09  Martin Liska  <mli...@suse.cz>

        PR ipa/85607
        * ipa-icf.c (sem_item::add_type): Do not ICE for incomplete types.

gcc/testsuite/ChangeLog:

2018-05-09  Martin Liska  <mli...@suse.cz>

        PR ipa/85607
        * g++.dg/ipa/pr85606.C: New test.
---
 gcc/ipa-icf.c                      |  5 ++++-
 gcc/testsuite/g++.dg/ipa/pr85606.C | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/ipa/pr85606.C


diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index f974d9f769f..7ecd0380fb7 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -1580,7 +1580,10 @@ 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))
+	return;
+
       hashval_t *val = optimizer->m_type_hash_cache.get (type);
 
       if (!val)
diff --git a/gcc/testsuite/g++.dg/ipa/pr85606.C b/gcc/testsuite/g++.dg/ipa/pr85606.C
new file mode 100644
index 00000000000..b47aba2167d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr85606.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;
+}

Reply via email to