diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2017-09-05 09:22:21 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2017-09-05 09:22:21 +0000 |
commit | 3fd9ae9664a57eac0fbf3b88b8f6971d293b13e5 (patch) | |
tree | 709346a280dbe29e244e61d0f73d170420311227 | |
parent | 1f073c9270d23a01f59b6871f127d99d54bd6670 (diff) | |
download | gcc-3fd9ae9664a57eac0fbf3b88b8f6971d293b13e5.zip gcc-3fd9ae9664a57eac0fbf3b88b8f6971d293b13e5.tar.gz gcc-3fd9ae9664a57eac0fbf3b88b8f6971d293b13e5.tar.bz2 |
trans.c (Attribute_to_gnu): Do not strip conversions around prefixes that are not references.
* gcc-interface/trans.c (Attribute_to_gnu) <Attr_Address>: Do not strip
conversions around prefixes that are not references.
From-SVN: r251704
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 0dbc779..cce0e41 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,10 @@ 2017-09-05 Eric Botcazou <ebotcazou@adacore.com> + * gcc-interface/trans.c (Attribute_to_gnu) <Attr_Address>: Do not strip + conversions around prefixes that are not references. + +2017-09-05 Eric Botcazou <ebotcazou@adacore.com> + * gcc-interface/utils.c (unchecked_convert): When the result type is a non-biased integral type with size 0, set the result to 0 directly. diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 270bf7a..518016d 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -1629,10 +1629,14 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) case Attr_Address: case Attr_Unrestricted_Access: - /* Conversions don't change addresses but can cause us to miss the - COMPONENT_REF case below, so strip them off. */ - gnu_prefix = remove_conversions (gnu_prefix, - !Must_Be_Byte_Aligned (gnat_node)); + /* Conversions don't change the address of references but can cause + build_unary_op to miss the references below, so strip them off. + On the contrary, if the address-of operation causes a temporary + to be created, then it must be created with the proper type. */ + gnu_expr = remove_conversions (gnu_prefix, + !Must_Be_Byte_Aligned (gnat_node)); + if (REFERENCE_CLASS_P (gnu_expr)) + gnu_prefix = gnu_expr; /* If we are taking 'Address of an unconstrained object, this is the pointer to the underlying array. */ |