aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/rtsfind.ads
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2021-03-31 08:00:59 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2021-06-21 06:45:12 -0400
commit336438b6d225c3a5f28d57fd766e36f53faf8f3e (patch)
tree4d9c8a37c32c67c6121686a39ed3a053d7b79556 /gcc/ada/rtsfind.ads
parent7f34e744c0bdb8b3f767463f290a32bc671bfcc8 (diff)
downloadgcc-336438b6d225c3a5f28d57fd766e36f53faf8f3e.zip
gcc-336438b6d225c3a5f28d57fd766e36f53faf8f3e.tar.gz
gcc-336438b6d225c3a5f28d57fd766e36f53faf8f3e.tar.bz2
[Ada] Implement 'Valid_Value attribute
gcc/ada/ * libgnat/s-valuen.ads, libgnat/s-valuen.adb (Value_Enumeration_Pos): New function to compute the 'Pos of the enumeration literal for a given String. Return a special value instead of raising an exception on invalid input. Called by both Valid_Enumeration_Image and Value_Enumeration. (Valid_Enumeration_Image): Return a Boolean indicating whether the String is a valid Image for the given enumeration type. (Value_Enumeration): Implement in terms of Value_Enumeration_Pos. * libgnat/s-vaenu8.ads, libgnat/s-vaen16.ads, libgnat/s-vaen32.ads: Rename Valid_Enumeration_Image from the instances. * libgnat/s-valuti.ads: Correct documentation (it was not true for the null string). * libgnat/s-valuti.adb (Normalize_String): Do not raise Constraint_Error for the null string, nor strings containing nothing but blanks, so that Valid_Enumeration_Image can return False in these cases, rather than raising an exception. * rtsfind.ads (RE_Value_Enumeration_8, RE_Value_Enumeration_16, RE_Value_Enumeration_32): New functions. (RTE_Available): Improve comment (E doesn't have to be a subprogram, although that's the usual case). * sem_attr.adb (nalid_Value): Semantic analysis for new attribute. * exp_attr.adb: Call Expand_Valid_Value_Attribute for new attribute. * exp_imgv.ads, exp_imgv.adb (Expand_Valid_Value_Attribute): New procedure to expand Valid_Value into a call to Valid_Enumeration_Image_NN. (Expand_Value_Attribute): Misc code cleanups. Remove two ??? mark comments. RTE_Available won't work here. For one thing, RTE_Available (X) shouldn't be called until the compiler has decided to make use of X (see comments on RTE_Available), and in this case we're trying to AVOID calling something. * snames.ads-tmpl: New attribute name. * doc/gnat_rm/implementation_defined_attributes.rst: Document new attribute. * gnat_rm.texi: Regenerate.
Diffstat (limited to 'gcc/ada/rtsfind.ads')
-rw-r--r--gcc/ada/rtsfind.ads25
1 files changed, 18 insertions, 7 deletions
diff --git a/gcc/ada/rtsfind.ads b/gcc/ada/rtsfind.ads
index ef17cf2..28d14bd 100644
--- a/gcc/ada/rtsfind.ads
+++ b/gcc/ada/rtsfind.ads
@@ -2036,9 +2036,13 @@ package Rtsfind is
RE_Value_Decimal128, -- System_Val_Decimal_128
- RE_Value_Enumeration_8, -- System.Val_Enum
- RE_Value_Enumeration_16, -- System.Val_Enum
- RE_Value_Enumeration_32, -- System.Val_Enum
+ RE_Value_Enumeration_8, -- System.Val_Enum_8
+ RE_Value_Enumeration_16, -- System.Val_Enum_16
+ RE_Value_Enumeration_32, -- System.Val_Enum_32
+
+ RE_Valid_Enumeration_Value_8, -- System.Val_Enum_8
+ RE_Valid_Enumeration_Value_16, -- System.Val_Enum_16
+ RE_Valid_Enumeration_Value_32, -- System.Val_Enum_32
RE_Value_Fixed32, -- System_Val_Fixed_32
@@ -3726,6 +3730,12 @@ package Rtsfind is
RE_Value_Enumeration_32 => System_Val_Enum_32,
+ RE_Valid_Enumeration_Value_8 => System_Val_Enum_8,
+
+ RE_Valid_Enumeration_Value_16 => System_Val_Enum_16,
+
+ RE_Valid_Enumeration_Value_32 => System_Val_Enum_32,
+
RE_Value_Fixed32 => System_Val_Fixed_32,
RE_Value_Fixed64 => System_Val_Fixed_64,
@@ -4074,10 +4084,11 @@ package Rtsfind is
-- and without generating an error message, i.e. if the call will obtain
-- the desired entity without any problems.
--
- -- If we call this and it returns True, we should generate a call to E.
- -- In other words, the compiler should not call RTE_Available (E) until
- -- it has decided it wants to generate a call to E. Otherwise we can get
- -- spurious dependencies and elaboration orders.
+ -- If we call this and it returns True, we should generate a reference to
+ -- E (usually a call). In other words, for a subprogram E, the compiler
+ -- should not call RTE_Available (E) until it has decided it wants to
+ -- generate a call to E. Otherwise we can get spurious dependencies and
+ -- elaboration orders.
--
-- if RTE_Available (E) -- WRONG!
-- and then <some condition>