* String interpolation::
* Constrained attribute for generic objects::
* Static aspect on intrinsic functions::
+* First Controlling Parameter::
Experimental Language Extensions
* String interpolation::
* Constrained attribute for generic objects::
* Static aspect on intrinsic functions::
+* First Controlling Parameter::
@end menu
The @code{Constrained} attribute is permitted for objects of generic types. The
result indicates whether the corresponding actual is constrained.
-@node Static aspect on intrinsic functions,,Constrained attribute for generic objects,Curated Extensions
+@node Static aspect on intrinsic functions,First Controlling Parameter,Constrained attribute for generic objects,Curated Extensions
@anchor{gnat_rm/gnat_language_extensions static-aspect-on-intrinsic-functions}@anchor{44b}
@subsection @code{Static} aspect on intrinsic functions
and the compiler will evaluate some of these intrinsics statically, in
particular the @code{Shift_Left} and @code{Shift_Right} intrinsics.
+@node First Controlling Parameter,,Static aspect on intrinsic functions,Curated Extensions
+@anchor{gnat_rm/gnat_language_extensions first-controlling-parameter}@anchor{44c}
+@subsection First Controlling Parameter
+
+
+A new pragma/aspect, @code{First_Controlling_Parameter}, is introduced for tagged
+types, altering the semantics of primitive/controlling parameters. When a
+tagged type is marked with this aspect, only subprograms where the first
+parameter is of that type will be considered dispatching primitives. This
+pragma/aspect applies to the entire hierarchy, starting from the specified
+type, without affecting inherited primitives.
+
+Here is an example of this feature:
+
+@example
+package Example is
+ type Root is tagged private;
+
+ procedure P (V : Integer; V2 : Root);
+ -- Primitive
+
+ type Child is tagged private
+ with First_Controlling_Parameter;
+
+private
+ type Root is tagged null record;
+ type Child is new Root with null record;
+
+ overriding
+ procedure P (V : Integer; V2 : Child);
+ -- Primitive
+
+ procedure P2 (V : Integer; V2 : Child);
+ -- NOT Primitive
+
+ function F return Child; -- NOT Primitive
+
+ function F2 (V : Child) return Child;
+ -- Primitive, but only controlling on the first parameter
+end;
+@end example
+
+Note that @code{function F2 (V : Child) return Child;} differs from @code{F2 (V : Child)
+return Child'Class;} in that the return type is a specific, definite type. This
+is also distinct from the legacy semantics, where further derivations with
+added fields would require overriding the function.
+
+The option @code{-gnatw_j}, that you can pass to the compiler directly, enables
+warnings related to this new language feature. For instance, compiling the
+example above without this switch produces no warnings, but compiling it with
+@code{-gnatw_j} generates the following warning on the declaration of procedure P2:
+
+@example
+warning: not a dispatching primitive of tagged type "Child"
+warning: disallowed by First_Controlling_Parameter on "Child"
+@end example
+
+For generic formal tagged types, you can specify whether the type has the
+First_Controlling_Parameter aspect enabled:
+
+@example
+generic
+ type T is tagged private with First_Controlling_Parameter;
+package T is
+ type U is new T with null record;
+ function Foo return U; -- Not a primitive
+end T;
+@end example
+
+For tagged partial views, the value of the aspect must be consistent between
+the partial and full views:
+
+@example
+package R is
+ type T is tagged private;
+...
+private
+ type T is tagged null record with First_Controlling_Parameter; -- ILLEGAL
+end R;
+@end example
+
+Link to the original RFC:
+@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/considered/rfc-oop-first-controlling.rst}
+
@node Experimental Language Extensions,,Curated Extensions,GNAT language extensions
-@anchor{gnat_rm/gnat_language_extensions experimental-language-extensions}@anchor{6a}@anchor{gnat_rm/gnat_language_extensions id2}@anchor{44c}
+@anchor{gnat_rm/gnat_language_extensions experimental-language-extensions}@anchor{6a}@anchor{gnat_rm/gnat_language_extensions id2}@anchor{44d}
@section Experimental Language Extensions
@end menu
@node Conditional when constructs,Storage Model,,Experimental Language Extensions
-@anchor{gnat_rm/gnat_language_extensions conditional-when-constructs}@anchor{44d}
+@anchor{gnat_rm/gnat_language_extensions conditional-when-constructs}@anchor{44e}
@subsection Conditional when constructs
@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-conditional-when-constructs.rst}
@node Storage Model,Attribute Super,Conditional when constructs,Experimental Language Extensions
-@anchor{gnat_rm/gnat_language_extensions storage-model}@anchor{44e}
+@anchor{gnat_rm/gnat_language_extensions storage-model}@anchor{44f}
@subsection Storage Model
@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-storage-model.rst}
@node Attribute Super,Simpler accessibility model,Storage Model,Experimental Language Extensions
-@anchor{gnat_rm/gnat_language_extensions attribute-super}@anchor{44f}
+@anchor{gnat_rm/gnat_language_extensions attribute-super}@anchor{450}
@subsection Attribute Super
@indicateurl{https://github.com/QuentinOchem/ada-spark-rfcs/blob/oop/considered/rfc-oop-super.rst}
@node Simpler accessibility model,Case pattern matching,Attribute Super,Experimental Language Extensions
-@anchor{gnat_rm/gnat_language_extensions simpler-accessibility-model}@anchor{450}
+@anchor{gnat_rm/gnat_language_extensions simpler-accessibility-model}@anchor{451}
@subsection Simpler accessibility model
@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-simpler-accessibility.md}
@node Case pattern matching,Mutably Tagged Types with Size’Class Aspect,Simpler accessibility model,Experimental Language Extensions
-@anchor{gnat_rm/gnat_language_extensions case-pattern-matching}@anchor{451}
+@anchor{gnat_rm/gnat_language_extensions case-pattern-matching}@anchor{452}
@subsection Case pattern matching
@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-pattern-matching.rst}
@node Mutably Tagged Types with Size’Class Aspect,Generalized Finalization,Case pattern matching,Experimental Language Extensions
-@anchor{gnat_rm/gnat_language_extensions mutably-tagged-types-with-size-class-aspect}@anchor{452}
+@anchor{gnat_rm/gnat_language_extensions mutably-tagged-types-with-size-class-aspect}@anchor{453}
@subsection Mutably Tagged Types with Size’Class Aspect
@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/topic/rfc-finally/considered/rfc-class-size.md}
@node Generalized Finalization,,Mutably Tagged Types with Size’Class Aspect,Experimental Language Extensions
-@anchor{gnat_rm/gnat_language_extensions generalized-finalization}@anchor{453}
+@anchor{gnat_rm/gnat_language_extensions generalized-finalization}@anchor{454}
@subsection Generalized Finalization
@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/topic/finalization-rehaul/considered/rfc-generalized-finalization.md}
@node Security Hardening Features,Obsolescent Features,GNAT language extensions,Top
-@anchor{gnat_rm/security_hardening_features doc}@anchor{454}@anchor{gnat_rm/security_hardening_features id1}@anchor{455}@anchor{gnat_rm/security_hardening_features security-hardening-features}@anchor{15}
+@anchor{gnat_rm/security_hardening_features doc}@anchor{455}@anchor{gnat_rm/security_hardening_features id1}@anchor{456}@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{456}
+@anchor{gnat_rm/security_hardening_features register-scrubbing}@anchor{457}
@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{457}
+@anchor{gnat_rm/security_hardening_features stack-scrubbing}@anchor{458}
@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{458}
+@anchor{gnat_rm/security_hardening_features hardened-conditionals}@anchor{459}
@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{459}
+@anchor{gnat_rm/security_hardening_features hardened-booleans}@anchor{45a}
@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{45a}
+@anchor{gnat_rm/security_hardening_features control-flow-redundancy}@anchor{45b}
@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{45b}@anchor{gnat_rm/obsolescent_features id1}@anchor{45c}@anchor{gnat_rm/obsolescent_features obsolescent-features}@anchor{16}
+@anchor{gnat_rm/obsolescent_features doc}@anchor{45c}@anchor{gnat_rm/obsolescent_features id1}@anchor{45d}@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{45d}@anchor{gnat_rm/obsolescent_features pragma-no-run-time}@anchor{45e}
+@anchor{gnat_rm/obsolescent_features id2}@anchor{45e}@anchor{gnat_rm/obsolescent_features pragma-no-run-time}@anchor{45f}
@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{45f}@anchor{gnat_rm/obsolescent_features pragma-ravenscar}@anchor{460}
+@anchor{gnat_rm/obsolescent_features id3}@anchor{460}@anchor{gnat_rm/obsolescent_features pragma-ravenscar}@anchor{461}
@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{461}@anchor{gnat_rm/obsolescent_features pragma-restricted-run-time}@anchor{462}
+@anchor{gnat_rm/obsolescent_features id4}@anchor{462}@anchor{gnat_rm/obsolescent_features pragma-restricted-run-time}@anchor{463}
@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{463}@anchor{gnat_rm/obsolescent_features pragma-task-info}@anchor{464}
+@anchor{gnat_rm/obsolescent_features id5}@anchor{464}@anchor{gnat_rm/obsolescent_features pragma-task-info}@anchor{465}
@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{465}@anchor{gnat_rm/obsolescent_features package-system-task-info-s-tasinf-ads}@anchor{466}
+@anchor{gnat_rm/obsolescent_features package-system-task-info}@anchor{466}@anchor{gnat_rm/obsolescent_features package-system-task-info-s-tasinf-ads}@anchor{467}
@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{467}@anchor{gnat_rm/compatibility_and_porting_guide compatibility-and-porting-guide}@anchor{17}@anchor{gnat_rm/compatibility_and_porting_guide id1}@anchor{468}
+@anchor{gnat_rm/compatibility_and_porting_guide doc}@anchor{468}@anchor{gnat_rm/compatibility_and_porting_guide compatibility-and-porting-guide}@anchor{17}@anchor{gnat_rm/compatibility_and_porting_guide id1}@anchor{469}
@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{469}@anchor{gnat_rm/compatibility_and_porting_guide writing-portable-fixed-point-declarations}@anchor{46a}
+@anchor{gnat_rm/compatibility_and_porting_guide id2}@anchor{46a}@anchor{gnat_rm/compatibility_and_porting_guide writing-portable-fixed-point-declarations}@anchor{46b}
@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{46b}@anchor{gnat_rm/compatibility_and_porting_guide id3}@anchor{46c}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-ada-83}@anchor{46c}@anchor{gnat_rm/compatibility_and_porting_guide id3}@anchor{46d}
@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{46d}@anchor{gnat_rm/compatibility_and_porting_guide legal-ada-83-programs-that-are-illegal-in-ada-95}@anchor{46e}
+@anchor{gnat_rm/compatibility_and_porting_guide id4}@anchor{46e}@anchor{gnat_rm/compatibility_and_porting_guide legal-ada-83-programs-that-are-illegal-in-ada-95}@anchor{46f}
@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{46f}@anchor{gnat_rm/compatibility_and_porting_guide more-deterministic-semantics}@anchor{470}
+@anchor{gnat_rm/compatibility_and_porting_guide id5}@anchor{470}@anchor{gnat_rm/compatibility_and_porting_guide more-deterministic-semantics}@anchor{471}
@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{471}@anchor{gnat_rm/compatibility_and_porting_guide id6}@anchor{472}
+@anchor{gnat_rm/compatibility_and_porting_guide changed-semantics}@anchor{472}@anchor{gnat_rm/compatibility_and_porting_guide id6}@anchor{473}
@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{473}@anchor{gnat_rm/compatibility_and_porting_guide other-language-compatibility-issues}@anchor{474}
+@anchor{gnat_rm/compatibility_and_porting_guide id7}@anchor{474}@anchor{gnat_rm/compatibility_and_porting_guide other-language-compatibility-issues}@anchor{475}
@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{475}@anchor{gnat_rm/compatibility_and_porting_guide id8}@anchor{476}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-between-ada-95-and-ada-2005}@anchor{476}@anchor{gnat_rm/compatibility_and_porting_guide id8}@anchor{477}
@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{477}@anchor{gnat_rm/compatibility_and_porting_guide implementation-dependent-characteristics}@anchor{478}
+@anchor{gnat_rm/compatibility_and_porting_guide id9}@anchor{478}@anchor{gnat_rm/compatibility_and_porting_guide implementation-dependent-characteristics}@anchor{479}
@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{479}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-pragmas}@anchor{47a}
+@anchor{gnat_rm/compatibility_and_porting_guide id10}@anchor{47a}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-pragmas}@anchor{47b}
@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{47b}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-attributes}@anchor{47c}
+@anchor{gnat_rm/compatibility_and_porting_guide id11}@anchor{47c}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-attributes}@anchor{47d}
@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{47d}@anchor{gnat_rm/compatibility_and_porting_guide libraries}@anchor{47e}
+@anchor{gnat_rm/compatibility_and_porting_guide id12}@anchor{47e}@anchor{gnat_rm/compatibility_and_porting_guide libraries}@anchor{47f}
@subsection Libraries
@end itemize
@node Elaboration order,Target-specific aspects,Libraries,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide elaboration-order}@anchor{47f}@anchor{gnat_rm/compatibility_and_porting_guide id13}@anchor{480}
+@anchor{gnat_rm/compatibility_and_porting_guide elaboration-order}@anchor{480}@anchor{gnat_rm/compatibility_and_porting_guide id13}@anchor{481}
@subsection Elaboration order
@end itemize
@node Target-specific aspects,,Elaboration order,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide id14}@anchor{481}@anchor{gnat_rm/compatibility_and_porting_guide target-specific-aspects}@anchor{482}
+@anchor{gnat_rm/compatibility_and_porting_guide id14}@anchor{482}@anchor{gnat_rm/compatibility_and_porting_guide target-specific-aspects}@anchor{483}
@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{483,,Representation Clauses}.
+GNAT’s approach to these issues is described in @ref{484,,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{484}@anchor{gnat_rm/compatibility_and_porting_guide id15}@anchor{485}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-other-ada-systems}@anchor{485}@anchor{gnat_rm/compatibility_and_porting_guide id15}@anchor{486}
@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{486}@anchor{gnat_rm/compatibility_and_porting_guide representation-clauses}@anchor{483}
+@anchor{gnat_rm/compatibility_and_porting_guide id16}@anchor{487}@anchor{gnat_rm/compatibility_and_porting_guide representation-clauses}@anchor{484}
@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{487}@anchor{gnat_rm/compatibility_and_porting_guide id17}@anchor{488}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-hp-ada-83}@anchor{488}@anchor{gnat_rm/compatibility_and_porting_guide id17}@anchor{489}
@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{489}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{48a}
+@anchor{share/gnu_free_documentation_license doc}@anchor{48a}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{48b}
@chapter GNU Free Documentation License