[Ada] Compiler failure on an extended_return_statement in a block
authorGary Dismukes <dismukes@adacore.com>
Tue, 31 Jul 2018 09:55:53 +0000 (09:55 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 31 Jul 2018 09:55:53 +0000 (09:55 +0000)
commit76ed5f08f4462d7d22bc6cda3624e131e65bdd52
tree054114f442c2e9e2489c8dd2bcb09c35b7aaed8f
parentc4a2e585d3b4e829f48fcb3c2a825584890b4fda
[Ada] Compiler failure on an extended_return_statement in a block

When compiling with an assertion-enabled compiler, Assert_Failure can be
raised when expanded an extended_return_statement whose enclosing scope
is not a function (such as when it's a block_statement). The simple fix
is to change the Assert to test Current_Subprogram rather than Current_Scope.
Three such Assert pragmas are corrected in this way.

2018-07-31  Gary Dismukes  <dismukes@adacore.com>

gcc/ada/

* exp_ch6.adb (Expand_N_Extended_Return_Statement): Replace
calls to Current_Scope in three assertions with calls to
Current_Subprogram.

gcc/testsuite/

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

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