re PR c++/53421 (__attribute__((__may_alias__)) prevents taking address of conversion...
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 13 Aug 2015 15:45:37 +0000 (15:45 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 13 Aug 2015 15:45:37 +0000 (15:45 +0000)
2015-08-13  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/53421
* g++.dg/ext/attribute-may-alias-1.C: New.
* g++.dg/ext/attribute-may-alias-2.C: Likewise.

From-SVN: r226868

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/attribute-may-alias-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/attribute-may-alias-2.C [new file with mode: 0644]

index 8c19d68a844994a7e125154a07fac151591e6372..ef2d567f64eb7b054811a6fa797573e28715a26d 100644 (file)
@@ -1,3 +1,9 @@
+2015-08-13  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/53421
+       * g++.dg/ext/attribute-may-alias-1.C: New.
+       * g++.dg/ext/attribute-may-alias-2.C: Likewise.
+
 2015-08-13  Matthew Wahab  <matthew.wahab@arm.com>
 
        * gcc.target/aarch64/atomic-inst-cas.c: New.
diff --git a/gcc/testsuite/g++.dg/ext/attribute-may-alias-1.C b/gcc/testsuite/g++.dg/ext/attribute-may-alias-1.C
new file mode 100644 (file)
index 0000000..24d2aab
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/53421
+
+template< class T >
+struct Y : T
+{ } __attribute__((__may_alias__));
+
+struct X
+{
+  operator Y<X>& () { return *static_cast< Y<X>* >(this); }
+};
+
+int main()
+{
+  &X::operator Y<X>&;
+}
diff --git a/gcc/testsuite/g++.dg/ext/attribute-may-alias-2.C b/gcc/testsuite/g++.dg/ext/attribute-may-alias-2.C
new file mode 100644 (file)
index 0000000..d7e1fdf
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/53421
+
+template< class T >
+struct Y : T
+{ } __attribute__((__may_alias__));
+
+struct X
+{
+  operator Y<X>& ();
+};
+
+Y<X> y = Y<X>();
+X::operator Y<X>& () { return *static_cast< Y<X>* >(this); }