--- acats/b3/b3a2016.a 2001/03/22 22:30:02 1.1
+++ acats/b3/b3a2016.a 2007/03/16 03:43:27 1.2
@@ -24,15 +24,26 @@
--*
--
-- OBJECTIVE:
--- of the prefix of X'Access is not used to resolve
--- both for X as an object and as a subprogram).
+-- Check that the type or profile of the prefix of X'Access is used
+-- to resolve the expected type (both for X as an object and as a
+-- subprogram).
--
+-- Check that the kind (pool-specific, access-to-constant, and so
+-- on) of access types that have the appropriate
+-- designated type is not used to resolve the expected type.
+--
-- Check that different access-to-subprogram types with the same accessed
-- profile do not match.
--
-- TEST DESCRIPTION:
--- the expected type of an 'Access or 'Unchecked_Access
--- le access type. This means that the type of the
+-- 3.10.2(2-2.3/2) was changed by AI-235 (which was included in the
+-- Amendment) to allow the type or profile of the prefix of an
+-- 'Access or 'Unchecked_Access attribute to participate in the
+-- resolution of the attribute.
+--
+-- However, the rule still requires a "single access type", so
+-- all access type with the appropriate designated type or profile
+-- participate in the resolution. This means that the type of the
-- prefix cannot be used to help determine the expected type. It also
-- means that pool-specific access types (which can never match the
-- attribute) participate in the resolution. Similarly, access to variable
@@ -40,8 +51,7 @@
--
-- Therefore, a series of subprograms overloaded on several access types
-- are declared. Various calls to the subprograms with Access and
--- tributes which would uniquely determine the correct
--- refix could be used.
+-- Unchecked_Access attributes which should and should not be legal.
--
-- We also check the common error of using a type conversion instead of
-- a qualified expression to disambiguate the calls. (This is illegal by
@@ -53,10 +63,6 @@
-- Several calls with similar access types with the same structure but
-- different names are also attempted.
--
--- icussing an AI which would change 3.10.2(2).
--- the tests are commented out, pending resolution
---
---
-- CHANGE HISTORY:
-- 17 Dec 99 RLB Created initial test from an Ada user problem
-- report.
@@ -72,6 +78,8 @@
-- either as errors or OKs, depending on the AI.
-- 01 Jun 00 RLB Added an access to constant test as suggested
-- by Tucker.
+-- 15 Mar 07 RLB Replaced test cases based on Amendment wording
+-- (from AI-235).
--!
package B3A2016 is
@@ -215,18 +223,18 @@
end Set_Flag;
- -- Test that the prefix of 'Access for objects is (not) used in resolution:
+ -- Test that the prefix of 'Access for objects is used in resolution:
Value : aliased Integer := 4;
- --Result1 : Float := Zap (Value'access); -- ERROR: Ambiguous (OK if AI-235)
- Result2 : Float := Zap (Int_Ptr'(Value'access)); -- OK
+ Result1 : Float := Zap (Value'access); -- OK.
+ Result2 : Float := Zap (Int_Ptr'(Value'access)); -- OK.
Temperature : aliased Float := 98.6;
- --Result3 : Float := Zap (Temperature'access); -- ERROR: Ambiguous (OK if AI-235)
+ Result3 : Float := Zap (Temperature'access); -- OK.
Result4 : Float := Zap (Float_Ptr(Temperature'access)); -- ERROR: Type conv
- Result5 : Float := Zap (Float_Ptr'(Temperature'access)); -- OK
+ Result5 : Float := Zap (Float_Ptr'(Temperature'access)); -- OK.
package body Pkg is
procedure Call (Action : Access_Proc) is
@@ -240,10 +248,10 @@
Humidity : aliased Float := 0.57;
- --Result6 : Float := Zop (Humidity'access); -- ERROR: Ambiguous (OK if AI-235)
+ Result6 : Float := Zop (Humidity'access); -- OK.
Result7 : Float := Zop (Float_Ptr(Humidity'access)); -- ERROR: Type conv
- Result8 : Float := Zop (Float_Ptr'(Humidity'access)); -- OK
- Result9 : Float := Pkg.Zop (Humidity'access); -- OK
+ Result8 : Float := Zop (Float_Ptr'(Humidity'access)); -- OK.
+ Result9 : Float := Pkg.Zop (Humidity'access); -- OK.
procedure My_Op (Val : access My_Tagged) is
begin
@@ -252,29 +260,29 @@
end Pkg;
- -- Test that the prefix of 'Unchecked_Access for objects is (not) used
+ -- Test that the prefix of 'Unchecked_Access for objects is used
-- in resolution:
- --Result11 : Float := Zap (Value'Unchecked_Access); -- ERROR: Ambiguous (OK if AI-235)
+ Result11 : Float := Zap (Value'Unchecked_Access); -- OK.
Result12 : Float := Zap (Int_Ptr(
Value'Unchecked_Access)); -- ERROR: Type conv
- Result13 : Float := Zap (Int_Ptr'(Value'Unchecked_Access)); -- OK
+ Result13 : Float := Zap (Int_Ptr'(Value'Unchecked_Access)); -- OK.
- --Result14 : Float := Zap (Temperature'Unchecked_Access); -- ERROR: Ambiguous (OK if AI-235)
+ Result14 : Float := Zap (Temperature'Unchecked_Access); -- OK.
Result15 : Float := Zap (Float_Ptr(
Temperature'Unchecked_Access)); -- ERROR: Type conv
- Result16 : Float := Zap (Float_Ptr'(Temperature'Unchecked_Access)); -- OK
+ Result16 : Float := Zap (Float_Ptr'(Temperature'Unchecked_Access)); -- OK.
- Subprogram : Access_Proc := Set_Flag'access; -- OK
+ Subprogram : Access_Proc := Set_Flag'access; -- OK.
-- Check that pool-specific access types participate in resolution of
-- access attributes:
Result20 : Float := Zup (Temperature'access); -- ERROR: Ambiguous
- Result21 : Float := Zup (Float_Ptr'(Temperature'access)); -- OK
+ Result21 : Float := Zup (Float_Ptr'(Temperature'access)); -- OK.
Result22 : Float := Zup (Temperature'Unchecked_Access); -- ERROR: Ambiguous
- Result23 : Float := Zup (Float_Ptr'(Temperature'Unchecked_Access)); -- OK
+ Result23 : Float := Zup (Float_Ptr'(Temperature'Unchecked_Access)); -- OK.
-- Check that access-to-variable access types participate in resolution of
-- access attributes, even when the prefix is a constant:
@@ -283,37 +291,37 @@
Result24 : Float := Zwp (Human_Temperature'access); -- ERROR: Ambiguous
Result25 : Float := Zwp (Constant_Float_Ptr'(
- Human_Temperature'access)); -- OK
+ Human_Temperature'access)); -- OK.
Result26 : Float := Zwp (Human_Temperature'Unchecked_Access); -- ERROR:
Result27 : Float := Zwp (Constant_Float_Ptr'(
- Human_Temperature'Unchecked_Access)); -- OK
+ Human_Temperature'Unchecked_Access)); -- OK.
- -- Check that subprogram access types participate in resolution of
+ -- Check that subprogram access types do not participate in resolution of
-- object access attributes:
- --Result30 : Float := Zep (Temperature'access); -- ERROR: Ambiguous (OK if AI-235)
- Result31 : Float := Zep (Float_Ptr'(Temperature'access)); -- OK
+ Result30 : Float := Zep (Temperature'access); -- OK.
+ Result31 : Float := Zep (Float_Ptr'(Temperature'access)); -- OK.
- --Result32 : Float := Zep (
- -- Temperature'Unchecked_Access); -- ERROR: Ambiguous (OK if AI-235)
- Result33 : Float := Zep (Float_Ptr'(Temperature'Unchecked_Access)); -- OK
-
- -- Check overloaded prefix case:
-
- --Result40 : Float := Zap (Zyp.all'access); -- ERROR: Ambiguous (OK if AI-235)
- --Result41 : Float := Zap (Zyp.all'Unchecked_Access); -- ERROR: Ambiguous (OK if AI-235)
- --Result42 : Float := Zap (Int_Ptr'(Zyp.all'access)); -- OK.
- --Result43 : Float := Zap (Int_Ptr'(Zyp.all'Unchecked_Access)); -- OK.
+ Result32 : Float := Zep (
+ Temperature'Unchecked_Access); -- OK.
+ Result33 : Float := Zep (Float_Ptr'(Temperature'Unchecked_Access)); -- OK.
+
+ -- Check that overloaded prefixes can be resolved:
+
+ Result40 : Float := Zap (Zyp.all'access); -- OK.
+ Result41 : Float := Zap (Zyp.all'Unchecked_Access); -- OK.
+ Result42 : Float := Zap (Int_Ptr'(Zyp.all'access)); -- OK.
+ Result43 : Float := Zap (Int_Ptr'(Zyp.all'Unchecked_Access)); -- OK.
begin
- -- Test that the prefix of 'Access for subprograms is not used in
+ -- Test that the prefix of 'Access for subprograms is used in
-- resolution:
- --Zip (Set_Flag'access); -- ERROR(?): (OK if AI-235)
+ Zip (Set_Flag'access); -- OK.
Zip (Access_Proc(Set_Flag'access)); -- ERROR: Type conv
- Zip (Access_Proc'(Set_Flag'access)); -- OK
- Zip (Subprogram); -- OK
+ Zip (Access_Proc'(Set_Flag'access)); -- OK.
+ Zip (Subprogram); -- OK.
-- Check that two types with the same structure do not accidentally
@@ -330,13 +338,13 @@
My_Obj : aliased Pkg.My_Tagged;
New_Obj : aliased Pkg2.New_Tagged;
begin
- --My_Op (New_Obj'access); -- ERROR: Ambiguous (OK if AI-235)
+ My_Op (New_Obj'access); -- OK.
Pkg2.My_Op (New_Obj'access); -- OK.
- --My_Op (My_Obj'Unchecked_Access); -- ERROR: Ambiguous (OK if AI-235)
+ My_Op (My_Obj'Unchecked_Access); -- OK.
Pkg.My_Op (My_Obj'Unchecked_Access); -- OK.
end;
- -- Check Tucker's overloading example:
+ -- Check Tucker Taft's overloading example:
declare
procedure Proc (X : Access_Proc; Y : Integer) is
begin
@@ -358,11 +366,10 @@
return null;
end Func;
begin
- --Proc (Func.all'access, 2); -- ERROR: Ambiguous (OK if AI-235, resolves to Access_Proc)
- --Proc (Func.all'Unchecked_Access, 2.0); -- ERROR: Ambiguous (OK if AI-235, resolves to Int_Ptr)
- --Proc (Access_Proc'(Func.all'access), 2); -- OK.
- --Proc (Int_Ptr'(Func.all'Unchecked_Access), 2.0); -- OK.
- null;
+ Proc (Func.all'access, 2); -- OK, resolves to Access_Proc.
+ Proc (Func.all'Unchecked_Access, 2.0); -- OK, resolves to Int_Ptr.
+ Proc (Access_Proc'(Func.all'access), 2); -- OK.
+ Proc (Int_Ptr'(Func.all'Unchecked_Access), 2.0); -- OK.
end;
end B3A2016;
Questions? Ask the ACAA Technical Agent