Hi,
sorry for taking so long to get to this.  This patch fixes the ICE which
happens when we try to output warning about anonymous type.
As Jason explains in the PR log the warning is correct and I think we
should warn at compile time when parsing 
$ cat 2.ii
extern "C" {
struct {
} admbaserest_;
}
as there seems to be no way to use admbaserest_ from other translation
unit in standard conforming way?

Honza

        PR lto/91222
        * ipa-devirt.c (warn_types_mismatch): Do not ICE when anonymous type
        is matched with non-C++ type
        * g++.dg/lto/odr-6_0.C: New testcase.
        * g++.dg/lto/odr-6_1.c: New testcase.
Index: ipa-devirt.c
===================================================================
--- ipa-devirt.c        (revision 276272)
+++ ipa-devirt.c        (working copy)
@@ -992,14 +992,14 @@ warn_types_mismatch (tree t1, tree t2, l
          std::swap (t1, t2);
          std::swap (loc_t1, loc_t2);
        }
-      gcc_assert (TYPE_NAME (t1) && TYPE_NAME (t2)
-                 && TREE_CODE (TYPE_NAME (t1)) == TYPE_DECL
-                 && TREE_CODE (TYPE_NAME (t2)) == TYPE_DECL);
+      gcc_assert (TYPE_NAME (t1)
+                 && TREE_CODE (TYPE_NAME (t1)) == TYPE_DECL);
       tree n1 = TYPE_NAME (t1);
-      tree n2 = TYPE_NAME (t2);
+      tree n2 = TYPE_NAME (t2) ? TYPE_NAME (t2) : NULL;
+
       if (TREE_CODE (n1) == TYPE_DECL)
        n1 = DECL_NAME (n1);
-      if (TREE_CODE (n2) == TYPE_DECL)
+      if (n2 && TREE_CODE (n2) == TYPE_DECL)
        n2 = DECL_NAME (n2);
       /* Most of the time, the type names will match, do not be unnecesarily
          verbose.  */
Index: testsuite/g++.dg/lto/odr-6_0.C
===================================================================
--- testsuite/g++.dg/lto/odr-6_0.C      (nonexistent)
+++ testsuite/g++.dg/lto/odr-6_0.C      (working copy)
@@ -0,0 +1,8 @@
+// { dg-lto-do link }
+extern "C" {
+struct {  // { dg-lto-message "" 2 }
+} admbaserest_;
+}
+int main()
+{
+}
Index: testsuite/g++.dg/lto/odr-6_1.c
===================================================================
--- testsuite/g++.dg/lto/odr-6_1.c      (nonexistent)
+++ testsuite/g++.dg/lto/odr-6_1.c      (working copy)
@@ -0,0 +1,4 @@
+struct {} admbaserest_; // { dg-lto-message "type of " 2 }
+
+
+

Reply via email to