return P_Identifier;
end if;
- -- For [all | some] indicates a quantified expression
+ -- Quantified expression or iterated component association
when Tok_For =>
if Token_Is_At_Start_Of_Line then
("quantified expression must be parenthesized",
Sloc (Node1));
end if;
+
+ -- If no quantifier keyword, this is an iterated component
+ -- in an aggregate or an ill-formed quantified expression.
+
else
Restore_Scan_State (Scan_State); -- To FOR
Node1 := P_Iterated_Component_Association;
+
+ if not (Lparen and then Token = Tok_Right_Paren) then
+ Error_Msg
+ ("construct must be parenthesized", Sloc (Node1));
+ end if;
end if;
return Node1;
("quantified expression must be parenthesized!", Result);
end if;
- else
- -- If no quantifier keyword, this is an iterated component in
- -- an aggregate.
+ -- If no quantifier keyword, this is an iterated component in
+ -- an aggregate or an ill-formed quantified expression.
+ else
Restore_Scan_State (Scan_State);
Result := P_Iterated_Component_Association;
+
+ if not (Lparen and then Token = Tok_Right_Paren) then
+ Error_Msg_N
+ ("construct must be parenthesized!", Result);
+ end if;
end if;
-- Declare expression
=>
null;
- -- A quantified expression with a missing "all" or "some" qualifier
- -- looks identical to an iterated component association. By language
- -- definition, the latter must be present within array aggregates. If
- -- this is not the case, then the iterated component association is
- -- really an illegal quantified expression. Diagnose this scenario.
-
- when N_Iterated_Component_Association =>
- Diagnose_Iterated_Component_Association (N);
-
when N_Iterated_Element_Association =>
null; -- May require a more precise error if misplaced.
| N_Function_Specification
| N_Generic_Association
| N_Index_Or_Discriminant_Constraint
+ | N_Iterated_Component_Association
| N_Iteration_Scheme
| N_Mod_Clause
| N_Modular_Type_Definition
end if;
end Designate_Same_Unit;
- ---------------------------------------------
- -- Diagnose_Iterated_Component_Association --
- ---------------------------------------------
-
- procedure Diagnose_Iterated_Component_Association (N : Node_Id) is
- Def_Id : constant Entity_Id := Defining_Identifier (N);
- Aggr : Node_Id;
-
- begin
- -- Determine whether the iterated component association appears within
- -- an aggregate. If this is the case, raise Program_Error because the
- -- iterated component association cannot be left in the tree as is and
- -- must always be processed by the related aggregate.
-
- Aggr := N;
- while Present (Aggr) loop
- if Nkind (Aggr) = N_Aggregate then
- raise Program_Error;
-
- -- Prevent the search from going too far
-
- elsif Is_Body_Or_Package_Declaration (Aggr) then
- exit;
- end if;
-
- Aggr := Parent (Aggr);
- end loop;
-
- -- At this point it is known that the iterated component association is
- -- not within an aggregate. This is really a quantified expression with
- -- a missing "all" or "some" quantifier.
-
- Error_Msg_N ("missing quantifier", Def_Id);
-
- -- Rewrite the iterated component association as True to prevent any
- -- cascaded errors.
-
- Rewrite (N, New_Occurrence_Of (Standard_True, Sloc (N)));
- Analyze (N);
- end Diagnose_Iterated_Component_Association;
-
------------------------
-- Discriminated_Size --
------------------------
-- these names is supposed to be a selected component name, an expanded
-- name, a defining program unit name or an identifier.
- procedure Diagnose_Iterated_Component_Association (N : Node_Id);
- -- Emit an error if iterated component association N is actually an illegal
- -- quantified expression lacking a quantifier.
-
function Discriminated_Size (Comp : Entity_Id) return Boolean;
-- If a component size is not static then a warning will be emitted
-- in Ravenscar or other restricted contexts. When a component is non-