Aspect_Dispatching_Domain,
Aspect_Dynamic_Predicate,
Aspect_Exceptional_Cases, -- GNAT
+ Aspect_External_Initialization, -- GNAT
Aspect_External_Name,
Aspect_External_Tag,
Aspect_Finalizable, -- GNAT
Aspect_Effective_Writes => True,
Aspect_Exceptional_Cases => True,
Aspect_Extensions_Visible => True,
+ Aspect_External_Initialization => True,
Aspect_Favor_Top_Level => True,
Aspect_Finalizable => True,
Aspect_First_Controlling_Parameter => True,
Aspect_Dispatching_Domain => Expression,
Aspect_Dynamic_Predicate => Expression,
Aspect_Exceptional_Cases => Expression,
+ Aspect_External_Initialization => Expression,
Aspect_External_Name => Expression,
Aspect_External_Tag => Expression,
Aspect_Finalizable => Expression,
Aspect_Dynamic_Predicate => False,
Aspect_Exceptional_Cases => False,
Aspect_Exclusive_Functions => False,
+ Aspect_External_Initialization => False,
Aspect_External_Name => False,
Aspect_External_Tag => False,
Aspect_Finalizable => False,
Aspect_Exclusive_Functions => Name_Exclusive_Functions,
Aspect_Export => Name_Export,
Aspect_Extensions_Visible => Name_Extensions_Visible,
+ Aspect_External_Initialization => Name_External_Initialization,
Aspect_External_Name => Name_External_Name,
Aspect_External_Tag => Name_External_Tag,
Aspect_Favor_Top_Level => Name_Favor_Top_Level,
Aspect_Exceptional_Cases => Never_Delay,
Aspect_Export => Never_Delay,
Aspect_Extensions_Visible => Never_Delay,
+ Aspect_External_Initialization => Never_Delay,
Aspect_First_Controlling_Parameter => Never_Delay,
Aspect_Ghost => Never_Delay,
Aspect_Global => Never_Delay,
-- T_Typ'Length = string-literal-length
- if Nkind (Expr_Actual) = N_String_Literal
+ -- The above also applies to the External_Initializer case.
+
+ if Nkind (Expr_Actual) in N_String_Literal | N_External_Initializer
and then Ekind (Etype (Expr_Actual)) = E_String_Literal_Subtype
then
Cond :=
Link to the original RFC:
https://github.com/AdaCore/ada-spark-rfcs/blob/topic/generic_instantiations/considered/rfc-inference-of-dependent-types.md
+
+External_Initialization Aspect
+------------------------------
+
+The ``External_Initialization`` aspect provides a feature similar to Rust's ``include_bytes!``
+and to C23's ``#embed``. It has the effect of initializing an object with the contents of
+a file specified by a file path.
+
+Only string objects and objects of type ``Ada.Streams.Stream_Element_Array`` can be subject
+to the ``External_Initialization`` aspect.
+
+Example:
+
+.. code-block:: ada
+
+ with Ada.Streams;
+
+ package P is
+ S : constant String with External_Initialization => "foo.txt";
+
+ X : constant Ada.Streams.Stream_Element_Array with External_Initialization => "bar.bin";
+ end P;
+
+Link to the original RFC:
+https://github.com/AdaCore/ada-spark-rfcs/blob/master/considered/rfc-embed-binary-resources.rst
| N_Expanded_Name
| N_Explicit_Dereference
| N_Extension_Aggregate
+ | N_External_Initializer
| N_Floating_Point_Definition
| N_Formal_Decimal_Fixed_Point_Definition
| N_Formal_Derived_Type_Definition
/* sinput: */
+struct c_array {
+ char *pointer;
+ int length;
+};
+
+#define C_Source_Buffer sinput__c_source_buffer
#define Debug_Source_Name sinput__debug_source_name
#define Get_Column_Number sinput__get_column_number
#define Get_Logical_Line_Number sinput__get_logical_line_number
#define Get_Source_File_Index sinput__get_source_file_index
+extern struct c_array C_Source_Buffer (Source_File_Index);
extern File_Name_Type Debug_Source_Name (Source_File_Index);
extern Column_Number_Type Get_Column_Number (Source_Ptr);
extern Line_Number_Type Get_Logical_Line_Number (Source_Ptr);
ada/libgnat/g-speche.o \
ada/libgnat/g-table.o \
ada/libgnat/g-u3spch.o \
+ ada/libgnat/i-c.o \
ada/libgnat/interfac.o \
ada/libgnat/s-addope.o \
ada/libgnat/s-addima.o \
ada/libgnat/g-byorma.o \
ada/libgnat/g-hesora.o \
ada/libgnat/g-htable.o \
+ ada/libgnat/i-c.o \
ada/libgnat/interfac.o \
ada/libgnat/s-addope.o \
ada/libgnat/s-assert.o \
gnu_result = build_atomic_load (gnu_result, aa_sync);
break;
+ case N_External_Initializer:
+ {
+ gnu_result_type = get_unpadded_type (Etype (gnat_node));
+ struct c_array a = C_Source_Buffer (File_Index (gnat_node));
+
+ gnu_result = build_string ((unsigned) a.length, a.pointer);
+
+ TREE_TYPE (gnu_result) = gnu_result_type;
+ }
+ break;
+
case N_Integer_Literal:
{
tree gnu_type;
Expression,
Expression_Copy,
Expressions,
+ File_Index,
First_Bit,
First_Inlined_Subprogram,
First_Name,
(Sy (Actions, List_Id, Default_No_List),
Sy (Expression, Node_Id, Default_Empty)));
+ Cc (N_External_Initializer, N_Subexpr,
+ (Sy (File_Index, Source_File_Index)));
+
Cc (N_If_Expression, N_Subexpr,
(Sy (Expressions, List_Id, Default_No_List),
Sy (Is_Elsif, Flag),
| Uint
| Uint_Subtype
| Ureal
+ | Source_File_Index
| Source_Ptr
| Union_Id
| Node_Id
Upos,
Nonzero_Uint,
Ureal,
+ Source_File_Index,
Node_Kind_Type, -- Type of result of Nkind function, i.e. Node_Kind
Entity_Kind_Type, -- Type of result of Ekind function, i.e. Entity_Kind
N_String_Literal,
N_Explicit_Dereference,
N_Expression_With_Actions,
+ N_External_Initializer,
N_If_Expression,
N_Indexed_Component,
N_Interpolated_String_Literal,
@setfilename gnat-style.info
@documentencoding UTF-8
@ifinfo
-@*Generated by Sphinx 5.3.0.@*
+@*Generated by Sphinx 8.0.2.@*
@end ifinfo
@settitle GNAT Coding Style A Guide for GNAT Developers
@defindex ge
@copying
@quotation
-GNAT Coding Style: A Guide for GNAT Developers , Dec 21, 2023
+GNAT Coding Style: A Guide for GNAT Developers , Oct 07, 2024
AdaCore
@setfilename gnat_rm.info
@documentencoding UTF-8
@ifinfo
-@*Generated by Sphinx 5.3.0.@*
+@*Generated by Sphinx 8.0.2.@*
@end ifinfo
@settitle GNAT Reference Manual
@defindex ge
@copying
@quotation
-GNAT Reference Manual , Aug 30, 2024
+GNAT Reference Manual , Oct 07, 2024
AdaCore
* Mutably Tagged Types with Size’Class Aspect::
* Generalized Finalization::
* Inference of Dependent Types in Generic Instantiations::
+* External_Initialization Aspect::
Security Hardening Features
The fourth form, with an @code{On|Off} parameter and a string, is used to
control individual messages, based on their text. The string argument
is a pattern that is used to match against the text of individual
-warning messages (not including the initial â\80\9cwarning: â\80\9d tag).
+warning messages (not including the initial â\80\9cwarning: â\80\9c tag).
The pattern may contain asterisks, which match zero or more characters in
the message. For example, you can use
* Mutably Tagged Types with Size’Class Aspect::
* Generalized Finalization::
* Inference of Dependent Types in Generic Instantiations::
+* External_Initialization Aspect::
@end menu
Link to the original RFC:
@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/topic/finalization-rehaul/considered/rfc-generalized-finalization.md}
-@node Inference of Dependent Types in Generic Instantiations,,Generalized Finalization,Experimental Language Extensions
+@node Inference of Dependent Types in Generic Instantiations,External_Initialization Aspect,Generalized Finalization,Experimental Language Extensions
@anchor{gnat_rm/gnat_language_extensions inference-of-dependent-types-in-generic-instantiations}@anchor{455}
@subsection Inference of Dependent Types in Generic Instantiations
Link to the original RFC:
@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/topic/generic_instantiations/considered/rfc-inference-of-dependent-types.md}
+@node External_Initialization Aspect,,Inference of Dependent Types in Generic Instantiations,Experimental Language Extensions
+@anchor{gnat_rm/gnat_language_extensions external-initialization-aspect}@anchor{456}
+@subsection External_Initialization Aspect
+
+
+The @code{External_Initialization} aspect provides a feature similar to Rust’s @code{include_bytes!}
+and to C23’s @code{#embed}. It has the effect of initializing an object with the contents of
+a file specified by a file path.
+
+Only string objects and objects of type @code{Ada.Streams.Stream_Element_Array} can be subject
+to the @code{External_Initialization} aspect.
+
+Example:
+
+@example
+with Ada.Streams;
+
+package P is
+ S : constant String with External_Initialization => "foo.txt";
+
+ X : constant Ada.Streams.Stream_Element_Array with External_Initialization => "bar.bin";
+end P;
+@end example
+
+Link to the original RFC:
+@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/considered/rfc-embed-binary-resources.rst}
+
@node Security Hardening Features,Obsolescent Features,GNAT language extensions,Top
-@anchor{gnat_rm/security_hardening_features doc}@anchor{456}@anchor{gnat_rm/security_hardening_features id1}@anchor{457}@anchor{gnat_rm/security_hardening_features security-hardening-features}@anchor{15}
+@anchor{gnat_rm/security_hardening_features doc}@anchor{457}@anchor{gnat_rm/security_hardening_features id1}@anchor{458}@anchor{gnat_rm/security_hardening_features security-hardening-features}@anchor{15}
@chapter Security Hardening Features
@end menu
@node Register Scrubbing,Stack Scrubbing,,Security Hardening Features
-@anchor{gnat_rm/security_hardening_features register-scrubbing}@anchor{458}
+@anchor{gnat_rm/security_hardening_features register-scrubbing}@anchor{459}
@section Register Scrubbing
@c Stack Scrubbing:
@node Stack Scrubbing,Hardened Conditionals,Register Scrubbing,Security Hardening Features
-@anchor{gnat_rm/security_hardening_features stack-scrubbing}@anchor{459}
+@anchor{gnat_rm/security_hardening_features stack-scrubbing}@anchor{45a}
@section Stack Scrubbing
@c Hardened Conditionals:
@node Hardened Conditionals,Hardened Booleans,Stack Scrubbing,Security Hardening Features
-@anchor{gnat_rm/security_hardening_features hardened-conditionals}@anchor{45a}
+@anchor{gnat_rm/security_hardening_features hardened-conditionals}@anchor{45b}
@section Hardened Conditionals
@c Hardened Booleans:
@node Hardened Booleans,Control Flow Redundancy,Hardened Conditionals,Security Hardening Features
-@anchor{gnat_rm/security_hardening_features hardened-booleans}@anchor{45b}
+@anchor{gnat_rm/security_hardening_features hardened-booleans}@anchor{45c}
@section Hardened Booleans
@c Control Flow Redundancy:
@node Control Flow Redundancy,,Hardened Booleans,Security Hardening Features
-@anchor{gnat_rm/security_hardening_features control-flow-redundancy}@anchor{45c}
+@anchor{gnat_rm/security_hardening_features control-flow-redundancy}@anchor{45d}
@section Control Flow Redundancy
can be used with other programming languages supported by GCC.
@node Obsolescent Features,Compatibility and Porting Guide,Security Hardening Features,Top
-@anchor{gnat_rm/obsolescent_features doc}@anchor{45d}@anchor{gnat_rm/obsolescent_features id1}@anchor{45e}@anchor{gnat_rm/obsolescent_features obsolescent-features}@anchor{16}
+@anchor{gnat_rm/obsolescent_features doc}@anchor{45e}@anchor{gnat_rm/obsolescent_features id1}@anchor{45f}@anchor{gnat_rm/obsolescent_features obsolescent-features}@anchor{16}
@chapter Obsolescent Features
@end menu
@node pragma No_Run_Time,pragma Ravenscar,,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features id2}@anchor{45f}@anchor{gnat_rm/obsolescent_features pragma-no-run-time}@anchor{460}
+@anchor{gnat_rm/obsolescent_features id2}@anchor{460}@anchor{gnat_rm/obsolescent_features pragma-no-run-time}@anchor{461}
@section pragma No_Run_Time
includes just those features that are to be made accessible.
@node pragma Ravenscar,pragma Restricted_Run_Time,pragma No_Run_Time,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features id3}@anchor{461}@anchor{gnat_rm/obsolescent_features pragma-ravenscar}@anchor{462}
+@anchor{gnat_rm/obsolescent_features id3}@anchor{462}@anchor{gnat_rm/obsolescent_features pragma-ravenscar}@anchor{463}
@section pragma Ravenscar
is part of the new Ada 2005 standard.
@node pragma Restricted_Run_Time,pragma Task_Info,pragma Ravenscar,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features id4}@anchor{463}@anchor{gnat_rm/obsolescent_features pragma-restricted-run-time}@anchor{464}
+@anchor{gnat_rm/obsolescent_features id4}@anchor{464}@anchor{gnat_rm/obsolescent_features pragma-restricted-run-time}@anchor{465}
@section pragma Restricted_Run_Time
this kind of implementation dependent addition.
@node pragma Task_Info,package System Task_Info s-tasinf ads,pragma Restricted_Run_Time,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features id5}@anchor{465}@anchor{gnat_rm/obsolescent_features pragma-task-info}@anchor{466}
+@anchor{gnat_rm/obsolescent_features id5}@anchor{466}@anchor{gnat_rm/obsolescent_features pragma-task-info}@anchor{467}
@section pragma Task_Info
library.
@node package System Task_Info s-tasinf ads,,pragma Task_Info,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features package-system-task-info}@anchor{467}@anchor{gnat_rm/obsolescent_features package-system-task-info-s-tasinf-ads}@anchor{468}
+@anchor{gnat_rm/obsolescent_features package-system-task-info}@anchor{468}@anchor{gnat_rm/obsolescent_features package-system-task-info-s-tasinf-ads}@anchor{469}
@section package System.Task_Info (@code{s-tasinf.ads})
standard replacement for GNAT’s @code{Task_Info} functionality.
@node Compatibility and Porting Guide,GNU Free Documentation License,Obsolescent Features,Top
-@anchor{gnat_rm/compatibility_and_porting_guide doc}@anchor{469}@anchor{gnat_rm/compatibility_and_porting_guide compatibility-and-porting-guide}@anchor{17}@anchor{gnat_rm/compatibility_and_porting_guide id1}@anchor{46a}
+@anchor{gnat_rm/compatibility_and_porting_guide doc}@anchor{46a}@anchor{gnat_rm/compatibility_and_porting_guide compatibility-and-porting-guide}@anchor{17}@anchor{gnat_rm/compatibility_and_porting_guide id1}@anchor{46b}
@chapter Compatibility and Porting Guide
@end menu
@node Writing Portable Fixed-Point Declarations,Compatibility with Ada 83,,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide id2}@anchor{46b}@anchor{gnat_rm/compatibility_and_porting_guide writing-portable-fixed-point-declarations}@anchor{46c}
+@anchor{gnat_rm/compatibility_and_porting_guide id2}@anchor{46c}@anchor{gnat_rm/compatibility_and_porting_guide writing-portable-fixed-point-declarations}@anchor{46d}
@section Writing Portable Fixed-Point Declarations
types will be portable.
@node Compatibility with Ada 83,Compatibility between Ada 95 and Ada 2005,Writing Portable Fixed-Point Declarations,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-ada-83}@anchor{46d}@anchor{gnat_rm/compatibility_and_porting_guide id3}@anchor{46e}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-ada-83}@anchor{46e}@anchor{gnat_rm/compatibility_and_porting_guide id3}@anchor{46f}
@section Compatibility with Ada 83
@end menu
@node Legal Ada 83 programs that are illegal in Ada 95,More deterministic semantics,,Compatibility with Ada 83
-@anchor{gnat_rm/compatibility_and_porting_guide id4}@anchor{46f}@anchor{gnat_rm/compatibility_and_porting_guide legal-ada-83-programs-that-are-illegal-in-ada-95}@anchor{470}
+@anchor{gnat_rm/compatibility_and_porting_guide id4}@anchor{470}@anchor{gnat_rm/compatibility_and_porting_guide legal-ada-83-programs-that-are-illegal-in-ada-95}@anchor{471}
@subsection Legal Ada 83 programs that are illegal in Ada 95
@end itemize
@node More deterministic semantics,Changed semantics,Legal Ada 83 programs that are illegal in Ada 95,Compatibility with Ada 83
-@anchor{gnat_rm/compatibility_and_porting_guide id5}@anchor{471}@anchor{gnat_rm/compatibility_and_porting_guide more-deterministic-semantics}@anchor{472}
+@anchor{gnat_rm/compatibility_and_porting_guide id5}@anchor{472}@anchor{gnat_rm/compatibility_and_porting_guide more-deterministic-semantics}@anchor{473}
@subsection More deterministic semantics
@end itemize
@node Changed semantics,Other language compatibility issues,More deterministic semantics,Compatibility with Ada 83
-@anchor{gnat_rm/compatibility_and_porting_guide changed-semantics}@anchor{473}@anchor{gnat_rm/compatibility_and_porting_guide id6}@anchor{474}
+@anchor{gnat_rm/compatibility_and_porting_guide changed-semantics}@anchor{474}@anchor{gnat_rm/compatibility_and_porting_guide id6}@anchor{475}
@subsection Changed semantics
@end itemize
@node Other language compatibility issues,,Changed semantics,Compatibility with Ada 83
-@anchor{gnat_rm/compatibility_and_porting_guide id7}@anchor{475}@anchor{gnat_rm/compatibility_and_porting_guide other-language-compatibility-issues}@anchor{476}
+@anchor{gnat_rm/compatibility_and_porting_guide id7}@anchor{476}@anchor{gnat_rm/compatibility_and_porting_guide other-language-compatibility-issues}@anchor{477}
@subsection Other language compatibility issues
@end itemize
@node Compatibility between Ada 95 and Ada 2005,Implementation-dependent characteristics,Compatibility with Ada 83,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide compatibility-between-ada-95-and-ada-2005}@anchor{477}@anchor{gnat_rm/compatibility_and_porting_guide id8}@anchor{478}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-between-ada-95-and-ada-2005}@anchor{478}@anchor{gnat_rm/compatibility_and_porting_guide id8}@anchor{479}
@section Compatibility between Ada 95 and Ada 2005
@end itemize
@node Implementation-dependent characteristics,Compatibility with Other Ada Systems,Compatibility between Ada 95 and Ada 2005,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide id9}@anchor{479}@anchor{gnat_rm/compatibility_and_porting_guide implementation-dependent-characteristics}@anchor{47a}
+@anchor{gnat_rm/compatibility_and_porting_guide id9}@anchor{47a}@anchor{gnat_rm/compatibility_and_porting_guide implementation-dependent-characteristics}@anchor{47b}
@section Implementation-dependent characteristics
@end menu
@node Implementation-defined pragmas,Implementation-defined attributes,,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide id10}@anchor{47b}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-pragmas}@anchor{47c}
+@anchor{gnat_rm/compatibility_and_porting_guide id10}@anchor{47c}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-pragmas}@anchor{47d}
@subsection Implementation-defined pragmas
relevant in a GNAT context and hence are not otherwise implemented.
@node Implementation-defined attributes,Libraries,Implementation-defined pragmas,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide id11}@anchor{47d}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-attributes}@anchor{47e}
+@anchor{gnat_rm/compatibility_and_porting_guide id11}@anchor{47e}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-attributes}@anchor{47f}
@subsection Implementation-defined attributes
@code{Type_Class}.
@node Libraries,Elaboration order,Implementation-defined attributes,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide id12}@anchor{47f}@anchor{gnat_rm/compatibility_and_porting_guide libraries}@anchor{480}
+@anchor{gnat_rm/compatibility_and_porting_guide id12}@anchor{480}@anchor{gnat_rm/compatibility_and_porting_guide libraries}@anchor{481}
@subsection Libraries
@end itemize
@node Elaboration order,Target-specific aspects,Libraries,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide elaboration-order}@anchor{481}@anchor{gnat_rm/compatibility_and_porting_guide id13}@anchor{482}
+@anchor{gnat_rm/compatibility_and_porting_guide elaboration-order}@anchor{482}@anchor{gnat_rm/compatibility_and_porting_guide id13}@anchor{483}
@subsection Elaboration order
@end itemize
@node Target-specific aspects,,Elaboration order,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide id14}@anchor{483}@anchor{gnat_rm/compatibility_and_porting_guide target-specific-aspects}@anchor{484}
+@anchor{gnat_rm/compatibility_and_porting_guide id14}@anchor{484}@anchor{gnat_rm/compatibility_and_porting_guide target-specific-aspects}@anchor{485}
@subsection Target-specific aspects
Ada 2005 and Ada 2012) are sometimes
incompatible with typical Ada 83 compiler practices regarding implicit
packing, the meaning of the Size attribute, and the size of access values.
-GNAT’s approach to these issues is described in @ref{485,,Representation Clauses}.
+GNAT’s approach to these issues is described in @ref{486,,Representation Clauses}.
@node Compatibility with Other Ada Systems,Representation Clauses,Implementation-dependent characteristics,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-other-ada-systems}@anchor{486}@anchor{gnat_rm/compatibility_and_porting_guide id15}@anchor{487}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-other-ada-systems}@anchor{487}@anchor{gnat_rm/compatibility_and_porting_guide id15}@anchor{488}
@section Compatibility with Other Ada Systems
@end itemize
@node Representation Clauses,Compatibility with HP Ada 83,Compatibility with Other Ada Systems,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide id16}@anchor{488}@anchor{gnat_rm/compatibility_and_porting_guide representation-clauses}@anchor{485}
+@anchor{gnat_rm/compatibility_and_porting_guide id16}@anchor{489}@anchor{gnat_rm/compatibility_and_porting_guide representation-clauses}@anchor{486}
@section Representation Clauses
@end itemize
@node Compatibility with HP Ada 83,,Representation Clauses,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-hp-ada-83}@anchor{489}@anchor{gnat_rm/compatibility_and_porting_guide id17}@anchor{48a}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-hp-ada-83}@anchor{48a}@anchor{gnat_rm/compatibility_and_porting_guide id17}@anchor{48b}
@section Compatibility with HP Ada 83
@end itemize
@node GNU Free Documentation License,Index,Compatibility and Porting Guide,Top
-@anchor{share/gnu_free_documentation_license doc}@anchor{48b}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{48c}
+@anchor{share/gnu_free_documentation_license doc}@anchor{48c}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{48d}
@chapter GNU Free Documentation License
@setfilename gnat_ugn.info
@documentencoding UTF-8
@ifinfo
-@*Generated by Sphinx 5.3.0.@*
+@*Generated by Sphinx 8.0.2.@*
@end ifinfo
@settitle GNAT User's Guide for Native Platforms
@defindex ge
@copying
@quotation
-GNAT User's Guide for Native Platforms , Aug 30, 2024
+GNAT User's Guide for Native Platforms , Oct 07, 2024
AdaCore
`[warning-as-error]'
Used to tag warning messages that have been converted to error messages by
use of the pragma Warning_As_Error. Note that such warnings are prefixed by
-the string â\80\9cerror: â\80\9d rather than “warning: “.
+the string â\80\9cerror: â\80\9c rather than “warning: “.
@item
`[enabled by default]'
drop the @code{-no-pie} workaround, you’ll need to get the identified
dependencies rebuilt with PIE enabled (compiled with @code{-fPIE}
and linked with @code{-pie}).
-@anchor{gnat_ugn/platform_specific_information choosing-the-scheduling-policy-with-gnu-linux}@anchor{1c2}
+
@geindex SCHED_FIFO scheduling policy
@geindex SCHED_RR scheduling policy
@geindex SCHED_OTHER scheduling policy
-
+@anchor{gnat_ugn/platform_specific_information choosing-the-scheduling-policy-with-gnu-linux}@anchor{1c2}
@node Choosing the Scheduling Policy with GNU/Linux,A GNU/Linux Debug Quirk,Position Independent Executable PIE Enabled by Default on Linux,GNU/Linux Topics
@anchor{gnat_ugn/platform_specific_information id7}@anchor{1c3}
@subsection Choosing the Scheduling Policy with GNU/Linux
when N_Case_Expression
| N_Delta_Aggregate
+ | N_External_Initializer
| N_Interpolated_String_Literal
| N_Op_Rotate_Left
| N_Op_Rotate_Right
when N_Extension_Aggregate =>
Analyze_Aggregate (N);
+ -- The expansion of the External_Initialization aspect creates fully
+ -- analyzed N_External_Initializer nodes.
+
+ when N_External_Initializer =>
+ null;
+
when N_Formal_Object_Declaration =>
Analyze_Formal_Object_Declaration (N);
Chars => Name_Storage_Size,
Expression => Relocate_Node (Expr));
end if;
+
+ when Aspect_External_Initialization =>
+ Error_Msg_GNAT_Extension
+ ("External_Initialization aspect", Sloc (Aspect));
+
+ -- The External_Initialization aspect specifications that
+ -- are attached to object declarations were already
+ -- processed and detached from the list at an earlier stage,
+ -- so we can only get here if the specification is not in an
+ -- appropriate place.
+
+ Error_Msg_N
+ ("External_Initialization aspect can only be specified " &
+ "for object declarations", Aspect);
end case;
-- Attach the corresponding pragma/attribute definition clause to
| Aspect_Dimension
| Aspect_Dimension_System
| Aspect_Exceptional_Cases
+ | Aspect_External_Initialization
| Aspect_Global
| Aspect_GNAT_Annotate
| Aspect_Implicit_Dereference
with Sinfo.Nodes; use Sinfo.Nodes;
with Sinfo.Utils; use Sinfo.Utils;
with Sinput; use Sinput;
+with Sinput.L;
with Snames; use Snames;
+with Stringt;
with Strub; use Strub;
with Targparm; use Targparm;
with Tbuild; use Tbuild;
-- E is set to Expression (N) throughout this routine. When Expression
-- (N) is modified, E is changed accordingly.
+ procedure Apply_External_Initialization
+ (Specification : N_Aspect_Specification_Id);
+ -- Transform N with the effects of the External_Initialization aspect
+ -- specified by Specification. Note that Specification is removed from
+ -- N's list of aspects.
+
procedure Check_Dynamic_Object (Typ : Entity_Id);
-- A library-level object with nonstatic discriminant constraints may
-- require dynamic allocation. The declaration is illegal if the
-- Any other relevant delayed aspects on object declarations ???
+ -----------------------------------
+ -- Apply_External_Initialization --
+ -----------------------------------
+
+ procedure Apply_External_Initialization
+ (Specification : N_Aspect_Specification_Id)
+ is
+ Def : constant Node_Id := Expression (Specification);
+
+ Expr : N_Subexpr_Id;
+
+ begin
+ Remove (Specification);
+
+ Error_Msg_GNAT_Extension
+ ("External_Initialization aspect", Sloc (Specification));
+
+ if Present (E) then
+ Error_Msg_N
+ ("initialization expression not allowed for object with aspect "
+ & "External_Initialization", Specification);
+ return;
+ end if;
+
+ Set_Has_Init_Expression (N);
+ Set_Expression (N, Error);
+ E := Error;
+
+ if Nkind (Def) /= N_String_Literal then
+ Error_Msg_N
+ ("External_Initialization aspect expects a string literal value",
+ Specification);
+ return;
+ end if;
+
+ if not (Is_String_Type (T)
+ or else Is_RTE (Base_Type (T), RE_Stream_Element_Array))
+ then
+ Error_Msg_N
+ ("External_Initialization aspect can only be applied to objects "
+ & "of string types or type Ada.Streams.Stream_Element_Array",
+ Specification);
+ return;
+ end if;
+
+ begin
+ declare
+ Name : constant Valid_Name_Id :=
+ Stringt.String_To_Name (Strval (Def));
+
+ Source_File_I : constant Source_File_Index :=
+ Sinput.L.Load_Source_File (File_Name_Type (Name));
+ begin
+ if Source_File_I <= No_Source_File then
+ Error_Msg_N ("cannot find input file", Specification);
+ return;
+ end if;
+
+ Expr :=
+ Make_External_Initializer
+ (Sloc (Specification), Source_File_I);
+ end;
+ exception
+ when Constraint_Error =>
+ -- The most likely cause for a constraint error is a file
+ -- whose size does not fit into Integer. We could modify
+ -- Load_Source_File to report that error with a special
+ -- exception???
+ Error_Msg_N
+ ("External_Initialization file exceeds maximum length",
+ Specification);
+ return;
+ end;
+
+ Set_Expression (N, Expr);
+ E := Expr;
+ end Apply_External_Initialization;
+
--------------------------
-- Check_Dynamic_Object --
--------------------------
end if;
end if;
+ declare
+ S : constant Opt_N_Aspect_Specification_Id :=
+ Find_Aspect (Id, Aspect_External_Initialization);
+ begin
+ if Present (S) then
+ Apply_External_Initialization (S);
+ end if;
+ end;
+
-- Ada 2005 (AI-231): Propagate the null-excluding attribute and carry
-- out some static checks.
end if;
end if;
- -- Case of initialization present but in error. Set initial
- -- expression as absent (but do not make above complaints).
+ -- Case of initialization present but in error
elsif E = Error then
- Set_Expression (N, Empty);
- E := Empty;
+ null;
-- Case of initialization present
with Sinfo.Nodes; use Sinfo.Nodes;
with Sinfo.Utils; use Sinfo.Utils;
with Sinfo.CN; use Sinfo.CN;
+with Sinput; use Sinput;
with Snames; use Snames;
with Stand; use Stand;
with Stringt; use Stringt;
procedure Resolve_Equality_Op (N : Node_Id; Typ : Entity_Id);
procedure Resolve_Explicit_Dereference (N : Node_Id; Typ : Entity_Id);
procedure Resolve_Expression_With_Actions (N : Node_Id; Typ : Entity_Id);
+ procedure Resolve_External_Initializer (N : Node_Id; Typ : Entity_Id);
procedure Resolve_If_Expression (N : Node_Id; Typ : Entity_Id);
procedure Resolve_Generalized_Indexing (N : Node_Id; Typ : Entity_Id);
procedure Resolve_Indexed_Component (N : Node_Id; Typ : Entity_Id);
procedure Set_String_Literal_Subtype (N : Node_Id; Typ : Entity_Id);
-- The String_Literal_Subtype is built for all strings that are not
- -- operands of a static concatenation operation. If the argument is not
- -- a N_String_Literal node, then the call has no effect.
+ -- operands of a static concatenation operation. It is also built for
+ -- expressions generated by the expansion of the External_Initialization
+ -- aspect. If the argument is not an N_String_Literal node or an
+ -- N_External_Initializer node, then the call has no effect.
procedure Set_Slice_Subtype (N : Node_Id);
-- Build subtype of array type, with the range specified by the slice
when N_Extension_Aggregate =>
Resolve_Extension_Aggregate (N, Ctx_Type);
+ when N_External_Initializer =>
+ Resolve_External_Initializer (N, Ctx_Type);
+
when N_Function_Call =>
Resolve_Call (N, Ctx_Type);
end if;
end Resolve_Expression_With_Actions;
+ ----------------------------------
+ -- Resolve_External_Initializer --
+ ----------------------------------
+
+ procedure Resolve_External_Initializer (N : Node_Id; Typ : Entity_Id) is
+ begin
+ Set_String_Literal_Subtype (N, Typ);
+ end Resolve_External_Initializer;
+
----------------------------------
-- Resolve_Generalized_Indexing --
----------------------------------
Loc : constant Source_Ptr := Sloc (N);
Low_Bound : constant Node_Id :=
Type_Low_Bound (Etype (First_Index (Typ)));
+ Length : constant Nat :=
+ (case Nkind (N) is
+ when N_String_Literal => String_Length (Strval (N)),
+ -- Sinput.Source_Last points to an EOF character that's not in the
+ -- original file and we do not include that character.
+ when N_External_Initializer => Nat (
+ Source_Last (File_Index (N)) - Source_First (File_Index (N))),
+ when others => 0);
Subtype_Id : Entity_Id;
begin
- if Nkind (N) /= N_String_Literal then
+ if Nkind (N) not in N_String_Literal | N_External_Initializer then
return;
end if;
Subtype_Id := Create_Itype (E_String_Literal_Subtype, N);
- Set_String_Literal_Length (Subtype_Id, UI_From_Int
- (String_Length (Strval (N))));
+ Set_String_Literal_Length (Subtype_Id, UI_From_Int (Length));
Set_Etype (Subtype_Id, Base_Type (Typ));
Set_Is_Constrained (Subtype_Id);
Set_Etype (N, Subtype_Id);
else
declare
- Length : constant Nat := String_Length (Strval (N));
Index_List : constant List_Id := New_List;
Index_Type : constant Entity_Id := Etype (First_Index (Typ));
Array_Subtype : Entity_Id;
when Flag_Field
| Node_Kind_Type_Field
| Entity_Kind_Type_Field
+ | Source_File_Index_Field
| Source_Ptr_Field
| Small_Paren_Count_Type_Field
| Convention_Id_Field
-- modifications performed on the original expression such as replacement
-- of the current type instance or substitutions of primitives.
+ -- File_Index
+ -- Present in N_External_Initializer nodes. Contains a Source_File_Index
+ -- that references the file the external initializer points to.
+
-- First_Inlined_Subprogram
-- Present in the N_Compilation_Unit node for the main program. Points
-- to a chain of entities for subprograms that are to be inlined. The
-- the expression of the node is fully analyzed and expanded, at which
-- point it is safe to remove it, since no more actions can be inserted.
+ --------------------------
+ -- External Initializer --
+ --------------------------
+
+ -- This node is used to represent an instance of the
+ -- External_Initialization aspect.
+
+ -- N_External_Initializer
+ -- File_Index
+ -- plus fields for expression
+
--------------------
-- Free Statement --
--------------------
return +Buf;
end Build_Location_String;
+ ---------------------
+ -- C_Source_Buffer --
+ ---------------------
+
+ function C_Source_Buffer (S : SFI) return C_Array is
+ use type Interfaces.C.int;
+
+ Length : constant Interfaces.C.int :=
+ Interfaces.C.int (Source_Last (S) - Source_First (S));
+
+ Text : constant Source_Buffer_Ptr := Source_Text (S);
+
+ Pointer : constant access constant Character :=
+ (if Length = 0 then null else
+ Text (Text'First)'Access);
+ begin
+ return (Pointer, Length);
+ end C_Source_Buffer;
+
-------------------
-- Check_For_BOM --
-------------------
with Alloc;
with Casing; use Casing;
+with Interfaces.C;
with Namet; use Namet;
with System;
with Table;
-- reloaded. It is intended for tools that parse several times sources,
-- to avoid memory leaks.
+ type C_Array is record
+ Pointer : access constant Character;
+ Length : Interfaces.C.int range 0 .. Interfaces.C.int'Last;
+ end record with Convention => C_Pass_By_Copy;
+
+ function C_Source_Buffer (S : SFI) return C_Array with
+ Export, Convention => C, External_Name => "sinput__c_source_buffer";
+
private
pragma Inline (File_Name);
pragma Inline (Full_File_Name);
Name_Disable_Controlled : constant Name_Id := N + $;
Name_Dynamic_Predicate : constant Name_Id := N + $;
Name_Exclusive_Functions : constant Name_Id := N + $;
+ Name_External_Initialization : constant Name_Id := N + $;
Name_Finalizable : constant Name_Id := N + $;
Name_Full_Access_Only : constant Name_Id := N + $;
Name_Ghost_Predicate : constant Name_Id := N + $;
Write_Char (';');
+ when N_External_Initializer =>
+ null;
+
when N_Delta_Aggregate =>
Write_Str_With_Col_Check_Sloc ("(");
Sprint_Node (Expression (Node));
type Text_Ptr is new Int range -4 .. Int'Last;
-- -4 .. -1 are special; see constants below
- type Text_Buffer is array (Text_Ptr range <>) of Character;
+ type Text_Buffer is array (Text_Ptr range <>) of aliased Character;
-- Text buffer used to hold source file or library information file
type Text_Buffer_Ptr is access all Text_Buffer;