===================================================================
@@ -446,7 +446,7 @@ package body Sem_Ch3 is
Related_Id : Entity_Id;
Suffix : Character;
Suffix_Index : Nat);
- -- Process an index constraint in a constrained array declaration. The
+ -- Process an index constraint S in a constrained array declaration. The
-- constraint can be a subtype name, or a range with or without an explicit
-- subtype mark. The index is the corresponding index of the unconstrained
-- array. The Related_Id and Suffix parameters are used to build the
@@ -4424,6 +4424,17 @@ package body Sem_Ch3 is
end if;
Make_Index (Index, P, Related_Id, Nb_Index);
+
+ -- Check error of subtype with predicate for index type
+
+ if Has_Predicates (Etype (Index)) then
+ Error_Msg_NE
+ ("subtype& has predicate, not allowed as index subtype",
+ Index, Etype (Index));
+ end if;
+
+ -- Move to next index
+
Next_Index (Index);
Nb_Index := Nb_Index + 1;
end loop;
@@ -11332,6 +11343,13 @@ package body Sem_Ch3 is
elsif Base_Type (Entity (S)) /= Base_Type (T) then
Wrong_Type (S, Base_Type (T));
+
+ -- Check error of subtype with predicate in index constraint
+
+ elsif Has_Predicates (Entity (S)) then
+ Error_Msg_NE
+ ("subtype& has predicate, not allowed in index consraint",
+ S, Entity (S));
end if;
return;
===================================================================
@@ -879,19 +879,36 @@ package body Sem_Ch9 is
Generate_Definition (Def_Id);
Tasking_Used := True;
+ -- Case of no discrete subtype definition
+
if No (D_Sdef) then
Set_Ekind (Def_Id, E_Entry);
+
+ -- Processing for discrete subtype definition present
+
else
Enter_Name (Def_Id);
Set_Ekind (Def_Id, E_Entry_Family);
Analyze (D_Sdef);
Make_Index (D_Sdef, N, Def_Id);
+
+ -- Check subtype with predicate in entry family
+
+ if Has_Predicates (Etype (D_Sdef)) then
+ Error_Msg_NE
+ ("subtype& has predicate, not allowed in entry family",
+ D_Sdef, Etype (D_Sdef));
+ end if;
end if;
+ -- Decorate Def_Id
+
Set_Etype (Def_Id, Standard_Void_Type);
Set_Convention (Def_Id, Convention_Entry);
Set_Accept_Address (Def_Id, New_Elmt_List);
+ -- Process formals
+
if Present (Formals) then
Set_Scope (Def_Id, Current_Scope);
Push_Scope (Def_Id);
===================================================================
@@ -8478,7 +8478,16 @@ package body Sem_Res is
Set_Slice_Subtype (N);
- if Nkind (Drange) = N_Range then
+ -- Check bad use of type with predicates
+
+ if Has_Predicates (Etype (Drange)) then
+ Error_Msg_NE
+ ("subtype& has predicate, not allowed in slice",
+ Drange, Etype (Drange));
+
+ -- Otherwise here is where we check suspicious indexes
+
+ elsif Nkind (Drange) = N_Range then
Warn_On_Suspicious_Index (Name, Low_Bound (Drange));
Warn_On_Suspicious_Index (Name, High_Bound (Drange));
end if;