!standard 3.6 10-02-22 SI99-0063-1/01 !standard 13.55 !standard 17.22 !standard 17.25 !standard 17.26 !class Amendment 10-02-22 !status No Action (7-0-2) 10-02-26 !status work item 10-02-22 !status received 10-02-22 !priority Medium !difficulty Medium !subject Normalized pragma argument lists !summary Allow Pragma_Argument_Associations to return a normalized pragma_argument_association list. !problem Unlike other sort of argument lists, pragma arguments cannot be normalized. But, given that pragmas have optional names and sometimes default associations, this is unusual. ASIS should be more consistent. !proposal (See summary.) !wording 3.6 subtypes of Element and Element_List subtype Path_List is Element_List; {subtype Pragma_Argument_Association_List is Element_List;} subtype Pragma_Element_List is Element_List; 13.55 function Pragma_Argument_Associations function Pragma_Argument_Associations (Pragma_Element : in Asis.Pragma_Element{; Normalized : in Boolean := False}) return [Asis.Association_List]{Asis.Pragma_Argument_Association_List}; Pragma_Element specifies the element to query. {Normalized specifies whether the normalized form is desired.} Returns a list of the Pragma_Argument_Associations of the pragma[, in their order of appearance]. {Returns Nil_Element_List if there are no Pragma_Argument_Association elements. An unnormalized list contains only explicit associations ordered as they appear in the program text. Each unnormalized association has a pragma_argument_identifier element and an explicit name or expression. The pragma_argument_identifier element is a nil element if the specific pragma_argument_association does not have a pragma_argument_identifier. A normalized list contains artificial associations representing all explicit and implicit associations. Implicit associations represent artificial pragma-specific pragma_argument_associations that have names or expressions that would have no affect on the semantics of the pragma had they appeared explicitly in the program text. The order of normalized associations matches the order of pragma_argument_associations defined for the pragma. A normalized association has one A_Defining_Name component that denotes the pragma_argument_identifier, and one A_Defining_Name or An_Expression component that is the explicit name or expression.} Pragma_Element expects an element that has the following Element_Kinds: A_Pragma Raises ASIS_Inappropriate_Element with a Status of Value_Error for any element that does not have one of these expected kinds. {Raises ASIS_Inappropriate_Element with a Status of Not_Implemented_Error if a normalized list is requested and an implicit association exists that is implementation defined.} Returns a list of elements that each have the following Element_Kinds: A_Pragma_Argument_Association {Implementation Permissions An implementation may return a normalized Pragma_Argument_Association list instead of raising ASIS_Inappropriate_Element with a Status of Not_Implemented_Error if the implementation is able to provide the implementation defined Pragma_Argument_Association_List result. Implementation Requirements Normalized associations are Is_Normalized and Is_Part_Of_Implicit. Normalized associations are never Is_Equal to unnormalized associations.} 17.22 function Actual_Parameter If the Association argument is from a normalized list: * If the Association is given explicitly: * Returns An_Expression representing: * the explicit_actual_parameter of a parameter_association. * the explicit_generic_actual_parameter of a generic_association. { * the name or expression of a pragma_argument_association.} The Enclosing_Element of An_Expression is the unnormalized An_Association Element containing the corresponding actual parameter. * If the Association is given by default: * Returns An_Expression representing: * the corresponding default_expression of the Is_Normalized A_Parameter_Association. * the corresponding default_expression or default_name of the Is_Normalized A_Generic_Association. { * the name or expression of the Is_Normalized A_Pragma_Argument_Association having the same semantics as an unnormalized Pragma_Argument_Association_List whereby the corresponding A_Pragma_Argument_Association is left unspecified.} * The Enclosing_Element of the An_Expression element is {the implicit An_Association Element containing the corresponding actual parameter if the actual parameter is the name or expression of a pragma_argument_association. The Enclosing_Element of the implicit association is the pragma declaration. Otherwise, the Enclosing_Element of the An_Expression element is} the parameter_specification or generic_formal_parameter_declaration that contains the default_expression or default_name, except for the case when this An_Expression element is an implicit naming expression representing the actual subprogram selected at the place of the instantiation for A_Box_Default. In the latter case, the Enclosing_Element for such An_Expression is the instantiation. 17.25 function Is_Normalized Returns True if the association is a normalized, artificially created association returned by the queries Discriminant_Associations, Generic_Actual_Part, Call_Statement_Parameters, Record_Component_Associations, {Pragma_Argument_Associations,} or Function_Call_Parameters where Normalized => True. Returns False for any unexpected Element. Association expects an element that has one of the following Association_Kinds: A_Discriminant_Association A_Record_Component_Association A_Parameter_Association A_Generic_Association {A_Pragma_Argument_Association} 17.26 function Is_Defaulted_Association Returns True if the association is a normalized, artificially created association returned by the queries Discriminant_Associations, Generic_Actual_Part, Record_Component_Associations, Call_Statement_Parameters, {Pragma_Argument_Associations,} or Function_Call_Parameters where Normalized => True and the association contains a default {name or} expression. A default {name or} expression is one that is implicitly supplied by the language semantics and that was not explicitly supplied (typed) by the user. Returns False for any unexpected Element. Association expects an element that has one of the following Association_Kinds: A_Parameter_Association A_Generic_Association {A_Pragma_Argument_Association} !discussion This SI was split from SI99-0058-1. This is considered an Amendment as Ada pragma arguments are always required to be in the same order, and thus there is no missing functionality (its possible to determine the details without the argument names). There are a number of language defined pragmas that have optional pragma argument associations where the absence of the pragma argument association implies a default association. [Editor's note: The Ada Standard has no such thing as a default pragma association, so if ASIS wants to treat them as if the standard defines such a thing, it is going to need wording to define that.] The call Asis.Pragma_Argument_Associations does not currently provide a way to retrieve implicit pragma_argument_associations. Other similar calls such as Asis.Discriminant_Associations and Asis.Record_Component_Associations have a Boolean Normalized parameter to indicate a normalized association list should be returned by the call. Ideally, Asis.Pragma_Argument_Associations would also have a similar Boolean Normalized parameter. For most language defined pragmas, the normalized Pragma_Argument_Association is identical to the unnormalized form since most pragmas do not have optional pragma_argument_associations. The pragmas that could provide normalized association lists that differ from the unnormalized form are as follows pragma Preelaborate, pragma All_Calls_Remote, pragma Remote_Call_Interface, pragma Remote_Types, pragma Shared_Passive, pragma Pure, pragma Elaborate_Body, pragma Interrupt_Priority, pragma Assert, pragma Import, pragma Export, and possibly certain implementation defined pragmas Pragma Preelaborate, All_Calls_Remote, Remote_Call_Interface, Remote_Types, Shared_Passive, Pure, and Elaborate_Body all have an optional pragma_argument_association that represents the library_unit_name, which is represents the library unit to which the pragma applies. The normalized form for this association would be the name of the enclosing library unit. The Interrupt_Priority pragma would provide the expression Interrupt_Priority'Last in normalized form. Pragma Assert, Import, Export, and implementation defined pragmas require special consideration because the normalized Pragma_Argument_Association list is implementation defined according to the Ada RM. It may not be possible for an ASIS implementation that is unaware of the compiler implementation to return a normalized pragma_argument_association list in such cases, therefore we say that calling Pragma_Argument_Associations with Normalized => True will raise ASIS.Inappropriate_Element with a status of Not_Implemented_Error; - for pragma Assert if the optional Message pragma_argument_association is not specified - for pragma Import, or Export if the optional External_Name or Link_Name pragma_argument_association is not specified. - for implementation defined pragmas. However, we specify an implementation permission to not raise the exception and return the normalized pragma_argument_association list if the ASIS implementation is aware of the compiler implementation and is able to generate the pragma_argument_association list result. Note that the Message Pragma_Argument_Association for pragma Assert does not default to "". It defaults to an implementation defined string that might include line number and file name of the Assert pragma for example. It may be possible for an ASIS implementation that is unaware of the compiler implementation to generate a Link_Name for pragma Import and Export if the External_Name pragma_argument_association is specified, however, it is not likely that the Link_Name could be generated by such an ASIS implementation if the External_Name was not specified. Similarly, such an ASIS implementation would not be able to generate the External_Name pragma_argument_association if it is not specified even though B.1 (48) states that the External_Name is ignored if the Link_Name is specified. Note also that there are certain pragmas that have optional pragma_argument_associations for which there is no implied default. For example, pragma Discard_Names [([On => ] local_name)]; -- No default pragma Inspection_Point[(object_name {, object_name})]; -- No default Since it is not possible to provide a pragma_argument_association for these pragmas which semantically changing the meaning of the pragma declaration, we want the normalized form for these pragmas to be the same as the unnormalized forms. If we allow Pragma_Argument_Association to return a Normalized association list, then we need to modify Actual_Parameter, Is_Normalized, and Is_Defaulted_Association to account for the possibility of normalized association lists of pragma_argument_associations. Note also that Pragma_Argument_Association returns an Association_List whereas other similar calls have defined subtypes of Association_Lists specific to the types of associations that are returned. For example, Discriminant_Associations returns a Discriminant_Association_List. Similarly, Pragma_Argument_Associations should return a Pragma_Argument_Association_List instead of just an Association_List to make use of stronger typing for the call. Therefore, Pragma_Argument_Association_List is defined as a subtype of Association_List. !appendix Old text from SI99-0058-1: 13.40 Pragma_Argument_Associations [Brad:] Shouldn't the call Pragma_Argument_Associations have a Normalized parameter? This seems like it might be useful. If so, then Is_Normalized should also accept a pragma_argument_association, and the wording for Actual_Parameter needs to be updated to support the possibility. Is_Defaulted_Association would also need some updating. [Randy:] Hum, this doesn't seem important (you are not analyzing the semantics of pragmas -- it's already well-defined or [for unrecognized pragmas] completely unknown). Optional pragma parameters would seem to cause trouble: they don't have a defined value. So what do you put there?? This just seems like work for little benefit -- it seems to have been omitted on purpose. [ARG (Meeting 39):] Unsure if this is a good idea. ****************************************************************