+2018-05-30 Bob Duff <duff@adacore.com>
+
+ * aspects.ads, contracts.adb, exp_util.adb, expander.adb, expander.ads,
+ freeze.adb, inline.adb, lib-xref.adb, sem.ads, sem_aggr.adb,
+ sem_attr.adb, sem_ch13.adb, sem_ch3.adb, sem_ch5.adb, sem_ch6.adb,
+ sem_ch8.adb, sem_dim.adb, sem_elab.adb, sem_res.adb, sem_res.ads,
+ sinfo.ads: Spell preanalysis, preanalyze correctly.
+
2018-05-30 Bob Duff <duff@adacore.com>
* libgnat/g-sestin.ads: Rework documentation comments.
-- 5. If the semantic analysis of expressions/names in the aspect should not
-- occur at the point the aspect is defined, add code in the adequate
-- semantic analysis procedure for the aspect. For example, this is the
--- case for aspects Pre and Post on subprograms, which are pre-analyzed
+-- case for aspects Pre and Post on subprograms, which are preanalyzed
-- at the end of the declaration list to which the subprogram belongs,
-- and fully analyzed (possibly with expansion) during the semantic
-- analysis of subprogram bodies.
then
Analyze_Task_Contract (Defining_Entity (Decl));
- -- For type declarations, we need to do the pre-analysis of Iterable
+ -- For type declarations, we need to do the preanalysis of Iterable
-- aspect specifications.
-- Other type aspects need to be resolved here???
-- Handle cases in which there is nothing to do. In GNATprove mode,
-- removal of side effects is useful for the light expansion of
-- renamings. This removal should only occur when not inside a
- -- generic and not doing a pre-analysis.
+ -- generic and not doing a preanalysis.
if not Expander_Active
and (Inside_A_Generic or not Full_Analysis or not GNATprove_Mode)
-- The first is when are not generating code. In this mode the
-- Full_Analysis flag indicates whether we are performing a complete
- -- analysis, in which case Full_Analysis = True or a pre-analysis in
+ -- analysis, in which case Full_Analysis = True or a preanalysis in
-- which case Full_Analysis = False. See the spec of Sem for more info
-- on this.
-- The second reason for the Expander_Active flag to be False is that
- -- we are performing a pre-analysis. During pre-analysis all expansion
+ -- we are performing a preanalysis. During preanalysis all expansion
-- activity is turned off to make sure nodes are semantically decorated
-- but no extra nodes are generated. This is for instance needed for
-- the first pass of aggregate semantic processing. Note that in this
-- or declaration (see routines Start_Generic_Processing and
-- End_Generic_Processing in Sem_Ch12)
--
- -- (b) when starting/completing the pre-analysis of an expression
- -- (see the spec of package Sem for more info on pre-analysis.)
+ -- (b) when starting/completing the preanalysis of an expression
+ -- (see the spec of package Sem for more info on preanalysis.)
--
-- Note that when processing a spec expression (In_Spec_Expression
-- is True) or performing semantic analysis of a generic spec or body
- -- (Inside_A_Generic) or when performing pre-analysis (Full_Analysis is
+ -- (Inside_A_Generic) or when performing preanalysis (Full_Analysis is
-- False) the Expander_Active flag is False.
procedure Expand (N : Node_Id);
-- This procedure is called for each subprogram to complete processing of
-- default expressions at the point where all types are known to be frozen.
-- The expressions must be analyzed in full, to make sure that all error
- -- processing is done (they have only been pre-analyzed). If the expression
+ -- processing is done (they have only been preanalyzed). If the expression
-- is not an entity or literal, its analysis may generate code which must
-- not be executed. In that case we build a function body to hold that
-- code. This wrapper function serves no other purpose (it used to be
Append (Body_To_Analyze, Declarations (N));
end if;
- -- The body to inline is pre-analyzed. In GNATprove mode we must disable
+ -- The body to inline is preanalyzed. In GNATprove mode we must disable
-- full analysis as well so that light expansion does not take place
-- either, and name resolution is unaffected.
-- Do not generate references if we are within a postcondition sub-
-- program, because the reference does not comes from source, and the
- -- pre-analysis of the aspect has already created an entry for the ALI
+ -- preanalysis of the aspect has already created an entry for the ALI
-- file at the proper source location.
if Chars (Current_Scope) = Name_uPostconditions then
-- code for the pragma is generated.
------------------
--- Pre-Analysis --
+-- Preanalysis --
------------------
-- For certain kind of expressions, such as aggregates, we need to defer
-- expanded code for "new Thing (Function_Call)".
-- To remedy this situation we introduce a flag that signals whether we want a
--- full analysis (i.e. expansion is enabled) or a pre-analysis which performs
+-- full analysis (i.e. expansion is enabled) or a preanalysis which performs
-- Analysis and Resolution but no expansion.
--- After the complete pre-analysis of an expression has been carried out we
+-- After the complete preanalysis of an expression has been carried out we
-- can transform the expression and then carry out the full three stage
-- (Analyze-Resolve-Expand) cycle on the transformed expression top-down so
-- that the expansion of inner expressions happens inside the newly generated
-- node for the parent expression.
-- Note that the difference between processing of default expressions and
--- pre-analysis of other expressions is that we do carry out freezing in
+-- preanalysis of other expressions is that we do carry out freezing in
-- the latter but not in the former (except for static scalar expressions).
-- The routine that performs preanalysis and corresponding resolution is
-- called Preanalyze_And_Resolve and is in Sem_Res.
-----------------------------
Full_Analysis : Boolean := True;
- -- Switch to indicate if we are doing a full analysis or a pre-analysis.
+ -- Switch to indicate if we are doing a full analysis or a preanalysis.
-- In normal analysis mode (Analysis-Expansion for instructions or
-- declarations) or (Analysis-Resolution-Expansion for expressions) this
-- flag is set. Note that if we are not generating code the expansion phase
-- merely sets the Analyzed flag to True in this case. If we are in
- -- Pre-Analysis mode (see above) this flag is set to False then the
+ -- Preanalysis mode (see above) this flag is set to False then the
-- expansion phase is skipped.
--
-- When this flag is False the flag Expander_Active is also False (the
-- Determine whether preanalysis is active at the point of invocation
procedure Preanalyze (N : Node_Id);
- -- Performs a pre-analysis of node N. During pre-analysis no expansion is
- -- carried out for N or its children. For more info on pre-analysis read
- -- the spec of Sem.
+ -- Performs a preanalysis of node N. During preanalysis no expansion is
+ -- carried out for N or its children. See above for more info on
+ -- preanalysis.
generic
with procedure Action (Item : Node_Id);
-- expressions allowed for a limited component association (namely, an
-- aggregate, function call, or <> notation). Report error for violations.
-- Expression is also OK in an instance or inlining context, because we
- -- have already pre-analyzed and it is known to be type correct.
+ -- have already preanalyzed and it is known to be type correct.
procedure Check_Qualified_Aggregate (Level : Nat; Expr : Node_Id);
-- Given aggregate Expr, check that sub-aggregates of Expr that are nested
-- designated type of the access type, since the type of the
-- referenced array is this type (see AI95-00106).
- -- As done elsewhere, freezing must not happen when pre-analyzing
+ -- As done elsewhere, freezing must not happen when preanalyzing
-- a pre- or postcondition or a default value for an object or for
-- a formal parameter.
-- Build the declaration for a predicate function. The declaration is built
-- at the end of the declarative part containing the type definition, which
-- may be before the freeze point of the type. The predicate expression is
- -- pre-analyzed at this point, to catch visibility errors.
+ -- preanalyzed at this point, to catch visibility errors.
procedure Build_Predicate_Functions (Typ : Entity_Id; N : Node_Id);
-- If Typ has predicates (indicated by Has_Predicates being set for Typ),
-- within a generic unit, prevent a double analysis of the body
-- which will not be marked analyzed yet. This will happen when
- -- the freeze node is created during the pre-analysis of an
+ -- the freeze node is created during the preanalysis of an
-- expression function.
if Inside_A_Generic then
-- Context denotes the owner of the declarative list.
procedure Check_Entry_Contracts;
- -- Perform a pre-analysis of the pre- and postconditions of an entry
+ -- Perform a preanalysis of the pre- and postconditions of an entry
-- declaration. This must be done before full resolution and creation
-- of the parameter block, etc. to catch illegal uses within the
-- contract expression. Full analysis of the expression is done when
-- Finally this happens in some complex cases when validity checks are
-- enabled, where the same subtype declaration may be analyzed twice.
- -- This can happen if the subtype is created by the pre-analysis of
+ -- This can happen if the subtype is created by the preanalysis of
-- an attribute tht gives the range of a loop statement, and the loop
-- itself appears within an if_statement that will be rewritten during
-- expansion.
begin
-- If the domain of iteration is an array component that depends
- -- on a discriminant, create actual subtype for it. Pre-analysis
+ -- on a discriminant, create actual subtype for it. preanalysis
-- does not generate the actual subtype of a selected component.
if Nkind (Iter_Name) = N_Selected_Component
-- If the iteration is given by a range, create temporaries and
-- assignment statements block to capture the bounds and perform
-- required finalization actions in case a bound includes a function
- -- call that uses the temporary stack. We first pre-analyze a copy of
+ -- call that uses the temporary stack. We first preanalyze a copy of
-- the range in order to determine the expected type, and analyze and
-- resolve the original bounds.
else
-- A quantified expression that appears in a pre/post condition
- -- is pre-analyzed several times. If the range is given by an
+ -- is preanalyzed several times. If the range is given by an
-- attribute reference it is rewritten as a range, and this is
-- done even with expansion disabled. If the type is already set
-- do not reanalyze, because a range with static bounds may be
Set_Corresponding_Body (N, Defining_Entity (New_Body));
Set_Corresponding_Spec (New_Body, Def_Id);
- -- Within a generic pre-analyze the original expression for name
+ -- Within a generic preanalyze the original expression for name
-- capture. The body is also generated but plays no role in
-- this because it is not part of the original source.
if No (Spec_Id) and then GNATprove_Mode
- -- Inlining does not apply during pre-analysis of code
+ -- Inlining does not apply during preanalysis of code
and then Full_Analysis
end if;
-- If the selected component appears within a default expression
- -- and it has an actual subtype, the pre-analysis has not yet
+ -- and it has an actual subtype, the preanalysis has not yet
-- completed its analysis, because Insert_Actions is disabled in
-- that context. Within the init proc of the enclosing type we
-- must complete this analysis, if an actual subtype was created.
-- For relational operations, only dimension checking is
-- performed (no propagation). If one operand is the result
-- of constant folding the dimensions may have been lost
- -- in a tree copy, so assume that pre-analysis has verified
+ -- in a tree copy, so assume that preanalysis has verified
-- that dimensions are correct.
elsif N_Kind in N_Op_Compare then
then
return;
- -- Nothing to do if call is being pre-analyzed, as when within a
+ -- Nothing to do if call is being preanalyzed, as when within a
-- pre/postcondition, a predicate, or an invariant.
elsif In_Spec_Expression then
Cannot_Inline
("cannot inline & (in default expression)?", N, Nam_UA);
- -- Inlining should not be performed during pre-analysis
+ -- Inlining should not be performed during preanalysis
elsif Full_Analysis then
-- The parameter T is the Typ for the corresponding resolve call.
procedure Preanalyze_And_Resolve (N : Node_Id; T : Entity_Id);
- -- Performs a pre-analysis of expression node N. During pre-analysis, N is
+ -- Performs a preanalysis of expression node N. During preanalysis, N is
-- analyzed and then resolved against type T, but no expansion is carried
- -- out for N or its children. For more info on pre-analysis read the spec
+ -- out for N or its children. For more info on preanalysis read the spec
-- of Sem.
procedure Preanalyze_And_Resolve (N : Node_Id);
-- The tree after this light expansion should be fully analyzed
-- semantically, which sometimes requires the insertion of semantic
- -- pre-analysis, for example for subprogram contracts and pragma
+ -- preanalysis, for example for subprogram contracts and pragma
-- check/assert. In particular, all expression must have their proper type,
-- and semantic links should be set between tree nodes (partial to full
-- view, etc.) Some kinds of nodes should be either absent, or can be