aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_attr.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2017-04-27 15:18:28 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2017-04-27 15:18:28 +0200
commit9dd8f36f2310db400fde9ca4b55ebb7791f50ec0 (patch)
tree404e270b875cdc8773a13f7c2cc90acc4e910ddb /gcc/ada/sem_attr.adb
parent7327f5c21ce98b8211801095008e2f024593b79c (diff)
downloadgcc-9dd8f36f2310db400fde9ca4b55ebb7791f50ec0.zip
gcc-9dd8f36f2310db400fde9ca4b55ebb7791f50ec0.tar.gz
gcc-9dd8f36f2310db400fde9ca4b55ebb7791f50ec0.tar.bz2
[multiple changes]
2017-04-27 Ed Schonberg <schonberg@adacore.com> * sem_attr.adb (Analyze_Attribute, case 'Image): In Ada2012 the prefix can be an object reference in which case Obj'Image (X) can only be interpreted as an indexing of the parameterless version of the attribute. * par-ch4.adb (P_Name): An attribute reference can be the prefix of an indexing or a slice operation if the attribute does not require parameters. In Ada2012 'Image also belongs in this category, and A'Image (lo .. hi) is legal and must be parsed as a slice. 2017-04-27 Yannick Moy <moy@adacore.com> * exp_ch4.adb: Minor reformatting. * gnat1drv.adb (Adjust_Global_Switches): When in GNATprove mode, disable the CodePeer and C generation modes. Similar to the opposite actions done in CodePeer mode. From-SVN: r247331
Diffstat (limited to 'gcc/ada/sem_attr.adb')
-rw-r--r--gcc/ada/sem_attr.adb23
1 files changed, 19 insertions, 4 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index ca43d06..f37b4c3 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -4042,10 +4042,25 @@ package body Sem_Attr is
and then Is_Object_Reference (P)
and then Is_Scalar_Type (P_Type)
then
- Rewrite (N,
- Make_Attribute_Reference (Loc,
- Prefix => Relocate_Node (P),
- Attribute_Name => Name_Img));
+ if No (Expressions (N)) then
+ Rewrite (N,
+ Make_Attribute_Reference (Loc,
+ Prefix => Relocate_Node (P),
+ Attribute_Name => Name_Img));
+
+ -- If the attribute reference includes expressions, the
+ -- only possible interpretation is as an indexing of the
+ -- parameterless version of 'Image, so rewrite it accordingly.
+
+ else
+ Rewrite (N,
+ Make_Indexed_Component (Loc,
+ Prefix =>
+ Make_Attribute_Reference (Loc,
+ Prefix => Relocate_Node (P),
+ Attribute_Name => Name_Img),
+ Expressions => Expressions (N)));
+ end if;
Analyze (N);
return;