[Ada] Build static dispatch tables always at the end of declarative part
commit5a06e886ac86fd14e02eca0cf70360f1c2d9374f
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 16 May 2022 14:14:46 +0000 (16 16:14 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 2 Jun 2022 09:06:41 +0000 (2 09:06 +0000)
tree8c68561bb5169f50eac157f08f854c70321b82c7
parent57b522c58a03d66f7acd9f4acc7614626aad3280
[Ada] Build static dispatch tables always at the end of declarative part

The static dispatch tables of library-level tagged types are either built
on the first object declaration or at the end of the declarative part of
the package spec or body. There is no real need for the former case, and
the tables are not built for other constructs that freeze (tagged) types.

Therefore this change removes the former case, thus causing the tables to
be always built at the end of the declarative part; that's orthogonal to
freezing and the tagged types are still frozen at the appropriate place.

Moreover, it wraps the code in the Actions list of a freeze node (like
for the nonstatic case) so that it is considered elaboration code by the
processing done in Sem_Elab and does not disturb it.

No functional changes.

gcc/ada/

* exp_ch3.adb (Expand_Freeze_Record_Type): Adjust comment.
(Expand_N_Object_Declaration): Do not build static dispatch tables.
* exp_disp.adb (Make_And_Insert_Dispatch_Table): New procedure.
(Build_Static_Dispatch_Tables): Call it to build the dispatch tables
and wrap them in the Actions list of a freeze node.
gcc/ada/exp_ch3.adb
gcc/ada/exp_disp.adb