aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_eval.ads
diff options
context:
space:
mode:
authorRonan Desplanques <desplanques@adacore.com>2024-11-19 10:10:31 +0100
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-12-12 10:57:58 +0100
commit003ed7d39343cdfb9dde70980c2aa67454bcacef (patch)
tree952b292f2fb6b11a1dad0ab5705b0b44a533b519 /gcc/ada/sem_eval.ads
parentfac69bd389303362efc0ae6e86fc08f3fe99946a (diff)
downloadgcc-003ed7d39343cdfb9dde70980c2aa67454bcacef.zip
gcc-003ed7d39343cdfb9dde70980c2aa67454bcacef.tar.gz
gcc-003ed7d39343cdfb9dde70980c2aa67454bcacef.tar.bz2
ada: Accept static strings with External_Initialization
Before this patch, the argument to the External_Initialization aspect had to be a string literal. This patch extends the possibilities so that any static string is accepted. A new helper function, Is_OK_Static_Expression_Of_Type, is introduced, and in addition to the main change of this patch a couple of calls to that helper function are added in other places to replace equivalent inline code. gcc/ada/ChangeLog: * sem_eval.ads (Is_OK_Static_Expression_Of_Type): New function. * sem_eval.adb (Is_OK_Static_Expression_Of_Type): Likewise. * sem_ch13.adb (Check_Expr_Is_OK_Static_Expression): Use new function. * sem_prag.adb (Check_Expr_Is_OK_Static_Expression): Likewise. * sem_ch3.adb (Apply_External_Initialization): Accept static strings for the parameter.
Diffstat (limited to 'gcc/ada/sem_eval.ads')
-rw-r--r--gcc/ada/sem_eval.ads9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/ada/sem_eval.ads b/gcc/ada/sem_eval.ads
index b79f61f..177a3e2 100644
--- a/gcc/ada/sem_eval.ads
+++ b/gcc/ada/sem_eval.ads
@@ -422,6 +422,15 @@ package Sem_Eval is
-- for compile time evaluation purposes. Use Compile_Time_Known_Value
-- instead (see section on "Compile-Time Known Values" above).
+ type Staticity is (Static, Not_Static, Invalid);
+
+ function Is_OK_Static_Expression_Of_Type
+ (Expr : Node_Id; Typ : Entity_Id := Empty) return Staticity;
+ -- Return whether Expr is a static expression of the given type (i.e. it
+ -- will be analyzed and resolved using this type, which can be any valid
+ -- argument to Resolve, e.g. Any_Integer is OK). Includes checking that the
+ -- expression does not raise Constraint_Error.
+
function Is_OK_Static_Range (N : Node_Id) return Boolean;
-- Determines if range is static, as defined in RM 4.9(26), and also checks
-- that neither bound of the range raises constraint error, thus ensuring