aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/checks.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2014-02-25 15:55:43 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2014-02-25 15:55:43 +0100
commitf9966234d510c33008281d0793d595f367f599b3 (patch)
tree2abdbf5c5cdcda0ae03817cfa833ccdd8485cbb7 /gcc/ada/checks.adb
parenta6abfd78fe2571bb025268983633ac1978a1d3c3 (diff)
downloadgcc-f9966234d510c33008281d0793d595f367f599b3.zip
gcc-f9966234d510c33008281d0793d595f367f599b3.tar.gz
gcc-f9966234d510c33008281d0793d595f367f599b3.tar.bz2
[multiple changes]
2014-02-25 Yannick Moy <moy@adacore.com> * sem_ch3.adb, sem_ch5.adb, sem_ch9.adb, sem_prag.adb, sem_attr.adb, sem_ch6.adb: Remove useless references to SPARK RM in error messages. 2014-02-25 Hristian Kirtchev <kirtchev@adacore.com> * sem_res.adb (Appears_In_Check): New routine. (Resolve_Entity_Name): Remove local variables Prev and Usage_OK. Par is now a constant. Remove the parent chain traversal as the placement of a volatile object with enabled property Async_Writers and/or Effective_Reads must appear immediately within a legal construct. 2014-02-25 Hristian Kirtchev <kirtchev@adacore.com> * checks.adb (Apply_Selected_Range_Checks): Alphabetize local constants and variables. Add comments. Always insert a range check that requires runtime evaluation into the tree. From-SVN: r208128
Diffstat (limited to 'gcc/ada/checks.adb')
-rw-r--r--gcc/ada/checks.adb40
1 files changed, 25 insertions, 15 deletions
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 82b6d60..8feebb9 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -3061,14 +3061,14 @@ package body Checks is
Source_Typ : Entity_Id;
Do_Static : Boolean)
is
- Cond : Node_Id;
- R_Result : Check_Result;
- R_Cno : Node_Id;
-
Loc : constant Source_Ptr := Sloc (Ck_Node);
Checks_On : constant Boolean :=
- (not Index_Checks_Suppressed (Target_Typ))
- or else (not Range_Checks_Suppressed (Target_Typ));
+ not Index_Checks_Suppressed (Target_Typ)
+ or else not Range_Checks_Suppressed (Target_Typ);
+
+ Cond : Node_Id;
+ R_Cno : Node_Id;
+ R_Result : Check_Result;
begin
if not Expander_Active or else not Checks_On then
@@ -3079,27 +3079,33 @@ package body Checks is
Selected_Range_Checks (Ck_Node, Target_Typ, Source_Typ, Empty);
for J in 1 .. 2 loop
-
R_Cno := R_Result (J);
exit when No (R_Cno);
- -- If the item is a conditional raise of constraint error, then have
- -- a look at what check is being performed and ???
+ -- The range check requires runtime evaluation. Depending on what its
+ -- triggering condition is, the check may be converted into a compile
+ -- time constraint check.
if Nkind (R_Cno) = N_Raise_Constraint_Error
and then Present (Condition (R_Cno))
then
Cond := Condition (R_Cno);
- if not Has_Dynamic_Range_Check (Ck_Node) then
- Insert_Action (Ck_Node, R_Cno);
+ -- Insert the range check before the related context. Note that
+ -- this action analyses the triggering condition.
- if not Do_Static then
- Set_Has_Dynamic_Range_Check (Ck_Node);
- end if;
+ Insert_Action (Ck_Node, R_Cno);
+
+ -- This old code doesn't make sense, why is the context flagged as
+ -- requiring dynamic range checks now in the middle of generating
+ -- them ???
+
+ if not Do_Static then
+ Set_Has_Dynamic_Range_Check (Ck_Node);
end if;
- -- Output a warning if the condition is known to be True
+ -- The triggering condition evaluates to True, the range check
+ -- can be converted into a compile time constraint check.
if Is_Entity_Name (Cond)
and then Entity (Cond) = Standard_True
@@ -3130,11 +3136,15 @@ package body Checks is
-- on, then we want to delete the check, since it is not needed.
-- We do this by replacing the if statement by a null statement
+ -- Why are we even generating checks if checks are turned off ???
+
elsif Do_Static or else not Checks_On then
Remove_Warning_Messages (R_Cno);
Rewrite (R_Cno, Make_Null_Statement (Loc));
end if;
+ -- The range check raises Constrant_Error explicitly
+
else
Install_Static_Check (R_Cno, Loc);
end if;