]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Add External_Initialization extension
authorRonan Desplanques <desplanques@adacore.com>
Mon, 2 Sep 2024 13:38:21 +0000 (15:38 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 8 Oct 2024 08:37:11 +0000 (10:37 +0200)
commit7e09f16ef980883598268b2044b9b370ec3a9611
tree236cd26c5cc9b0f85994488a873a1fe59f2b9240
parent23017cea9c8438865e557782c6c46eb996cf2132
ada: Add External_Initialization extension

This patch introduces a GNAT extension that adds a new aspect,
External_Initialization. A section is added to the reference
manual with a description of what the aspect does.

The implementation reuses existing mechanisms, in particular
Sinput.L.Load_Source_File and Sem_Res.Set_String_Literal_Subtype.

A new node kind is added, and nodes of that type are present in what
is passed to the back ends. That makes it necessary to update the back
ends to handle the new node type. The C interface is extended to make
that possible.

gcc/ada/ChangeLog:
* aspects.ads: Add entities for External_Initialization.
* checks.adb (Selected_Length_Checks): Add support for
N_External_Initializer nodes.
* doc/gnat_rm/gnat_language_extensions.rst: Add section for the added
extension.
* exp_util.adb (Insert_Actions): Add support for N_External_Initializer
nodes.
* fe.h (C_Source_Buffer): New function.
* gen_il-fields.ads: Add new field.
* gen_il-gen-gen_nodes.adb: Add N_External_Initializer node kind.
* gen_il-gen.adb: Add new field type.
* gen_il-types.ads: Add new node kind and new field type.
* pprint.adb (Expr_Name): Handle new node kind.
* sem.adb (Analyze): Add support for N_External_Initializer nodes.
* sem_ch13.adb (Analyze_Aspect_Specifications, Check_Aspect_At_Freeze_Point):
Add support for External_Initialization aspect.
* sem_ch3.adb (Apply_External_Initialization): New subprogram.
(Analyze_Object_Declaration): Add support for External_Initialization aspect.
* sem_res.adb (Resolve_External_Initializer): New procedure.
(Resolve): Add support for N_External_Initializer nodes.
(Set_String_Literal_Subtype): Extend to handle N_External_Initializer nodes.
* sinfo-utils.adb (Is_In_Union_Id): Adapt to new field addition.
* sinfo.ads: Add documentation for new node kind and new field.
* sinput.adb, sinput.ads (C_Source_Buffer): Add new C interface function.
* snames.ads-tmpl: Add new aspect identifier.
* sprint.adb (Sprint_Node_Actual): Add nop handling of N_External_Initializer
nodes.
* types.ads: Modify type to allow for new C interface.
* gcc-interface/trans.cc (gnat_to_gnu): Handle new GNAT node type.
* gcc-interface/Make-lang.in: Update list of stage1 run-time library units.
* gnat-style.texi: Regenerate.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.
26 files changed:
gcc/ada/aspects.ads
gcc/ada/checks.adb
gcc/ada/doc/gnat_rm/gnat_language_extensions.rst
gcc/ada/exp_util.adb
gcc/ada/fe.h
gcc/ada/gcc-interface/Make-lang.in
gcc/ada/gcc-interface/trans.cc
gcc/ada/gen_il-fields.ads
gcc/ada/gen_il-gen-gen_nodes.adb
gcc/ada/gen_il-gen.adb
gcc/ada/gen_il-types.ads
gcc/ada/gnat-style.texi
gcc/ada/gnat_rm.texi
gcc/ada/gnat_ugn.texi
gcc/ada/pprint.adb
gcc/ada/sem.adb
gcc/ada/sem_ch13.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_res.adb
gcc/ada/sinfo-utils.adb
gcc/ada/sinfo.ads
gcc/ada/sinput.adb
gcc/ada/sinput.ads
gcc/ada/snames.ads-tmpl
gcc/ada/sprint.adb
gcc/ada/types.ads