diff options
author | Marc Poulhiès <poulhies@adacore.com> | 2021-12-17 14:34:15 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2022-05-10 08:19:21 +0000 |
commit | 5046228671e991170c19c1c0d9f70a51026e2cab (patch) | |
tree | 18ccb6aa301e56f7a3f3856c98c04049e79671b2 /gcc/fold-const.cc | |
parent | a445a8692c43d14c494e1edf505ee4f33cb98bb6 (diff) | |
download | gcc-5046228671e991170c19c1c0d9f70a51026e2cab.zip gcc-5046228671e991170c19c1c0d9f70a51026e2cab.tar.gz gcc-5046228671e991170c19c1c0d9f70a51026e2cab.tar.bz2 |
[Ada] Fix incorrect range computation
When the type range [Lo, Hi] and the computed expression range [Lor,
Hir] are disjoint, the range-constraining logic breaks and returns an
incorrect range. For example, when Lo<Hi<Lor<Hir, it currently returns
[Lor, Hi]. Instead, return the computed range.
The current constraining logic would require returning the base type's
bounds. However, this would miss an opportunity to warn about out of
range values for some cases (e.g. when type's upper bound is equal to
base type upper bound).
The alternative of always returning the computed values, even when
ranges are intersecting, has unwanted effects (mainly useless
constraint checks are inserted) in the Enable_Overflow_Check and
Apply_Scalar_Range_Check as these bounds have a special interpretation.
gcc/ada/
* checks.adb (Determine_Range): Fix range refining.
Diffstat (limited to 'gcc/fold-const.cc')
0 files changed, 0 insertions, 0 deletions