From d9c59db4554b9fe827e2f262eafdd789b686a944 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Fri, 6 Jan 2017 12:10:13 +0100 Subject: [multiple changes] 2017-01-06 Ed Schonberg * 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 * exp_attr.adb, sem_attr.ads: Minor reformatting. From-SVN: r244135 --- gcc/ada/sem_eval.adb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'gcc/ada/sem_eval.adb') 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; -- cgit v1.1