From 98bf4cf4973d9b66774c85fe271073e7bc0ff916 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Mon, 4 Aug 2014 10:07:57 +0200 Subject: [PATCH] [multiple changes] 2014-08-04 Ed Schonberg * sem_util.adb (Is_Potentially_Unevaluated): If the original node of a parent node in the tree is a short-circuit operation, the node is potentially unevaluated. 2014-08-04 Robert Dewar * sem_res.adb (Resolve_Type_Conversion): Set Do_Range_Check on conversion from a real type to an integer type. From-SVN: r213538 --- gcc/ada/ChangeLog | 11 +++++++++++ gcc/ada/sem_res.adb | 21 ++++++++++++++++----- gcc/ada/sem_util.adb | 11 +++++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 09575ebfab3..b797f135baf 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,14 @@ +2014-08-04 Ed Schonberg + + * sem_util.adb (Is_Potentially_Unevaluated): If the original + node of a parent node in the tree is a short-circuit operation, + the node is potentially unevaluated. + +2014-08-04 Robert Dewar + + * sem_res.adb (Resolve_Type_Conversion): Set Do_Range_Check on + conversion from a real type to an integer type. + 2014-08-04 Yannick Moy * sem_aggr.adb, sem_ch3.adb, sem_ch5.adb, sem_ch7.adb, sem_ch9.adb, diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index b7fa5f523bd..87024ee92f5 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -10322,11 +10322,11 @@ package body Sem_Res is -- odd subtype coming from the bounds). if (Is_Entity_Name (Orig_N) - and then - (Etype (Entity (Orig_N)) = Orig_T - or else - (Ekind (Entity (Orig_N)) = E_Loop_Parameter - and then Covers (Orig_T, Etype (Entity (Orig_N)))))) + and then + (Etype (Entity (Orig_N)) = Orig_T + or else + (Ekind (Entity (Orig_N)) = E_Loop_Parameter + and then Covers (Orig_T, Etype (Entity (Orig_N)))))) -- If not an entity, then type of expression must match @@ -10504,6 +10504,17 @@ package body Sem_Res is Apply_Predicate_Check (N, Target_Typ); end if; end if; + + -- If at this stage we have a real to integer conversion, make sure + -- that the Do_Range_Check flag is set, because such conversions in + -- general need a range check. + + if Nkind (N) = N_Type_Conversion + and then Is_Integer_Type (Target_Typ) + and then Is_Real_Type (Operand_Typ) + then + Set_Do_Range_Check (Operand); + end if; end Resolve_Type_Conversion; ---------------------- diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 4c8bddd515b..5c1a5a8011e 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -11146,6 +11146,17 @@ package body Sem_Util is begin Expr := N; Par := Parent (N); + + -- A postcondition whose expression is a short-circuit is broken down + -- into individual aspects for better exception reporting. The original + -- short-circuit expression is rewritten as the second operand, and an + -- occurrence of 'Old in that operand is potentially unevaluated. + -- See Sem_ch13.adb for details of this transformation. + + if Nkind (Original_Node (Par)) = N_And_Then then + return True; + end if; + while not Nkind_In (Par, N_If_Expression, N_Case_Expression, N_And_Then, -- 2.30.2