Version 1.1 of ai05s/ai05-0225-1.txt

Unformatted version of ai05s/ai05-0225-1.txt version 1.1
Other versions for file ai05s/ai05-0225-1.txt

!standard A.4.7(28)          10-10-21 AI05-0225-1/01
!standard A.4.8(28/2)
!class binding interpretation 10-10-21
!status work item 10-10-21
!status received 10-06-04
!priority Low
!difficulty Easy
!qualifier Omission
!subject Call using constant protected objects
!summary
It is illegal to use a constant prefix for a name that denotes a protected procedure or entry.
!question
9.5(7.1) says, "The view of the target protected object associated with a call of a protected procedure or entry shall be a variable".
Is it the intent that this be allowed?
protected type Ptype is procedure P_Proc (Param1 : Integer); end Ptype;
protected body Ptype is procedure P_Proc (Param1 : Integer) is begin ... end P_Proc; end Ptype;
procedure Fool_The_Compiler (P_Obj : in Ptype) is -- P_Obj is constant type P_Proc_Acc is access protected procedure (Param1 : Integer); P_Acc : P_Proc_Acc; begin -- P_Obj.P_Proc (10); -- illegal by 9.5(7.1), but... P_Acc := P_Obj.P_Proc'access; -- (A) P_Acc (10); end Fool_The_Compiler;
P_Obj.P_Proc'access is not a call, so it doesn't seem to be subject to the rule (see 6(2)). 9.5(7.1) cannot apply to the call P_Acc (10), since the "protected object associated with the call" is not known at compile time, and it can't be known statically whether the object is variable or constant.
What is the intent here? (The 'Access attribute is illegal.)
!wording
Add after 4.1.3(13.2/2): [Legality Rules]
For a selected_component that denotes a protected procedure or protected entry, the prefix shall be a variable view Redundant[of a protected object].
Delete 9.5(7.1/2): [Legality Rules]
The view of the target protected object associated with a call of a protected procedure or entry shall be a variable.
!discussion
This problem is similar to the one recently fixed for several restrictions, such as No_Specific_Termination_Handlers.
There is no value in allowing the use of a name of a callable entity that would be illegal to call, for the reasons shown in the question. Thus we make the selected component illegal.
!ACATS Test
!appendix

!topic Call using constant protected objects 
!reference 9.5(7.1)
!from Adam Beneschan 10-06-04
!discussion


9.5(7.1) says, "The view of the target protected object associated
with a call of a protected procedure or entry shall be a variable".  

Is it the intent that this be allowed?

   protected type Ptype is
      procedure P_Proc (Param1 : Integer);
   end Ptype;

   protected body Ptype is
      procedure P_Proc (Param1 : Integer) is
      begin
         ...
      end P_Proc;
   end Ptype;

   procedure Fool_The_Compiler (P_Obj : in Ptype) is
         -- P_Obj is constant
      type P_Proc_Acc is access protected procedure (Param1 : Integer);
      P_Acc : P_Proc_Acc;
   begin
      -- P_Obj.P_Proc (10);   -- illegal by 9.5(7.1), but...
      P_Acc := P_Obj.P_Proc'access;
      P_Acc (10);
   end Fool_The_Compiler;

P_Obj.P_Proc'access is not a call, so it doesn't seem to be subject to
the rule (see 6(2)).  I don't see how 9.5(7.1) can apply to the call
P_Acc (10), since the "protected object associated with the call" is
not known at compile time, and it can't be known statically whether
the object is variable or constant.

I don't actually see why *any* use of
Constant_Protected_Object.Protected_Procedure or
Constant_Protected_Object.Entry should be allowed; I can't think of a
context where it could be useful.  This includes not just 'access, but
also subprogram renames and actuals for generic formal subprograms.
Maybe I've missed some other places.  But the way the rule is written,
it applies only to calls and not other uses of the protected procedure
or entry.


****************************************************************

Questions? Ask the ACAA Technical Agent