+2018-05-28 Ed Schonberg <schonberg@adacore.com>
+
+ * exp_unst.adb (Check_Static_Type): For a record subtype, check
+ discriminant constraints as well.
+ (Visit_Node): For a selected component, check type of prefix, as is
+ done for indexed components and slices.
+
2018-05-28 Javier Miranda <miranda@adacore.com>
* exp_ch4.adb (Real_Range_Check): Add a temporary to store the integer
end if;
end;
- -- For record type, check all components
+ -- For record type, check all components and discriminant
+ -- constraints if present.
elsif Is_Record_Type (T) then
declare
C : Entity_Id;
+ D : Elmt_Id;
+
begin
C := First_Component_Or_Discriminant (T);
while Present (C) loop
Check_Static_Type (Etype (C), N, DT);
Next_Component_Or_Discriminant (C);
end loop;
+
+ if Has_Discriminants (T)
+ and then Present (Discriminant_Constraint (T))
+ then
+ D := First_Elmt (Discriminant_Constraint (T));
+ while Present (D) loop
+ if not Is_Static_Expression (Node (D)) then
+ Note_Uplevel_Bound (Node (D), N);
+ DT := True;
+ end if;
+
+ Next_Elmt (D);
+ end loop;
+ end if;
end;
-- For array type, check index types and component type
Check_Static_Type (Etype (Prefix (N)), Empty, DT);
end;
+ -- A selected component can have an implicit up-level reference
+ -- due to the bounds of previous fields in the record. We
+ -- simplify the processing here by examining all components
+ -- of the record.
+
+ elsif Nkind (N) = N_Selected_Component then
+ declare
+ DT : Boolean := False;
+ begin
+ Check_Static_Type (Etype (Prefix (N)), Empty, DT);
+ end;
+
-- Record a subprogram. We record a subprogram body that acts as
-- a spec. Otherwise we record a subprogram declaration, providing
-- that it has a corresponding body we can get hold of. The case