ada: Attach pre/post on access-to-subprogram to internal subprogram type
commit11f406ee4747e48a9b0e34aa6f6b3cdb38665a1b
authorPiotr Trojanek <trojanek@adacore.com>
Sun, 2 Apr 2023 12:47:49 +0000 (2 14:47 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 29 May 2023 08:23:21 +0000 (29 10:23 +0200)
tree6e39edb72405c43c38f74c1662785a2f96011546
parent8bb536cc97645208482ec3303d1cf9f99f95b42c
ada: Attach pre/post on access-to-subprogram to internal subprogram type

Aspects Pre/Post that annotate access-to-subprogram type were attached
to the source entity (whose kind is either E_Access_Subprogram_Type or
E_Access_Protected_Subprogram_Type). However, it is more convenient to
attach them to the internal entity (whose kind is E_Subprogram_Type), so
that both Pre/Post aspects and First_Formal/Next_Formal chain are
attached to the same entity, just like for ordinary subprograms.

The drawback of having the Post aspect attached to an internal entity is
that name in prefixes of attribute Result no longer match the name of
entity where this Post aspect is attached. However, currently there is
no code that relies on this matching and, in general, there are fewer
routines that deal with attribute Result so they are easier to adapt
than the code that queries the Pre/Post aspects.

gcc/ada/

* contracts.adb
(Add_Pre_Post_Condition): Attach pre/post aspects to E_Subprogram_Type
entity.
(Analyze_Entry_Or_Subprogram_Contract): Adapt to use full type
declaration for a contract attached to E_Subprogram_Type entity.
* sem_prag.adb
(Analyze_Pre_Post_Condition): Add pre/post aspects to the designed type.
gcc/ada/contracts.adb
gcc/ada/sem_prag.adb