diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2016-04-19 15:10:35 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2016-04-19 15:10:35 +0200 |
commit | b4213ffdafd1907f53c50b7bcdaa7fd269495592 (patch) | |
tree | 2d79230ef6305475d4443fa77a5b880a0db98247 /gcc/ada/exp_aggr.adb | |
parent | b314303784ccc313d79eadd61770225b0ec7fbfc (diff) | |
download | gcc-b4213ffdafd1907f53c50b7bcdaa7fd269495592.zip gcc-b4213ffdafd1907f53c50b7bcdaa7fd269495592.tar.gz gcc-b4213ffdafd1907f53c50b7bcdaa7fd269495592.tar.bz2 |
[multiple changes]
2016-04-19 Hristian Kirtchev <kirtchev@adacore.com>
* checks.adb, sem_util.adb, sem_res.adb, sem_attr.adb: Minor
reformatting.
2016-04-19 Ed Schonberg <schonberg@adacore.com>
* freeze.adb (Freeze_Profile): Refine predicate that checks
whether a function that returns a limited view is declared in
another unit and cannot be frozen at this point.
2016-04-19 Ed Schonberg <schonberg@adacore.com>
* exp_aggr.adb (Component_Count): Handle properly superflat
arrays, i.e. empty arrays where Hi < Lo - 1, to ensure that the
return value of the function is Natural, rather than leaving
the handling of such arrays to the caller of this function.
From-SVN: r235200
Diffstat (limited to 'gcc/ada/exp_aggr.adb')
-rw-r--r-- | gcc/ada/exp_aggr.adb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index cb97dca..94f8e07 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -354,10 +354,16 @@ package body Exp_Aggr is Siz : constant Nat := Component_Count (Component_Type (T)); begin + -- Check for superflat arrays, i.e. arrays with such bounds + -- as 4 .. 2, to insure that this function never returns a + -- meaningless negative value. + if not Compile_Time_Known_Value (Lo) or else not Compile_Time_Known_Value (Hi) + or else Expr_Value (Hi) < Expr_Value (Lo) then return 0; + else return Siz * UI_To_Int (Expr_Value (Hi) - Expr_Value (Lo) + 1); |