Version 1.2 of ai12s/ai12-0373-1.txt

Unformatted version of ai12s/ai12-0373-1.txt version 1.2
Other versions for file ai12s/ai12-0373-1.txt

!standard 3.1(1)          20-03-22 AI12-0373-1/01
!standard 4.9(17.3/5)
!standard 13.1.1(4/3)
!standard 13.1.1(11/3)
!standard 13.14(3/5)
!class Amendment 20-03-22
!status Amendment 1-2012 20-03-22
!status work item 20-03-22
!status received 20-03-22
!priority Low
!difficulty Easy
!subject Bunch 'o fixes
!summary
[Editor's note: These fixes, while unapproved, are included in the draft 25 RM as they are not expected to be controversial.]
A number of fixes to the draft Ada 202x Standard are needed:
(1) The definition of statically names only excludes components found in variants.
(2) Freezing of library units occurs at the end of the unit.
(3) Not all entities are (directly) associated with a declaration.
!problem
(1) The definition of statically names excludes any discriminant-dependent component. The reason is to avoid any names that require a discriminant check. However, a discriminant-dependent array component does not require a discriminant check to name or read it. That means that this rule makes 'Old prefixes illegal that do not have to be illegal. We want to allow as many 'Old prefixes as possible, so this rule should be revised.
(2) AI12-0079-1 has been replaced by AI12-0079-3, but three Chapter 13 fixes didn't make the trip: a syntax rule allowing the special Global aspect syntax in aspect specifications; and two rules that are a general correction to explain when aspects of a library unit are evaluated/frozen.
(3) 3.1(1) says that an entity is introduced by a named declaration. That seems to imply that an array component is not an entity. That would make some things that are objects not entities.
!proposal
(See Summary.)
!wording
Modify 3.1(1):
The language defines several kinds of named entities that are declared by declarations. The entity's name is defined by the declaration, usually by a defining_identifier, but sometimes by a defining_character_literal or defining_operator_symbol. {[Redundant: There are also entities that are not directly declared; some of these are elements of other entities, or are allocated dynamically. Such entities can be denoted using indexed_component, selected_component, or dereference names (see 4.1).]}
AARM Discussion: Some entities are always anonymous. For instance, a type is never named (the name represents the first subtype). We don't mention those here as this paragraph is about named entities.
Modify 4.9(17.3/5):
* is a selected_component whose prefix statically names an object, there is no implicit dereference of the prefix, and the selector_name [names a component that does not depend on a discriminant] {does not denote a component_declaration occurring within a variant_part}; or
Modify 13.1.1(4/3):
aspect_definition ::= name | expression | identifier{ | global_aspect_definition}
Modify 13.1.1(11/3):
The usage names in an aspect_definition [Redundant: are not resolved at the point of the associated declaration, but rather] are resolved at the end of the immediately enclosing declaration list{, or in the case of the declaration of a library unit, at the end of the visible part of the entity}.
Modify 13.14(3/5):
The end of a declarative_part, protected_body, or a declaration of a library package or generic library package, causes freezing of each entity and profile declared within it{, as well as the entity itself in the case of the declaration of a library unit}.
!discussion
(1) The reason for the rule is to prevent check failure for objects that are statically named. That's important for components found in a variant. However, simply accessing other kinds of discriminant-dependent components do not require any kind of check. Moreover, discriminant-dependent array components are not statically constrained, so their subcomponents cannot be statically named. Discriminant-dependent record components have the same requirements as any other record, so that's already covered.
Note that this makes statically name weaker than the rules for renaming; one can statically name a component that it is illegal to rename. For the major purposes of this term, however, we want the term to allow as much as possible (no sense in making illegal constructs which are not a problem), even if that is more than other similar constructs.
(2) Obviously, we need freezing and syntax rules that allow Global aspects.
(3) Clearly, objects are intended to be a subset of entities. There is plenty of wording that assumes that already in the Standard. For instance, 8.5(3) renaming says that a renaming elaborates the name to determine the entity. Since we can rename array subcomponents, clearly it's expected that they're entities.
Moreover, 4.1(11/2) says:
The evaluation of a name determines the entity denoted by the name...
So an entity is effectively anything that can be denoted by a name.
However, 3.1(1) is the only definition of entities in the Standard. We don't want to make it seem that a array component or type is not an entity simply because it doesn't have a declaration with a name. So we improve the wording to make it clear there are other kinds of entities.
!corrigendum 3.1(1)
Replace the paragraph:
The language defines several kinds of named entities that are declared by declarations. The entity's name is defined by the declaration, usually by a defining_identifier, but sometimes by a defining_character_literal or defining_operator_symbol.
by:
The language defines several kinds of named entities that are declared by declarations. The entity's name is defined by the declaration, usually by a defining_identifier, but sometimes by a defining_character_literal or defining_operator_symbol. There are also entities that are not directly declared; some of these are elements of other entities, or are allocated dynamically. Such entities can be denoted using indexed_component, selected_component, or dereference names (see 4.1).
!corrigendum 4.9(17)
Insert after the paragraph:
the new paragraphs:
A name statically names an object if it:
For an entity other than an object, a name statically names an entity if the name statically denotes the entity.
!corrigendum 13.1.1(4/3)
Replace the paragraph:
aspect_definition ::= name | expression | identifier
by:

aspect_definition ::= 
    name | expression | identifier | aggregate | global_aspect_definition

!corrigendum 13.1.1(11/3)
Replace the paragraph:
The usage names in an aspect_definition are not resolved at the point of the associated declaration, but rather are resolved at the end of the immediately enclosing declaration list.
by:
The usage names in an aspect_definition are not resolved at the point of the associated declaration, but rather are resolved at the end of the immediately enclosing declaration list, or in the case of the declaration of a library unit, at the end of the visible part of the entity.
!corrigendum 13.14(3/5)
Replace the paragraph:
The end of a declarative_part, protected_body, or a declaration of a library package or generic library package, causes freezing of each entity and profile declared within it, except for incomplete types. A proper_body, body_stub, or entry_body causes freezing of each entity and profile declared before it within the same declarative_part that is not an incomplete type; it only causes freezing of an incomplete type if the body is within the immediate scope of the incomplete type.
by:
The end of a declarative_part, protected_body, or a declaration of a library package or generic library package, causes freezing of each entity and profile declared within it, as well as the entity itself in the case of the declaration of a library unit. A noninstance proper_body, body_stub, or entry_body causes freezing of each entity and profile declared before it within the same declarative_part.
!example
(1)
procedure Cutdown is type R (D : Positive) is record F : String (1 .. D); end record;
procedure P (X : in out R; Flag : Boolean) with Post => Flag or else X.F'Old <= X.F;
procedure P (X : in out R; Flag : Boolean) is begin null; end P; begin null; end Cutdown;
X.F'Old is illegal with the original rule, and legal with the rule as revised by this AI.
!ASIS
[Not sure. It seems like some new capabilities might be needed, but I didn't check - Editor.]
!ACATS test
ACATS B- and C-Tests are needed to check that the new capabilities are supported.
!appendix

From: Tucker Taft
Sent: Wednesday, March 18, 2020  9:54 AM

I just happened to notice that the earlier variant of the AI on the Global
aspect (AI12-0079-1) had some important additions to chapter 13:

Modify 13.1.1(4/3)

  aspect_definition ::= name | expression | identifier{
                      | global_aspect_definition}


Modify 13.1.1(11/3):

  The usage names in an aspect_definition [Redundant: are not resolved
  at the point of the associated declaration, but rather] are resolved
  at the end of the immediately enclosing declaration list{, or in the
  case of the declaration of a library unit, at the end of the visible
  part of the entity}.

Modify 13.14(3/5):

  The end of a declarative_part, protected_body, or a declaration of a
  library package or generic library package, causes freezing of each
  entity and profile declared within it{, as well as the entity itself
  in the case of the declaration of a library unit}.

-----

Since we have now adopted variant 3 of 0079, we should either move these 
chapter 13 changes to a separate AI, or simply include them in variant 3 as 
part of our "approve with changes" work.

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

From: Randy Brukardt
Sent: Sunday, March 22, 2020  6:54 PM

I've put this into a "bunch of fixes" AI; it's a bit too much to do without 
some vote, and I don't want to reopen AI12-0079-3 lest people change their 
minds again. :-)

I'll check if there is anything else when I remove the old AI12-0079-1 from 
the draft RM and replace it with AI12-0079-3 (it should be obvious).

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

From: Tucker Taft
Sent: Sunday, March 22, 2020  7:54 PM

> I've put this into a "bunch of fixes" AI; it's a bit too much to do 
> without some vote, and I don't want to reopen AI12-0079-3 lest people 
> change their minds again. :-)

Good plan.

> 
> I'll check if there is anything else when I remove the old AI12-0079-1 
> from the draft RM and replace it with AI12-0079-3 (it should be obvious).

OK, sounds good.

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

Questions? Ask the ACAA Technical Agent