Commit 4fd9587f by Ed Schonberg Committed by Pierre-Marie de Rodat

[Ada] Improve unnesting for discriminants of record subtypes

2018-05-28  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* 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.

From-SVN: r260838
parent 04920bb6
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
......
......@@ -481,17 +481,34 @@ package body Exp_Unst is
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
......@@ -685,6 +702,18 @@ package body Exp_Unst is
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment