diff options
author | Ed Schonberg <schonberg@adacore.com> | 2017-04-27 10:20:36 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-04-27 12:20:36 +0200 |
commit | aaa0a838e6a944b0b9ff4a13e08c93a98fb94e97 (patch) | |
tree | 8586ee43f539f9cd48e608d19d63392b3a2d09d6 /gcc/ada/contracts.adb | |
parent | c1025b4e6ff78e8c6358f542661e1ba0dbd03e6b (diff) | |
download | gcc-aaa0a838e6a944b0b9ff4a13e08c93a98fb94e97.zip gcc-aaa0a838e6a944b0b9ff4a13e08c93a98fb94e97.tar.gz gcc-aaa0a838e6a944b0b9ff4a13e08c93a98fb94e97.tar.bz2 |
sem_util.adb, [...] (Build_Class_Wide_Clone_Body): Build body of subprogram that has a class-wide condition that contains calls to...
2017-04-27 Ed Schonberg <schonberg@adacore.com>
* sem_util.adb, sem_util.ads (Build_Class_Wide_Clone_Body):
Build body of subprogram that has a class-wide condition that
contains calls to other primitives.
(Build_Class_Wide_Clone_Call); Build a call to the common
class-wide clone of a subprogram with classwide conditions. The
body of the subprogram becomes a wrapper for a call to the
clone. The inherited operation becomes a similar wrapper to which
modified conditions apply, and the call to the clone includes
the proper conversion in a call the parent operation.
(Build_Class_Wide_Clone_Decl (Spec_Id : Entity_Id): For a
subprogram that has a classwide condition that contains calls to
other primitives, build an internal subprogram that is invoked
through a type-specific wrapper for all inherited subprograms
that may have a modified condition.
* sem_prag.adb (Check_References): If subprogram has a classwide
condition, create entity for corresponding clone, to be invoked
through wrapper subprograns.
(Analyze_Pre_Post_Condition_In_Decl_Part): Do not emit error
message about placement if pragma isi internally generated.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): If subprogram has
a classwide clone, build body of clone as copy of original body,
and rewrite original body as a wrapper as a wrapper for a call to
the clone, so that it incorporates the original pre/postconditions
of the subprogram.
* freeze.adb (Check_Inherited_Conditions): For an inherited
subprogram that inherits a classwide condition, build spec and
body of corresponding wrapper so that call to inherited operation
gets the modified conditions.
* contracts.adb (Analyze_Contracts): If analysis of classwide
condition has created a clone for a primitive operation, analyze
declaration of clone.
From-SVN: r247313
Diffstat (limited to 'gcc/ada/contracts.adb')
-rw-r--r-- | gcc/ada/contracts.adb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb index e4dc59e..ce61fdc 100644 --- a/gcc/ada/contracts.adb +++ b/gcc/ada/contracts.adb @@ -384,9 +384,23 @@ package body Contracts is N_Generic_Subprogram_Declaration, N_Subprogram_Declaration) then - Analyze_Entry_Or_Subprogram_Contract - (Subp_Id => Defining_Entity (Decl), - Freeze_Id => Freeze_Id); + declare + Subp_Id : constant Entity_Id := Defining_Entity (Decl); + + begin + Analyze_Entry_Or_Subprogram_Contract (Subp_Id, Freeze_Id); + + -- If analysis of a classwide pre/postcondition indicates + -- that a class-wide clone is needed, analyze its declaration + -- now. Its body is created when the body of the original + -- operation is analyzed (and rewritten). + + if Is_Subprogram (Subp_Id) + and then Present (Class_Wide_Clone (Subp_Id)) + then + Analyze (Unit_Declaration_Node (Class_Wide_Clone (Subp_Id))); + end if; + end; -- Entry or subprogram bodies |