From 42b7febc53cac744c7d0c0ae6e2dae0876b7d896 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 13 Aug 2015 15:45:37 +0000 Subject: [PATCH] re PR c++/53421 (__attribute__((__may_alias__)) prevents taking address of conversion operator member function) 2015-08-13 Paolo Carlini 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 | 6 ++++++ gcc/testsuite/g++.dg/ext/attribute-may-alias-1.C | 15 +++++++++++++++ gcc/testsuite/g++.dg/ext/attribute-may-alias-2.C | 13 +++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/attribute-may-alias-1.C create mode 100644 gcc/testsuite/g++.dg/ext/attribute-may-alias-2.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8c19d68a844..ef2d567f64e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-08-13 Paolo Carlini + + 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 * 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 index 00000000000..24d2aab7615 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attribute-may-alias-1.C @@ -0,0 +1,15 @@ +// PR c++/53421 + +template< class T > +struct Y : T +{ } __attribute__((__may_alias__)); + +struct X +{ + operator Y& () { return *static_cast< Y* >(this); } +}; + +int main() +{ + &X::operator Y&; +} 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 index 00000000000..d7e1fdfdd4a --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attribute-may-alias-2.C @@ -0,0 +1,13 @@ +// PR c++/53421 + +template< class T > +struct Y : T +{ } __attribute__((__may_alias__)); + +struct X +{ + operator Y& (); +}; + +Y y = Y(); +X::operator Y& () { return *static_cast< Y* >(this); } -- 2.30.2