]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/80287 C++ crash with __attribute((may_alias))
authorYvan Roux <yvan.roux@linaro.org>
Thu, 24 Aug 2017 13:20:22 +0000 (13:20 +0000)
committerYvan Roux <yroux@gcc.gnu.org>
Thu, 24 Aug 2017 13:20:22 +0000 (13:20 +0000)
gcc/
2017-08-24  Yvan Roux  <yvan.roux@linaro.org>

Backport from mainline
2017-04-17  Bernd Edlinger  <bernd.edlinger@hotmail.de>

PR c++/80287
* class.c (fixup_may_alias): Fix all type variants.

gcc/testsuite
2017-08-24  Yvan Roux  <yvan.roux@linaro.org>

Backport from mainline
2017-08-22  Yvan Roux  <yvan.roux@linaro.org>

PR c++/80287
* g++.dg/pr8028.C: New test.

From-SVN: r251331

gcc/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr80287.C [new file with mode: 0644]

index 0ae6be90330c126cea4ad5a7d1e158650d2a7fcf..4fb1a32636b5b9d772c65810dbd28e214bdc4436 100644 (file)
@@ -1,3 +1,11 @@
+2017-08-24  Yvan Roux  <yvan.roux@linaro.org>
+
+       Backport from mainline
+       2017-04-17  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+       PR c++/80287
+       * class.c (fixup_may_alias): Fix all type variants.
+
 2017-08-22  Peter Bergner  <bergner@vnet.ibm.com>
 
        Backport from mainline
index 35deb1e99cd29ac2b5b5902cb52809e4cf8c83cd..86e7e003fe49f1fd11922c89bdef4b0c30ce6682 100644 (file)
@@ -1999,12 +1999,14 @@ fixup_type_variants (tree t)
 static void
 fixup_may_alias (tree klass)
 {
-  tree t;
+  tree t, v;
 
   for (t = TYPE_POINTER_TO (klass); t; t = TYPE_NEXT_PTR_TO (t))
-    TYPE_REF_CAN_ALIAS_ALL (t) = true;
+    for (v = TYPE_MAIN_VARIANT (t); v; v = TYPE_NEXT_VARIANT (v))
+      TYPE_REF_CAN_ALIAS_ALL (v) = true;
   for (t = TYPE_REFERENCE_TO (klass); t; t = TYPE_NEXT_REF_TO (t))
-    TYPE_REF_CAN_ALIAS_ALL (t) = true;
+    for (v = TYPE_MAIN_VARIANT (t); v; v = TYPE_NEXT_VARIANT (v))
+      TYPE_REF_CAN_ALIAS_ALL (v) = true;
 }
 
 /* Early variant fixups: we apply attributes at the beginning of the class
index 7120e3a27236a80c8a14ae7cb89763d3fa7ebc79..6000f6a4bd82780465a7763d7f8e6c12adb9cdcc 100644 (file)
@@ -1,3 +1,11 @@
+2017-08-24  Yvan Roux  <yvan.roux@linaro.org>
+
+       Backport from mainline
+       2017-08-22  Yvan Roux  <yvan.roux@linaro.org>
+
+       PR c++/80287
+       * g++.dg/pr8028.C: New test.
+
 2017-08-22  Peter Bergner  <bergner@vnet.ibm.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/g++.dg/pr80287.C b/gcc/testsuite/g++.dg/pr80287.C
new file mode 100644 (file)
index 0000000..da8d3fa
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/80287
+// { dg-do compile { target c++11 } }
+// { dg-options "-g" }
+
+struct A {
+  operator long() {}
+} __attribute__((__may_alias__));
+
+struct {
+  A ino;
+} a;
+
+char b = a.ino;