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
+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.
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");
+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-*-*,
--- /dev/null
+/* { 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" } */
+}
+
+++ /dev/null
-/* { 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" } */
--- /dev/null
+/* { 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" } */
+}