ada: Fix spurious error in checking of SPARK elaboration
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 2 Dec 2022 09:21:25 +0000 (10:21 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 6 Dec 2022 13:58:48 +0000 (14:58 +0100)
commit0cb36c85ab0c9876dde207d5b93aad7398539c7e
treede01fe4ce5cafc7e9e510a7dc8b84684ec3a55e7
parentea588d41f39428b0c3b02f016353dceb1aaaaa39
ada: Fix spurious error in checking of SPARK elaboration

The problem is that the computation of early call regions skips freeze nodes
but scenarios involving procedures declared as actions of these freeze nodes
are taken into account.  As a consequence if a subprogram body, typically of
an expression function, is placed just after a freeze node, its early call
region depends on whether the construct just before the freeze node can be
preelaborated or not; in other words, the legality of calls made from the
actions of this freeze node to the subprogram depends on what happens ahead
of the freeze node, which may be totally unrelated to the situation.

This change disables the ABE diagnostics in this case, as is done in a few
other similar cases leading to bogus errors too.

gcc/ada/

* sem_elab.adb (Processing_In_State): Add Within_Freezing_Actions
component.
(Process_Conditional_ABE_Call): Compute its value.
(Process_Conditional_ABE_Call_SPARK): For a call and a target in
the main unit, do not emit any ABE diagnostics if the call occurs
in a freezing actions context.
gcc/ada/sem_elab.adb