[Ada] Handle bodies-to-inline just like generic templates
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 6 Jul 2022 07:37:15 +0000 (09:37 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 13 Jul 2022 10:01:17 +0000 (10:01 +0000)
commita714ca803cbf2f9e26ca214d7ddd7ed65bac2c26
treefeb9d383d4a3b7c08be4a420149701bac68c41c7
parent4621bae835be11ae4ec81d5842166e819826459c
[Ada] Handle bodies-to-inline just like generic templates

Originally bodies-to-inline created for the frontend inlining were
analyzed with expansion disabled. Then, to facilitate inlining in
GNATprove mode, the analysis was changed to preanalysis.

However, preanalysis in this context works badly for calls in prefix
notation, because preanalysis assigns entities and types to nodes but
doesn't convert calls from prefix to ordinary notation. When the
body-to-inline is actually inlined, the (re)analysis of calls in prefix
notation fails.

The proper solution is rather to handle bodies-to-inline just like
generic templates.

From the user point of view, this patch fixes spurious errors both in
GNATprove (which uses frontend inlining by default) and in GNAT (where
frontend inlining is typically explicitly requested with -gnatN and
pragma Inline_Always).

gcc/ada/

* inline.adb (Build_Body_To_Inline): Instead of manipulating the
Full_Analysis flag, use the Inside_A_Generic flag (which is
conveniently manipulated by Start_Generic/End_Generic, together
with Expander_Active).
* sem_attr.adb (Analyze_Attribute_Old_Result): Adapt comment and
assertion to different flag that is set while building
body-to-inline.
gcc/ada/inline.adb
gcc/ada/sem_attr.adb