aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_attr.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/exp_attr.adb')
-rw-r--r--gcc/ada/exp_attr.adb41
1 files changed, 31 insertions, 10 deletions
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index 25f1627..9c8d80f 100644
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -2316,19 +2316,40 @@ package body Exp_Attr is
if Is_Access_Protected_Subprogram_Type (Btyp) then
Expand_Access_To_Protected_Op (N, Pref, Typ);
- -- If prefix is a subprogram that has class-wide preconditions and
- -- an indirect-call wrapper (ICW) of such subprogram is available
- -- then replace the prefix by the ICW.
-
elsif Is_Access_Subprogram_Type (Btyp)
and then Is_Entity_Name (Pref)
- and then Present (Class_Preconditions (Entity (Pref)))
- and then Present (Indirect_Call_Wrapper (Entity (Pref)))
then
- Rewrite (Pref,
- New_Occurrence_Of
- (Indirect_Call_Wrapper (Entity (Pref)), Loc));
- Analyze_And_Resolve (N, Typ);
+ -- If prefix is a subprogram that has class-wide preconditions
+ -- and an indirect-call wrapper (ICW) of the subprogram is
+ -- available then replace the prefix by the ICW.
+
+ if Present (Class_Preconditions (Entity (Pref)))
+ and then Present (Indirect_Call_Wrapper (Entity (Pref)))
+ then
+ Rewrite (Pref,
+ New_Occurrence_Of
+ (Indirect_Call_Wrapper (Entity (Pref)), Loc));
+ Analyze_And_Resolve (N, Typ);
+ end if;
+
+ -- Ensure the availability of the extra formals to check that
+ -- they match.
+
+ if not Is_Frozen (Entity (Pref))
+ or else From_Limited_With (Etype (Entity (Pref)))
+ then
+ Create_Extra_Formals (Entity (Pref));
+ end if;
+
+ if not Is_Frozen (Btyp_DDT)
+ or else From_Limited_With (Etype (Btyp_DDT))
+ then
+ Create_Extra_Formals (Btyp_DDT);
+ end if;
+
+ pragma Assert
+ (Extra_Formals_Match_OK
+ (E => Entity (Pref), Ref_E => Btyp_DDT));
-- If prefix is a type name, this is a reference to the current
-- instance of the type, within its initialization procedure.