]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2016-03-09 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 9 Mar 2016 14:01:16 +0000 (14:01 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 9 Mar 2016 14:01:16 +0000 (14:01 +0000)
c-family/
PR c/70143
* c-common.c (strict_aliasing_warning): Add back
alias_sets_conflict_p check.

* gcc.dg/Wstrict-aliasing-bogus-upcast.c: New testcase.
* gcc.dg/Wstrict-aliasing-struct-with-char-member.c: Likewise.
* gcc.dg/Wstrict-aliasing-struct-member.c: Remove again.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234084 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-upcast.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wstrict-aliasing-struct-member.c [deleted file]
gcc/testsuite/gcc.dg/Wstrict-aliasing-struct-with-char-member.c [new file with mode: 0644]

index 464297b653919e9de1c9dea81e4a4e8f10961052..534d6058870c14dcb119e260908e9018861cae70 100644 (file)
@@ -1,3 +1,9 @@
+2016-03-09  Richard Biener  <rguenther@suse.de>
+
+       PR c/70143
+       * c-common.c (strict_aliasing_warning): Add back
+       alias_sets_conflict_p check.
+
 2016-03-08  Jason Merrill  <jason@redhat.com>
 
        * c-opts.c (set_std_cxx1z): Don't enable concepts.
index 965cf493699a7950c78f7d7af04c50d00f83895f..08b761c4776d02f0e2d2d1e8b024e119eed2fa71 100644 (file)
@@ -1568,7 +1568,9 @@ strict_aliasing_warning (tree otype, tree type, tree expr)
           alias_set_type set2 = get_alias_set (TREE_TYPE (type));
 
           if (set1 != set2 && set2 != 0
-             && (set1 == 0 || !alias_set_subset_of (set2, set1)))
+             && (set1 == 0
+                 || (!alias_set_subset_of (set2, set1)
+                     && !alias_sets_conflict_p (set1, set2))))
            {
              warning (OPT_Wstrict_aliasing, "dereferencing type-punned "
                       "pointer will break strict-aliasing rules");
index 2136f7f92f99e6591afd380080391dfc02d16e11..9ea56a7b9fc93cc1e07afd4491e08f5889d29d8b 100644 (file)
@@ -1,3 +1,10 @@
+2016-03-09  Richard Biener  <rguenther@suse.de>
+
+       PR c/70143
+       * gcc.dg/Wstrict-aliasing-bogus-upcast.c: New testcase.
+       * gcc.dg/Wstrict-aliasing-struct-with-char-member.c: Likewise.
+       * gcc.dg/Wstrict-aliasing-struct-member.c: Remove again.
+
 2016-03-09  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * gcc.dg/vect/bb-slp-34.c: Really don't xfail on aarch64-*-*,
diff --git a/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-upcast.c b/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-upcast.c
new file mode 100644 (file)
index 0000000..cb70838
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wall" } */
+
+struct a {
+    int i;
+};
+struct b {
+    struct a a;
+    int j;
+};
+int main(void)
+{
+  static struct b b;
+  struct a *ap=(struct a *)&b;
+  return ((struct b *)&ap->i)->j; /* { dg-bogus "will break strict-aliasing" } */
+}
+
diff --git a/gcc/testsuite/gcc.dg/Wstrict-aliasing-struct-member.c b/gcc/testsuite/gcc.dg/Wstrict-aliasing-struct-member.c
deleted file mode 100644 (file)
index 6c5e88d..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-O2 -Wall" } */
-
-struct S { int i; long l; };
-long x;
-struct S foo () { return *(struct S *)&x; } /* { dg-warning "will break strict-aliasing" } */
diff --git a/gcc/testsuite/gcc.dg/Wstrict-aliasing-struct-with-char-member.c b/gcc/testsuite/gcc.dg/Wstrict-aliasing-struct-with-char-member.c
new file mode 100644 (file)
index 0000000..0da9a16
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wall" } */
+
+struct a {
+    int i;
+    char c;
+};
+struct b {
+    float f;
+    float g;
+};
+int main(void)
+{
+  static struct b b;
+  return ((struct a *)&b)->i; /* { dg-warning "will break strict-aliasing" } */
+}