re PR lto/78472 (warning: type of 's' does not match original declaration from zero...
authorRichard Biener <rguenther@suse.de>
Wed, 23 Nov 2016 11:24:55 +0000 (11:24 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 23 Nov 2016 11:24:55 +0000 (11:24 +0000)
2016-11-23  Richard Biener  <rguenther@suse.de>

PR lto/78472
* tree.c (gimple_canonical_types_compatible_p): Ignore zero-sized
fields.

lto/
* lto.c (hash_canonical_type): Ignore zero-sized fields.

* g++.dg/lto/pr78472_0.c: New testcase.
* g++.dg/lto/pr78472_1.C: Likewise.

From-SVN: r242746

gcc/ChangeLog
gcc/lto/ChangeLog
gcc/lto/lto.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lto/pr78472_0.c [new file with mode: 0644]
gcc/testsuite/g++.dg/lto/pr78472_1.C [new file with mode: 0644]
gcc/tree.c

index 7c7ff4c61bef2ee387a38a9aed3dade08f729182..c0c529f5faa3807b74007f5fa91bb7dc63706fa0 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-23  Richard Biener  <rguenther@suse.de>
+
+       PR lto/78472
+       * tree.c (gimple_canonical_types_compatible_p): Ignore zero-sized
+       fields.
+
 2016-11-23  Richard Biener  <rguenther@suse.de>
            Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.rog>
 
index 732fc8a53ec2e8960ae179be2ddb9c4dfdaed386..cf65f02288603f0b2977dab606e101c40d459d6f 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-23  Richard Biener  <rguenther@suse.de>
+
+       PR lto/78472
+       * lto.c (hash_canonical_type): Ignore zero-sized fields.
+
 2016-11-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        PR c++/71973
index a01b4813f36961fbb514ba33ebef177ba0958166..6706557b2213d834d4cb717dae5f72b20344956c 100644 (file)
@@ -373,7 +373,9 @@ hash_canonical_type (tree type)
       tree f;
 
       for (f = TYPE_FIELDS (type), nf = 0; f; f = TREE_CHAIN (f))
-       if (TREE_CODE (f) == FIELD_DECL)
+       if (TREE_CODE (f) == FIELD_DECL
+           && (! DECL_SIZE (f)
+               || ! integer_zerop (DECL_SIZE (f))))
          {
            iterative_hash_canonical_type (TREE_TYPE (f), hstate);
            nf++;
index bb502baf72db54ffa40e85b613eb0f06af65a9a7..f4306f02b69bc53377c559214d4d70c8c9ae18d0 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-23  Richard Biener  <rguenther@suse.de>
+
+       PR lto/78472
+       * g++.dg/lto/pr78472_0.c: New testcase.
+       * g++.dg/lto/pr78472_1.C: Likewise.
+
 2016-11-23  Richard Biener  <rguenther@suse.de>
            Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.rog>
 
diff --git a/gcc/testsuite/g++.dg/lto/pr78472_0.c b/gcc/testsuite/g++.dg/lto/pr78472_0.c
new file mode 100644 (file)
index 0000000..f2dae32
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-lto-do link }
+
+extern struct S
+{
+  unsigned i:4;
+  unsigned :0;
+} s;
+static void *f(void)
+{
+  return &s;
+}
+int main() {}
diff --git a/gcc/testsuite/g++.dg/lto/pr78472_1.C b/gcc/testsuite/g++.dg/lto/pr78472_1.C
new file mode 100644 (file)
index 0000000..eed7f16
--- /dev/null
@@ -0,0 +1,9 @@
+struct S
+{
+  unsigned i:4;
+  unsigned :0;
+} s;
+static void *f(void)
+{
+  return &s;
+}
index 9b0b806cb56b32e21267d274435140a5583b463a..80675dbd9f49dc6171bd5ce5f7763026fb465b87 100644 (file)
@@ -13708,10 +13708,14 @@ gimple_canonical_types_compatible_p (const_tree t1, const_tree t2,
             f1 || f2;
             f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
          {
-           /* Skip non-fields.  */
-           while (f1 && TREE_CODE (f1) != FIELD_DECL)
+           /* Skip non-fields and zero-sized fields.  */
+           while (f1 && (TREE_CODE (f1) != FIELD_DECL
+                         || (DECL_SIZE (f1)
+                             && integer_zerop (DECL_SIZE (f1)))))
              f1 = TREE_CHAIN (f1);
-           while (f2 && TREE_CODE (f2) != FIELD_DECL)
+           while (f2 && (TREE_CODE (f2) != FIELD_DECL
+                         || (DECL_SIZE (f2)
+                             && integer_zerop (DECL_SIZE (f2)))))
              f2 = TREE_CHAIN (f2);
            if (!f1 || !f2)
              break;