Support bitfields in Wodr machinery (PR lto/85405).
authorMartin Liska <marxin@gcc.gnu.org>
Tue, 17 Apr 2018 05:41:40 +0000 (05:41 +0000)
committerMartin Liska <marxin@gcc.gnu.org>
Tue, 17 Apr 2018 05:41:40 +0000 (05:41 +0000)
2018-04-17  Jan Hubicka  <jh@suse.cz>

PR lto/85405
* ipa-devirt.c (odr_types_equivalent_p): Handle bit fields.
2018-04-17  Martin Liska  <mliska@suse.cz>

PR lto/85405
* g++.dg/lto/pr85405_0.C: New test.
* g++.dg/lto/pr85405_1.C: New test.

From-SVN: r259429

gcc/ChangeLog
gcc/ipa-devirt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lto/pr85405_0.C [new file with mode: 0644]
gcc/testsuite/g++.dg/lto/pr85405_1.C [new file with mode: 0644]

index a96c8decffc446000c73ad1832019df3a3599e6f..4ba0f0f57fa673b4d0b57ecb18485b2e7ed720f1 100644 (file)
@@ -1,3 +1,8 @@
+2018-04-17  Jan Hubicka  <jh@suse.cz>
+
+       PR lto/85405
+       * ipa-devirt.c (odr_types_equivalent_p): Handle bit fields.
+
 2018-04-17  Martin Liska  <mliska@suse.cz>
 
        PR ipa/85329
index fa9380cce80ecdeb5a9f06fbe727cf6fe1031594..5da0f72d14f3a65883c3a30d14c1bd3e39cf92b5 100644 (file)
@@ -1587,8 +1587,15 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
                                 "in another translation unit"));
                    return false;
                  }
-               gcc_assert (DECL_NONADDRESSABLE_P (f1)
-                           == DECL_NONADDRESSABLE_P (f2));
+               if (DECL_BIT_FIELD (f1) != DECL_BIT_FIELD (f2))
+                 {
+                   warn_odr (t1, t2, f1, f2, warn, warned,
+                             G_ ("one field is bitfield while other is not "));
+                   return false;
+                 }
+               else
+                 gcc_assert (DECL_NONADDRESSABLE_P (f1)
+                             == DECL_NONADDRESSABLE_P (f2));
              }
 
            /* If one aggregate has more fields than the other, they
index a7dd355e5a5af328c4c0a5e529d68c742fd29a90..23c519efcf1cb4dd07f88056abb94e8b0c37db83 100644 (file)
@@ -1,3 +1,9 @@
+2018-04-17  Martin Liska  <mliska@suse.cz>
+
+       PR lto/85405
+       * g++.dg/lto/pr85405_0.C: New test.
+       * g++.dg/lto/pr85405_1.C: New test.
+
 2018-04-17  Martin Liska  <mliska@suse.cz>
 
        PR ipa/85329
diff --git a/gcc/testsuite/g++.dg/lto/pr85405_0.C b/gcc/testsuite/g++.dg/lto/pr85405_0.C
new file mode 100644 (file)
index 0000000..1a41d81
--- /dev/null
@@ -0,0 +1,18 @@
+// { dg-lto-do link }
+// { dg-lto-options {{-fPIC -shared -flto}} }
+
+class VclReferenceBase { // { dg-lto-warning "7: type 'struct VclReferenceBase' violates the C\\+\\+ One Definition Rule" }
+  int mnRefCnt;
+  bool mbDisposed : 1;
+  virtual ~VclReferenceBase();
+};
+class a;
+class b {
+  a &e;
+  bool c();
+};
+class B {
+  VclReferenceBase d;
+};
+class a : B {};
+bool b::c() { return false; }
diff --git a/gcc/testsuite/g++.dg/lto/pr85405_1.C b/gcc/testsuite/g++.dg/lto/pr85405_1.C
new file mode 100644 (file)
index 0000000..7860618
--- /dev/null
@@ -0,0 +1,9 @@
+class VclReferenceBase {
+  int mnRefCnt;
+  bool mbDisposed;
+
+protected:
+  virtual ~VclReferenceBase();
+};
+class : VclReferenceBase {
+} a;