aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_eval.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2017-01-06 12:10:13 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2017-01-06 12:10:13 +0100
commitd9c59db4554b9fe827e2f262eafdd789b686a944 (patch)
tree15fa1871fd9ce2ae63b248d5890875bd40df590f /gcc/ada/sem_eval.adb
parentf68d33443ec67d0b0c2a28f04f3c90b28d22b5d4 (diff)
downloadgcc-d9c59db4554b9fe827e2f262eafdd789b686a944.zip
gcc-d9c59db4554b9fe827e2f262eafdd789b686a944.tar.gz
gcc-d9c59db4554b9fe827e2f262eafdd789b686a944.tar.bz2
[multiple changes]
2017-01-06 Ed Schonberg <schonberg@adacore.com> * sem_eval.adb (Check_Expression_Against_Static_Predicate): If expression is compile-time known and obeys a static predicate it must be labelled as static, to prevent spurious warnings and run-time errors, e.g. in case statements. This is relevant when the expression is the result of constant-folding a type conversion whose expression is a variable with a known static value. 2017-01-06 Hristian Kirtchev <kirtchev@adacore.com> * exp_attr.adb, sem_attr.ads: Minor reformatting. From-SVN: r244135
Diffstat (limited to 'gcc/ada/sem_eval.adb')
-rw-r--r--gcc/ada/sem_eval.adb9
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb
index 314c110..fce4643 100644
--- a/gcc/ada/sem_eval.adb
+++ b/gcc/ada/sem_eval.adb
@@ -347,7 +347,11 @@ package body Sem_Eval is
-- Here we have a static predicate (note that it could have arisen from
-- an explicitly specified Dynamic_Predicate whose expression met the
- -- rules for being predicate-static).
+ -- rules for being predicate-static). If the expression is known at
+ -- compile time and obeys the predicate, then it is static and must be
+ -- labeled as such, which matters e.g. for case statements. The original
+ -- expression may be a type conversion of a variable with a known value,
+ -- which might otherwise not be marked static.
-- Case of real static predicate
@@ -356,6 +360,7 @@ package body Sem_Eval is
(Val => Make_Real_Literal (Sloc (Expr), Expr_Value_R (Expr)),
Typ => Typ)
then
+ Set_Is_Static_Expression (Expr);
return;
end if;
@@ -365,6 +370,7 @@ package body Sem_Eval is
if Real_Or_String_Static_Predicate_Matches
(Val => Expr_Value_S (Expr), Typ => Typ)
then
+ Set_Is_Static_Expression (Expr);
return;
end if;
@@ -376,6 +382,7 @@ package body Sem_Eval is
-- If static predicate matches, nothing to do
if Choices_Match (Expr, Static_Discrete_Predicate (Typ)) = Match then
+ Set_Is_Static_Expression (Expr);
return;
end if;
end if;