]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/ada/checks.adb
[Ada] Compiler abort on a dynamic predicate used in a precondition
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Jul 2019 07:02:03 +0000 (07:02 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Jul 2019 07:02:03 +0000 (07:02 +0000)
commit164597c57dab38f44f912afdd90259ee6b8b99fd
treea986027d4dac11bec4c8e61a041e512a5d4d41aa
parent572a4bc50d4e5047f9094d3bd069d44bb42563a8
[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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@273106 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ada/ChangeLog
gcc/ada/checks.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/predicate7.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/predicate7.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/predicate7_pkg.ads [new file with mode: 0644]