[Ada] Compiler abort on a dynamic predicate used in a precondition
This patch suppresses the generation of a predicate check when the expression is a formal IN parameter of a subprogram S. If the check is being applied to the actual in a call, the call is either in the body of S, or in an aspect specfication for S, e.g. a precondition, In both cases the check is redundant bevause it will be applied on any call to S. In the second case the expansion of the predicate check may lead to out-of-scope references the the formal. 2019-07-05 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * checks.adb (Apply_Predicate_Check): Except within the subprogram body that defines the formal, do not apply predicate check on a formal IN parameter: such a check is redundant and its expansion can lead to out-of-scope references when it is originates in a function call in a precondition, gcc/testsuite/ * gnat.dg/predicate7.adb, gnat.dg/predicate7.ads, gnat.dg/predicate7_pkg.ads: New testcase. From-SVN: r273106
Showing
gcc/testsuite/gnat.dg/predicate7.adb
0 → 100644
gcc/testsuite/gnat.dg/predicate7.ads
0 → 100644
gcc/testsuite/gnat.dg/predicate7_pkg.ads
0 → 100644
Please
register
or
sign in
to comment