diff options
author | Ed Schonberg <schonberg@adacore.com> | 2012-10-02 08:10:54 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2012-10-02 10:10:54 +0200 |
commit | 4856cc2a7d10a3da76084704a51a37aae0e59cef (patch) | |
tree | 2377288705d822fe4345d9a763c34e97adda307d /gcc/ada | |
parent | 538dbb562fc7b3d8792477176eba628498f2ef18 (diff) | |
download | gcc-4856cc2a7d10a3da76084704a51a37aae0e59cef.zip gcc-4856cc2a7d10a3da76084704a51a37aae0e59cef.tar.gz gcc-4856cc2a7d10a3da76084704a51a37aae0e59cef.tar.bz2 |
sem_ch4.adb (Is_Empty_Range): Use bounds of index type to determine whether an array is empty when...
2012-10-02 Ed Schonberg <schonberg@adacore.com>
* sem_ch4.adb (Is_Empty_Range): Use bounds of index type
to determine whether an array is empty when optimizing
a quantified expression over a null range. Use of RM_Size
was incorrect. Analyze condition before constant-folding the
expression to catch potential errors. Modify the error message
to avoid mathematical terminology.
From-SVN: r191958
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/ada/sem_ch4.adb | 32 |
2 files changed, 31 insertions, 10 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 99ee5a2..fa0c515 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +2012-10-02 Ed Schonberg <schonberg@adacore.com> + + * sem_ch4.adb (Is_Empty_Range): Use bounds of index type + to determine whether an array is empty when optimizing + a quantified expression over a null range. Use of RM_Size + was incorrect. Analyze condition before constant-folding the + expression to catch potential errors. Modify the error message + to avoid mathematical terminology. + 2012-10-02 Robert Dewar <dewar@adacore.com> * usage.adb, gnat_rm.texi, vms_data.ads: Add entry for diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 93f6d36..ef13222 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -3404,27 +3404,37 @@ package body Sem_Ch4 is procedure Analyze_Quantified_Expression (N : Node_Id) is QE_Scop : Entity_Id; - function Is_Empty_Range (Typ : Entity_Id) return Boolean; + function Is_Empty_Range (Typ : Entity_Id) return Boolean; -- If the iterator is part of a quantified expression, and the range is -- known to be statically empty, emit a warning and replace expression - -- with its static value. + -- with its static value. Returns True if the replacement occurs. - function Is_Empty_Range (Typ : Entity_Id) return Boolean is - Loc : constant Source_Ptr := Sloc (N); + -------------------- + -- Is_Empty_Range -- + -------------------- + + function Is_Empty_Range (Typ : Entity_Id) return Boolean is + Loc : constant Source_Ptr := Sloc (N); begin if Is_Array_Type (Typ) - and then Size_Known_At_Compile_Time (Typ) - and then RM_Size (Typ) = 0 + and then Compile_Time_Known_Bounds (Typ) + and then + (Expr_Value (Type_Low_Bound (Etype (First_Index (Typ)))) + > Expr_Value (Type_High_Bound (Etype (First_Index (Typ))))) then + Preanalyze_And_Resolve (Condition (N), Standard_Boolean); + if All_Present (N) then - Error_Msg_N ("?universal quantified expression " - & "over a null range has value True", N); + Error_Msg_N + ("?quantified expression with ALL " + & "over a null range has value True", N); Rewrite (N, New_Occurrence_Of (Standard_True, Loc)); else - Error_Msg_N ("?existential quantified expression " - & "over a null range has value False", N); + Error_Msg_N + ("?quantified expression with SOME " + & "over a null range has value False", N); Rewrite (N, New_Occurrence_Of (Standard_False, Loc)); end if; @@ -3436,6 +3446,8 @@ package body Sem_Ch4 is end if; end Is_Empty_Range; + -- Start of processing for Analyze_Quantified_Expression + begin Check_SPARK_Restriction ("quantified expression is not allowed", N); |