* [Ada] Fix bogus constraint error on value conversion with -gnatVa
@ 2017-09-05 9:22 Eric Botcazou
0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2017-09-05 9:22 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 248 bytes --]
Tested on x86_64-suse-linux, applied on mainline.
2017-09-05 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (Attribute_to_gnu) <Attr_Address>: Do notstrip
conversions around prefixes that are not references.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1092 bytes --]
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c (revision 251700)
+++ gcc-interface/trans.c (working copy)
@@ -1629,10 +1629,14 @@ Attribute_to_gnu (Node_Id gnat_node, tre
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. */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-09-05 9:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-05 9:22 [Ada] Fix bogus constraint error on value conversion with -gnatVa Eric Botcazou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).