diff options
author | Ed Schonberg <schonberg@adacore.com> | 2018-07-31 09:55:48 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-07-31 09:55:48 +0000 |
commit | c4a2e585d3b4e829f48fcb3c2a825584890b4fda (patch) | |
tree | 2c76177eefdccd1a103a4a6318068a90456d026c | |
parent | 1e739bf78ec49cdb24787d0447c6a44ff20a3a00 (diff) | |
download | gcc-c4a2e585d3b4e829f48fcb3c2a825584890b4fda.zip gcc-c4a2e585d3b4e829f48fcb3c2a825584890b4fda.tar.gz gcc-c4a2e585d3b4e829f48fcb3c2a825584890b4fda.tar.bz2 |
[Ada] Spurious warning on iteration over range of 64-bit modular type
This patch suppresses a spurious warning on the use of a 64-bit modular type
in a quantified expression, where the range of iteration will include a bound
that appears larger than the run-time representation of Universal_Integer'last.
2018-07-31 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_eval.adb (Check_Non_Static_Context): Do not warn on an
integer literal greater than the upper bound of
Universal_Integer'Last when expansion is disabled, to avoid a
spurious warning over ranges involving 64-bit modular types.
gcc/testsuite/
* gnat.dg/iter3.adb: New testcase.
From-SVN: r263095
-rw-r--r-- | gcc/ada/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ada/sem_eval.adb | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/iter3.adb | 15 |
4 files changed, 32 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f91727b..8b28605 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2018-07-31 Ed Schonberg <schonberg@adacore.com> + + * sem_eval.adb (Check_Non_Static_Context): Do not warn on an + integer literal greater than the upper bound of + Universal_Integer'Last when expansion is disabled, to avoid a + spurious warning over ranges involving 64-bit modular types. + 2018-07-31 Arnaud Charlet <charlet@adacore.com> * einfo.adb (Write_Entity_Flags): Also print diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb index c14347b..4560a51 100644 --- a/gcc/ada/sem_eval.adb +++ b/gcc/ada/sem_eval.adb @@ -547,9 +547,15 @@ package body Sem_Eval is -- called in contexts like the expression of a number declaration where -- we certainly want to allow out of range values. + -- We inhibit the warning when expansion is disabled, because the + -- preanalysis of a range of a 64-bit modular type may appear to + -- violate the constraint on non-static Universal_Integer. If there + -- is a true overflow it will be diagnosed during full analysis. + if Etype (N) = Universal_Integer and then Nkind (N) = N_Integer_Literal and then Nkind (Parent (N)) in N_Subexpr + and then Expander_Active and then (Intval (N) < Expr_Value (Type_Low_Bound (Universal_Integer)) or else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eb64742..fd3079c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-07-31 Ed Schonberg <schonberg@adacore.com> + + * gnat.dg/iter3.adb: New testcase. + 2018-07-31 Andre Vieira <andre.simoesdiasvieira@arm.com> Revert 'AsyncI/O patch committed' diff --git a/gcc/testsuite/gnat.dg/iter3.adb b/gcc/testsuite/gnat.dg/iter3.adb new file mode 100644 index 0000000..28c90a1 --- /dev/null +++ b/gcc/testsuite/gnat.dg/iter3.adb @@ -0,0 +1,15 @@ +-- { dg-do compile } +-- { dg-options "-gnata" } + +procedure Iter3 is + type Mod64 is mod 2 ** 64; + + function F (X : Mod64) return Boolean is (X /= Mod64'Last); +begin + pragma Assert (for all X in Mod64 => F(X)); + pragma Assert (for all X in Mod64'Range => F(X)); + + for X in Mod64'Range loop + null; + end loop; +end; |