[Ada] Missing predicate check on return value
The semantics of the return statement includes an implicit conversion of
the value to the return type of the funcction. This conversion, as
elsewhere, entails a predicate check if the return type has a predicate
aspect.
We do not apply the check to a case expression because in the context of
a return statement it will be expanded into a series of return
statements, each of which will receive a predicate check.
2018-09-26 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch6.adb (Analyze_Function_Return): If the return type has
a dynamic_predicate, apply a Predicate_Check to the expression,
given that it is implicitly converted to the return type.
Exclude case expressions from the check, because in this context
the expression is expanded into individual return statements.
gcc/testsuite/
* gnat.dg/predicate3.adb, gnat.dg/predicate3_pkg.ads: New
testcase.
From-SVN: r264611