aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2016-11-23 11:24:55 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2016-11-23 11:24:55 +0000
commitefb71232412323c504f3af95ed6679abfd15cb7a (patch)
treea697ff65416b8a61c02dab5a71350e0bd9eabab7
parenta5bb8a5ceae1bfb0fa82a58254a6539c8943d4b8 (diff)
downloadgcc-efb71232412323c504f3af95ed6679abfd15cb7a.zip
gcc-efb71232412323c504f3af95ed6679abfd15cb7a.tar.gz
gcc-efb71232412323c504f3af95ed6679abfd15cb7a.tar.bz2
re PR lto/78472 (warning: type of 's' does not match original declaration from zero length bitfield in C vs C++)
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
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/lto/ChangeLog5
-rw-r--r--gcc/lto/lto.c4
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/lto/pr78472_0.c12
-rw-r--r--gcc/testsuite/g++.dg/lto/pr78472_1.C9
-rw-r--r--gcc/tree.c10
7 files changed, 48 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7c7ff4c..c0c529f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,4 +1,10 @@
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>
PR tree-optimization/78154
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index 732fc8a..cf65f02 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -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
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index a01b481..6706557 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -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++;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bb502ba..f4306f0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,4 +1,10 @@
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>
PR tree-optimization/78154
diff --git a/gcc/testsuite/g++.dg/lto/pr78472_0.c b/gcc/testsuite/g++.dg/lto/pr78472_0.c
new file mode 100644
index 0000000..f2dae32
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr78472_0.c
@@ -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
index 0000000..eed7f16
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr78472_1.C
@@ -0,0 +1,9 @@
+struct S
+{
+ unsigned i:4;
+ unsigned :0;
+} s;
+static void *f(void)
+{
+ return &s;
+}
diff --git a/gcc/tree.c b/gcc/tree.c
index 9b0b806..80675db 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -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;