diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-07-03 18:24:37 +0200 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-08-02 09:08:04 +0200 |
commit | 3067fdd87bfb5666460094ce9b783deb7b643145 (patch) | |
tree | 5ab4a04fa48841caf7dff3d6e32529b5f75cf4dd /gcc/ada/doc/gnat_rm | |
parent | dc72d4dca9e6ee5af2ea2af0353a994a7a109db3 (diff) | |
download | gcc-3067fdd87bfb5666460094ce9b783deb7b643145.zip gcc-3067fdd87bfb5666460094ce9b783deb7b643145.tar.gz gcc-3067fdd87bfb5666460094ce9b783deb7b643145.tar.bz2 |
ada: Implement No_Raise aspect & pragma on subprograms
The new aspect is automatically set on the Adjust and Finalize primitives of
finalizable types, unless Relaxed_Finalization is explicitly set to False,
but it can also be specified directly on subprograms. It is also available
in earlier versions of the language by means of the associated pragma.
gcc/ada/
* aspects.ads (Aspect_Id): Add Aspect_No_Raise identifier.
(Implementation_Defined_Aspect): Add True for Aspect_No_Raise.
(Is_Representation_Aspect): Add False for Aspect_No_Raise.
(Aspect_Names): Add Name_No_Raise for Aspect_No_Raise.
(Aspect_Delay): Add Always_Delay for Aspect_No_Raise.
* checks.ads (Raise_Checks_Suppressed): New function.
(Apply_Raise_Check): New procedure.
* checks.adb (Apply_Raise_Check): New procedure.
(Raise_Checks_Suppressed): New function.
* doc/gnat_rm/gnat_language_extensions.rst (Generalized
Finalization): Update.
* doc/gnat_rm/implementation_defined_aspects.rst (No_Raise): New.
* doc/gnat_rm/implementation_defined_characteristics.rst (Check
names): Document Raise_Check and alphabetize others.
* doc/gnat_rm/implementation_defined_pragmas.rst (No_Raise): New.
* einfo.ads (No_Raise): New flag defined in subprograms and
generic subprograms.
* exp_ch6.adb (Expand_N_Subprogram_Body): Call Apply_Raise_Check
at the end of the processing.
* exp_ch11.adb (Get_RT_Exception_Name): Add alternative for
PE_Raise_Check_Failed to case statement.
* gen_il-fields.ads (Opt_Field_Enum): Add No_Raise identifier.
* gen_il-gen-gen_entities.adb (Subprogram_Kind): Add No_Raise as
semantical flag.
(Generic_Subprogram_Kind): Likewise.
* par-prag.adb (Prag): Add alternative for Pragma_No_Raise to case
statement.
* sem_ch13.adb (Validate_Finalizable_Aspect): Set No_Raise on the
Adjust and Finalize primitives if Relaxed_Finalization is set.
* sem_prag.adb (Analyze_Pragma): Add alternative for
Pragma_No_Raise to case statement.
(Sig_Flag): Add 0 for Pragma_No_Raise.
* snames.ads-tmpl (Remaining pragma names): Add Name_No_Raise.
(Names of recognized checks): Add Name_Raise_Check.
(Pragma_Id): Add Pragma_No_Raise identifier.
* types.ads (Raise_Check): New named number.
(All_Checks): Adjust.
(RT_Exception_Code): Add PE_Raise_Check_Failed identifier.
(Rkind): Add PE_Reason for PE_Raise_Check_Failed and alphabetize.
* types.h (RT_Exception_Code): Add PE_Raise_Check_Failed as 38.
(LAST_REASON_CODE): Adjust.
* libgnat/a-except.adb (Rcheck_PE_Raise_Check): New procedure with
pragmas Export, No_Return and Machine_Attributes.
(Rmsg_38): New string constant.
* gnat_rm.texi: Regenerate.
Diffstat (limited to 'gcc/ada/doc/gnat_rm')
4 files changed, 30 insertions, 6 deletions
diff --git a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst index efda4af..32f00c0 100644 --- a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst +++ b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst @@ -579,7 +579,5 @@ Example: procedure Finalize (Obj : in out Ctrl); procedure Initialize (Obj : in out Ctrl); -As of this writing, the RFC is implemented except for the `No_Raise` aspect. - Link to the original RFC: https://github.com/AdaCore/ada-spark-rfcs/blob/topic/finalization-rehaul/considered/rfc-generalized-finalization.md diff --git a/gcc/ada/doc/gnat_rm/implementation_defined_aspects.rst b/gcc/ada/doc/gnat_rm/implementation_defined_aspects.rst index e19684c..8718023 100644 --- a/gcc/ada/doc/gnat_rm/implementation_defined_aspects.rst +++ b/gcc/ada/doc/gnat_rm/implementation_defined_aspects.rst @@ -473,6 +473,12 @@ Aspect No_Inline This boolean aspect is equivalent to :ref:`pragma No_Inline<Pragma-No_Inline>`. +Aspect No_Raise +=============== +.. index:: No_Raise + +This boolean aspect is equivalent to :ref:`pragma No_Raise<Pragma-No_Raise>`. + Aspect No_Tagged_Streams ======================== .. index:: No_Tagged_Streams diff --git a/gcc/ada/doc/gnat_rm/implementation_defined_characteristics.rst b/gcc/ada/doc/gnat_rm/implementation_defined_characteristics.rst index 54bcd0c..5399bda 100644 --- a/gcc/ada/doc/gnat_rm/implementation_defined_characteristics.rst +++ b/gcc/ada/doc/gnat_rm/implementation_defined_characteristics.rst @@ -479,10 +479,11 @@ via compiler switches such as "-gnata". "Implementation-defined check names. See 11.5(27)." The implementation defined check names include Alignment_Check, -Atomic_Synchronization, Duplicated_Tag_Check, Container_Checks, -Tampering_Check, Predicate_Check, and Validity_Check. In addition, a user -program can add implementation-defined check names by means of the pragma -Check_Name. See the description of pragma ``Suppress`` for full details. +Atomic_Synchronization, Container_Checks, Duplicated_Tag_Check, +Predicate_Check, Raise_Check, Tampering_Check, and Validity_Check. +In addition, a user program can add implementation-defined check +names by means of the pragma Check_Name. See the description of +pragma ``Suppress`` for full details. * "Existence and meaning of second parameter of pragma Unsuppress. diff --git a/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst b/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst index f31a1b9..926c5f4 100644 --- a/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst +++ b/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst @@ -3923,6 +3923,25 @@ in particular it is not subject to the use of option *-gnatn* or *-gnatN*. It is illegal to specify both pragma ``No_Inline`` and pragma ``Inline_Always`` for the same ``NAME``. +.. _Pragma-No_Raise: + +Pragma No_Raise +=============== + +Syntax: + + +:: + + pragma No_Raise (subprogram_LOCAL_NAME {, subprogram_LOCAL_NAME}); + + +Each ``subprogram_LOCAL_NAME`` argument must refer to one or more subprogram +declarations in the current declarative part. A subprogram to which this +pragma is applied may not raise an exception that is not caught within it. +An implementation-defined check named `Raise_Check` is associated with the +pragma, and `Program_Error` is raised upon its failure (see RM 11.5(19/5)). + Pragma No_Return ================ |