diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-04-27 15:18:28 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-04-27 15:18:28 +0200 |
commit | 9dd8f36f2310db400fde9ca4b55ebb7791f50ec0 (patch) | |
tree | 404e270b875cdc8773a13f7c2cc90acc4e910ddb /gcc/ada/par-ch4.adb | |
parent | 7327f5c21ce98b8211801095008e2f024593b79c (diff) | |
download | gcc-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/par-ch4.adb')
-rw-r--r-- | gcc/ada/par-ch4.adb | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb index d500e58..0e01594 100644 --- a/gcc/ada/par-ch4.adb +++ b/gcc/ada/par-ch4.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -47,12 +47,11 @@ package body Ch4 is Attribute_Version => True, Attribute_Type_Key => True, others => False); - -- This map contains True for parameterless attributes that return a - -- string or a type. For those attributes, a left parenthesis after - -- the attribute should not be analyzed as the beginning of a parameters - -- list because it may denote a slice operation (X'Img (1 .. 2)) or - -- a type conversion (X'Class (Y)). The Ada2012 attribute 'Old is in - -- this category. + -- This map contains True for parameterless attributes that return a string + -- or a type. For those attributes, a left parenthesis after the attribute + -- should not be analyzed as the beginning of a parameters list because it + -- may denote a slice operation (X'Img (1 .. 2)) or a type conversion + -- (X'Class (Y)). The Ada 2012 attribute 'Old is in this category. -- Note: Loop_Entry is in this list because, although it can take an -- optional argument (the loop name), we can't distinguish that at parse @@ -587,8 +586,35 @@ package body Ch4 is -- Here for normal case (not => for named parameter) else - Append (Expr, Expressions (Name_Node)); - exit when not Comma_Present; + -- Special handling for 'Image in Ada 2012, where + -- the attribute can be parameterless and its value + -- can be the prefix of a slice. Rewrite name as a + -- a slice, Expr is its low bound. + + if Token = Tok_Dot_Dot + and then Attr_Name = Name_Image + and then Ada_Version >= Ada_2012 + then + Set_Expressions (Name_Node, No_List); + Prefix_Node := Name_Node; + Name_Node := + New_Node (N_Slice, Sloc (Prefix_Node)); + Set_Prefix (Name_Node, Prefix_Node); + Range_Node := New_Node (N_Range, Token_Ptr); + Set_Low_Bound (Range_Node, Expr); + Scan; -- past .. + Expr_Node := P_Expression; + Check_Simple_Expression (Expr_Node); + Set_High_Bound (Range_Node, Expr_Node); + Set_Discrete_Range (Name_Node, Range_Node); + T_Right_Paren; + + goto Scan_Name_Extension; + + else + Append (Expr, Expressions (Name_Node)); + exit when not Comma_Present; + end if; end if; end; end loop; |