===================================================================
@@ -2310,7 +2310,7 @@
then
Bad_Predicated_Subtype_Use
("cannot use subtype& with non-static predicate for loop " &
- "iteration", DS, Entity (DS));
+ "iteration", DS, Entity (DS), Suggest_Static => True);
end if;
end if;
===================================================================
@@ -449,9 +449,10 @@
--------------------------------
procedure Bad_Predicated_Subtype_Use
- (Msg : String;
- N : Node_Id;
- Typ : Entity_Id)
+ (Msg : String;
+ N : Node_Id;
+ Typ : Entity_Id;
+ Suggest_Static : Boolean := False)
is
begin
if Has_Predicates (Typ) then
@@ -465,6 +466,13 @@
else
Error_Msg_FE (Msg, N, Typ);
end if;
+
+ -- Emit an optional suggestion on how to remedy the error if the
+ -- context warrants it.
+
+ if Suggest_Static and then Present (Static_Predicate (Typ)) then
+ Error_Msg_FE ("\predicate of & should be marked static", N, Typ);
+ end if;
end if;
end Bad_Predicated_Subtype_Use;
===================================================================
@@ -122,19 +122,21 @@
-- is an error.
procedure Bad_Predicated_Subtype_Use
- (Msg : String;
- N : Node_Id;
- Typ : Entity_Id);
+ (Msg : String;
+ N : Node_Id;
+ Typ : Entity_Id;
+ Suggest_Static : Boolean := False);
-- This is called when Typ, a predicated subtype, is used in a context
- -- which does not allow the use of a predicated subtype. Msg is passed
- -- to Error_Msg_FE to output an appropriate message using N as the
- -- location, and Typ as the entity. The caller must set up any insertions
- -- other than the & for the type itself. Note that if Typ is a generic
- -- actual type, then the message will be output as a warning, and a
- -- raise Program_Error is inserted using Insert_Action with node N as
- -- the insertion point. Node N also supplies the source location for
- -- construction of the raise node. If Typ is NOT a type with predicates
- -- this call has no effect.
+ -- which does not allow the use of a predicated subtype. Msg is passed to
+ -- Error_Msg_FE to output an appropriate message using N as the location,
+ -- and Typ as the entity. The caller must set up any insertions other than
+ -- the & for the type itself. Note that if Typ is a generic actual type,
+ -- then the message will be output as a warning, and a raise Program_Error
+ -- is inserted using Insert_Action with node N as the insertion point. Node
+ -- N also supplies the source location for construction of the raise node.
+ -- If Typ does not have any predicates, the call has no effect. Set flag
+ -- Suggest_Static when the context warrants an advice on how to avoid the
+ -- use error.
function Build_Actual_Subtype
(T : Entity_Id;
===================================================================
@@ -1260,7 +1260,8 @@
then
Bad_Predicated_Subtype_Use
("cannot use subtype& with non-static "
- & "predicate as case alternative", Choice, E);
+ & "predicate as case alternative", Choice, E,
+ Suggest_Static => True);
-- Static predicate case