[Ada] Compile-time evaluation of predicate checks
authorEd Schonberg <schonberg@adacore.com>
Thu, 11 Jul 2019 08:01:54 +0000 (08:01 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Thu, 11 Jul 2019 08:01:54 +0000 (08:01 +0000)
commita081ded4df03e30cd4aefa1e946eb31aa423bfb2
tree013e6f55feb3e4e9d186337e498d82b74d5e482c
parentdd8b4c118e15b03a9f8ca748be0c3415e8df788a
[Ada] Compile-time evaluation of predicate checks

This patch recognizes case of dynamic predicates on integer subtypes
that are simple enough to be evaluated statically when the argument is
itself a literal. Even though in many cases such predicate checks will
be removed by the back-end with any level of optimization, it is
preferable to perform this constant folding in the front-end, wich also
cleans up the output of CCG, as well as producing explicit warnings when
the test will fail.

2019-07-11  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* exp_ch6.adb (Can_Fold_Predicate_Call): New function,
subsidiary of Expand_Call_Helper, to compute statically a
predicate check when the argument is a static integer.

gcc/testsuite/

* gnat.dg/predicate11.adb: New testcase.

From-SVN: r273386
gcc/ada/ChangeLog
gcc/ada/exp_ch6.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/predicate11.adb [new file with mode: 0644]