diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2020-07-13 12:42:18 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-10-20 03:21:28 -0400 |
commit | afa1ffd42cd208fc1c6c819567c363dd8080efa2 (patch) | |
tree | 0c3d58b77acc62b511f160449849d48056f086b7 /gcc/ada/contracts.ads | |
parent | 87eb6d2c2a9a9fbea23b91c01fa64fcf1f3825df (diff) | |
download | gcc-afa1ffd42cd208fc1c6c819567c363dd8080efa2.zip gcc-afa1ffd42cd208fc1c6c819567c363dd8080efa2.tar.gz gcc-afa1ffd42cd208fc1c6c819567c363dd8080efa2.tar.bz2 |
[Ada] Support for new aspect Subprogram_Variant on recursive subprograms
gcc/ada/
* aspects.ads: Introduce Subprogram_Variant aspect with the
following properties: GNAT-specific, with mandatory expression,
not a representation aspect, never delayed.
* contracts.adb (Expand_Subprogram_Contract): Mention new aspect
in the comment.
(Add_Contract_Item): Support addition of pragma
Subprogram_Variant to N_Contract node.
(Analyze_Entry_Or_Subprogram_Contract): Mention new aspect in
the comment; add pragma Subprogram_Variant to N_Contract node.
(Build_Postconditions_Procedure): Adapt call to
Insert_Before_First_Source_Declaration, which is now reused in
expansion of new aspect.
(Process_Contract_Cases_For): Also process Subprogram_Variant,
which is stored in N_Contract node together with Contract_Cases.
* contracts.ads (Analyze_Entry_Or_Subprogram_Contract): Mention
new aspect in the comment.
(Analyze_Entry_Or_Subprogram_Body_Contract): Likewise.
* einfo.adb (Get_Pragma): Support retrieval of new pragma.
* einfo.ads (Get_Pragma): Likewise.
* exp_ch6.adb (Check_Subprogram_Variant): New routine for
emitting call to check Subprogram_Variant expressions at run
time.
(Expand_Call_Helper): Check Subprogram_Variant expressions at
recursive calls.
* exp_prag.adb (Make_Op): Moved from expansion of pragma
Loop_Variant to Exp_Util, so it is now reused for expansion of
pragma Subprogram_Variant.
(Process_Variant): Adapt call to Make_Op after moving it to
Exp_Util.
(Expand_Pragma_Subprogram_Variant): New routine.
* exp_prag.ads (Expand_Pragma_Subprogram_Variant): Likewise.
* exp_util.adb (Make_Variant_Comparison): Moved from Exp_Prag
(see above).
* exp_util.ads (Make_Variant_Comparison): Likewise.
* inline.adb (Remove_Aspects_And_Pragmas): Handle aspect/pragma
Subprogram_Variant just like similar contracts.
* par-prag.adb (Prag): Likewise.
* sem.adb (Insert_Before_First_Source_Declaration): Moved from
Contracts (see above).
* sem.ads (Insert_Before_First_Source_Declaration): Likewise.
* sem_ch12.adb: Mention new aspect in the comment about
"Implementation of Generic Contracts", just like similar aspects
are mentioned there.
* sem_ch13.adb (Insert_Pragma): Mention new aspect in the
comment, because this routine is now used for Subprogram_Variant
just like for other similar aspects.
(Analyze_Aspect_Specifications): Mention new aspect in comments;
it is handled just like aspect Contract_Cases.
(Check_Aspect_At_Freeze_Point): Do not expect aspect
Subprogram_Variant just like we don't expect aspect
Contract_Cases.
* sem_prag.adb (Ensure_Aggregate_Form): Now also used for pragma
Subprogram_Variant, so update comment.
(Analyze_Pragma): Add initial checks for pragma
Subprogram_Variant.
(Analyze_Subprogram_Variant_In_Decl_Part): New routine with
secondary checks on the new pragma.
(Sig_Flags): Handle references within pragma Subprogram_Variant
expression just like references in similar pragma
Contract_Cases.
(Is_Valid_Assertion_Kind): Handle Subprogram_Variant just like
other similar contracts.
* sem_prag.ads (Analyze_Subprogram_Variant_In_Decl_Part): New
routine.
* sem_res.adb (Same_Or_Aliased_Subprograms): Moved to Sem_Util,
so it can be reused for detection of recursive calls where
Subprogram_Variant needs to be verified.
* sem_util.adb (Is_Subprogram_Contract_Annotation): Handle new
Subprogram_Variant annotation just like other similar
annotations.
(Same_Or_Aliased_Subprograms): Moved from Sem_Res (see above).
* sem_util.ads (Is_Subprogram_Contract_Annotation): Mention new
aspect in the comment.
(Same_Or_Aliased_Subprograms): Moved from Sem_Res (see above).
* sinfo.ads (N_Contract): Document handling of
Subprogram_Variant.
* snames.ads-tmpl: Add name for the internally generated
procedure with checks for Subprogram_Variant expression, name
for the new aspect and new pragma corresponding to aspect
Subprogram_Variant.
Diffstat (limited to 'gcc/ada/contracts.ads')
-rw-r--r-- | gcc/ada/contracts.ads | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/gcc/ada/contracts.ads b/gcc/ada/contracts.ads index 9e7b955..4782ef5 100644 --- a/gcc/ada/contracts.ads +++ b/gcc/ada/contracts.ads @@ -69,15 +69,16 @@ package Contracts is -- subprogram body Body_Id as if they appeared at the end of a declarative -- region. Pragmas in question are: -- - -- Contract_Cases (stand alone subprogram body) - -- Depends (stand alone subprogram body) - -- Global (stand alone subprogram body) - -- Postcondition (stand alone subprogram body) - -- Precondition (stand alone subprogram body) + -- Contract_Cases (stand alone subprogram body) + -- Depends (stand alone subprogram body) + -- Global (stand alone subprogram body) + -- Postcondition (stand alone subprogram body) + -- Precondition (stand alone subprogram body) -- Refined_Depends -- Refined_Global -- Refined_Post - -- Test_Case (stand alone subprogram body) + -- Subprogram_Variant (stand alone subprogram body) + -- Test_Case (stand alone subprogram body) procedure Analyze_Entry_Or_Subprogram_Contract (Subp_Id : Entity_Id; @@ -91,6 +92,7 @@ package Contracts is -- Global -- Postcondition -- Precondition + -- Subprogram_Variant -- Test_Case -- -- Freeze_Id is the entity of a [generic] package body or a [generic] |