CVS difference for ai12s/ai12-0036-1.txt
--- ai12s/ai12-0036-1.txt 2012/11/29 06:43:27 1.1
+++ ai12s/ai12-0036-1.txt 2013/12/07 05:41:41 1.2
@@ -1,9 +1,12 @@
-!standard 12.5.1(5.1/3) 12-11-29 AI12-0036-1/01
+!standard 12.5.1(5.1/3) 13-12-06 AI12-0036-1/02
!class binding interpretation 12-11-29
+!status Corrigendum 2014 13-12-06
+!status ARG Approved 9-0-2 13-11-16
!status work item 12-11-29
!status received 12-08-01
!priority Low
!difficulty Medium
+!qualifier Omission
!subject The actual for an untagged formal derived type cannot be tagged
!summary
@@ -14,25 +17,25 @@
Consider:
generic
- type T1 is private;
- type T2 is new T1;
- type T3 is new T1;
+ type T1 is private;
+ type T2 is new T1;
+ type T3 is new T1;
package Pack1 is
- procedure Proc;
+ procedure Proc;
end Pack1;
package body Pack1 is
-
- V1 : T1;
- V2 : T2;
- V3 : T3;
-
- procedure Proc is
- begin
- V2 := T2(V1); -- (A)
- V3 := T3(V2); -- (B)
- V1 := T1(V2); -- (C)
- end Proc;
+
+ V1 : T1;
+ V2 : T2;
+ V3 : T3;
+
+ procedure Proc is
+ begin
+ V2 := T2(V1); -- (A)
+ V3 := T3(V2); -- (B)
+ V1 := T1(V2); -- (C)
+ end Proc;
end Pack1;
@@ -59,9 +62,9 @@
The actual type for a formal derived type shall be a descendant of the
ancestor type and every progenitor of the formal type. If the formal type is
-nonlimited, the actual type shall be nonlimited. {If the actual type for
-a formal derived type is tagged, the formal derived type shall be a
-private extension.} If the reserved word synchronized appears in the
+nonlimited, the actual type shall be nonlimited. {The actual type for a
+formal derived type shall be tagged if and only if the formal derived type
+is a private extension.} If the reserved word synchronized appears in the
declaration of the formal derived type, the actual type shall be a
synchronized tagged type.
@@ -83,32 +86,88 @@
In addition, untagged formal derived types are rare, so compatibility issues
are likely to be much rarer.
+This solution is still incompatible, but only in cases where the formal derived
+type does not accurately describe the actual. As noted above, we believe such
+instances will be rare.
+
Note that the problem does not require the types to be declared in the same
generic unit; the problem also appears in cases like:
generic
- type T1 is private;
+ type T1 is private;
package Pack1 is
- generic
- type T2 is new T1;
- type T3 is new T1;
- package Inner_Generic is ...
+ generic
+ type T2 is new T1;
+ type T3 is new T1;
+ package Inner_Generic is ...
end Pack1;
or
generic
- type T1 is private;
+ type T1 is private;
package Pack1 is ...
end Pack1;
generic
- type T2 is new T1;
- type T3 is new T1;
+ type T2 is new T1;
+ type T3 is new T1;
package Pack1.Child is ...
end Pack1.Child;
The matching rule works in these cases as well.
+
+We make the rule symmetric as it is possible to match a formal private
+extension with a nontagged type:
+
+ generic
+ type N is tagged private;
+ type NC is new N with private;
+ package GG is
+ ...
+ end GG;
+
+ package P is
+ type T1 is private;
+ private
+ type T1 is tagged ...
+ end P;
+
+ with P;
+ package Q is
+ type T2 is new P.T1;
+ end Q;
+
+ with Q;
+ package body P is
+ package G is new GG (T1, T2);
+ ...
+ end P;
+
+Here, T1 is tagged, but T2 is not tagged nor an extension. It's not
+clear that there is any semantic problem with allowing a case like
+this, but we're taking the safest option here.
+
+!corrigendum 12.5.1(5.1/3)
+
+@drepl
+The actual type for a formal derived type shall be a descendant of the ancestor
+type and every progenitor of the formal type. If the formal type is nonlimited,
+the actual type shall be nonlimited. If the reserved word @b<synchronized>
+appears in the declaration of the formal derived type, the actual type shall be a
+synchronized tagged type.
+@dby
+The actual type for a formal derived type shall be a descendant of the
+ancestor type and every progenitor of the formal type. If the formal type is
+nonlimited, the actual type shall be nonlimited. The actual type for a
+formal derived type shall be tagged if and only if the formal derived type
+is a private extension. If the reserved word @b<synchronized> appears in the
+declaration of the formal derived type, the actual type shall be a
+synchronized tagged type.
+
+!ASIS
+
+No ASIS impact.
!ACATS test
Questions? Ask the ACAA Technical Agent