!standard 3.9.2(13) 10-11-18 AI05-0222-1/02 !standard 13.14(16) !class ramification 10-11-18 !status ARG Approved 9-0-1 10-10-30 !status work item 10-10-20 !status received 10-03-25 !priority Low !difficulty Easy !qualifier Error !subject A completion of a primitive subprogram can occur after freezing !summary A completion of a primitive subprogram of a tagged type can occur after the freezing of the tagged type. !question Consider: package Pak1 is type T1 is tagged record ... end record; procedure Op (X : in out T1); end Pak1; with Pak1; procedure Proc2 is type T2 is new Pak1.T1 with record ... end record; overriding procedure Op (X : in out T2); Var : T2; overriding procedure Op (X : in out T2) is -- (A) begin ... end Op; ... 3.9.2(13): "The explicit declaration of a primitive subprogram of a tagged type shall occur before the type is frozen." 6.3(5): "A subprogram_body is considered a declaration. It can either complete a previous declaration, or itself be the initial declaration of the subprogram." one could think that since line (A) is a declaration, it's overriding a primitive subprogram, and it's occurring after the type is frozen, that 3.9.2(13) makes it illegal. That clearly makes no sense; should this be fixed? (No.) !response The rules clearly were intended to apply only to "original" declarations, and not the declaration of a completion. No user or implementer is going to misinterpret these rules, given that a literal interpretation would prevent the declaration of any concrete tagged type with primitive operations (those operations could never be completed). Moreover, one could argue that subprogram declarations in a body are not primitive subprograms - whether or not completions of a primitive subprogram also is a primitive subprogram when a stand-alone subprogram would not be primitive is not clearly addressed by 3.2.3(2-7) -- a literal reading would say that they are not. But that would just make the issue even more confusing. With the unlikelyhood of misinterpretation, we simply add a To Be Honest note to the AARM to make it crystal clear that completions are not considered. Note the introduction of expression functions by AI05-0177-1 makes this a more significant issue. We would not want the following to be illegal: package Pak2 is type T is tagged private; function F (Obj : T) return Boolean; private type T is tagged record Flag : Boolean; end record; Object : T; -- Freezes T. function F (Obj : T) return Boolean is (Obj.Flag); end Pak2; !wording Add a new AARM note after 3.9.2(13) and after 13.14(16): AARM To Be Honest: This rule only applies to "original" declarations and not to the completion of a primitive subprogram, even though a completion is technically an explicit declaration, and it may declare a primitive subprogram. !ACATS Test An ACATS test could be constructed for the expression function case (the example of the question is too much of a pathology to matter). !ASIS This has no impact on ASIS. !appendix !topic Subprogram body declarations and 3.9.2(13) !reference RM 3.9.2(13), 13.14(16), 6.3(5) !from Adam Beneschan 10-03-25 !discussion This is a wording nitpick that I'm not sure really needs to be fixed: package Pak1 is type T1 is tagged record ... end record; procedure Op (X : in out T1); end Pak1; with Pak1; procedure Proc2 is type T2 is new Pak1.T1 with record ... end record; overriding procedure Op (X : in out T2); Var : T2; overriding procedure Op (X : in out T2) is -- (A) begin ... end Op; ... Shouldn't cause any problems, right? Op (on T2) is declared before Var, which is before T2 is frozen. However, the way things are worded: 3.9.2(13): "The explicit declaration of a primitive subprogram of a tagged type shall occur before the type is frozen." 6.3(5): "A subprogram_body is considered a declaration. It can either complete a previous declaration, or itself be the initial declaration of the subprogram." one could think that since line (A) is a declaration, and it's occurring after the type is frozen, that 3.9.2(13) makes it illegal. Perhaps the intent is so obvious that no fix is needed; but if it's considered incorrect, then changing 3.9.2(13) and 13.14(16) to something like The explicit declaration (that is not the completion of a previous declaration) of a primitive subprogram of a tagged type shall occur before the type is frozen. would work. ****************************************************************