Commit 05dbb83f by Arnaud Charlet

[multiple changes]

2017-05-02  Eric Botcazou  <ebotcazou@adacore.com>

	* einfo.ads (Corresponding_Record_Component): New alias
	for Node21 used for E_Component and E_Discriminant.
	* einfo.adb (Corresponding_Record_Component): New function.
	(Set_Corresponding_Record_Component): New procedure.
	(Write_Field21_Name): Handle Corresponding_Record_Component.
	* sem_ch3.adb (Inherit_Component): Set
	Corresponding_Record_Component for every component in
	the untagged case.  Clear it afterwards for non-girder
	discriminants.
	* gcc-interface/decl.c (gnat_to_gnu_entity)
	<E_Record_Type>: For a derived untagged type with discriminants
	and constraints, apply the constraints to the layout of the
	parent type to deduce the layout.
	(field_is_aliased): Delete.
	(components_to_record): Test DECL_ALIASED_P directly.
	(annotate_rep): Check that fields are present except for
	an extension.
	(create_field_decl_from): Add DEBUG_INFO_P
	parameter and pass it in recursive and other calls.  Add guard
	for the manual CSE on the size.
	(is_stored_discriminant): New predicate.
	(copy_and_substitute_in_layout): Consider only
	stored discriminants and check that original fields are present
	in the old type.  Deal with derived types.  Adjust call to
	create_variant_part_from.

2017-05-02  Ed Schonberg  <schonberg@adacore.com>

	* exp_ch6.adb (Expand_Call_Helper): When locating the
	accessibility entity created for an access parameter, handle
	properly a reference to a formal of an enclosing subprogram. if
	the reference appears in an inherited class-wide condition, it
	is the rewriting of the reference in the ancestor expression,
	but the accessibility entity must be that of the current formal.

2017-05-02  Javier Miranda  <miranda@adacore.com>

	* exp_ch4.adb (Expand_Non_Binary_Modular_Op): New subprogram.
	(Expand_N_Op_Add, Expand_N_Op_Divide, Expand_N_Op_Minus,
	Expand_N_Op_Multiply, Expand_N_Op_Or, Expand_N_Op_Subtract):
	Call Expand_Non_Binary_Modular_Op.

From-SVN: r247482
parent f934fd02
2017-05-02 Eric Botcazou <ebotcazou@adacore.com> 2017-05-02 Eric Botcazou <ebotcazou@adacore.com>
* einfo.ads (Corresponding_Record_Component): New alias
for Node21 used for E_Component and E_Discriminant.
* einfo.adb (Corresponding_Record_Component): New function.
(Set_Corresponding_Record_Component): New procedure.
(Write_Field21_Name): Handle Corresponding_Record_Component.
* sem_ch3.adb (Inherit_Component): Set
Corresponding_Record_Component for every component in
the untagged case. Clear it afterwards for non-girder
discriminants.
* gcc-interface/decl.c (gnat_to_gnu_entity)
<E_Record_Type>: For a derived untagged type with discriminants
and constraints, apply the constraints to the layout of the
parent type to deduce the layout.
(field_is_aliased): Delete.
(components_to_record): Test DECL_ALIASED_P directly.
(annotate_rep): Check that fields are present except for
an extension.
(create_field_decl_from): Add DEBUG_INFO_P
parameter and pass it in recursive and other calls. Add guard
for the manual CSE on the size.
(is_stored_discriminant): New predicate.
(copy_and_substitute_in_layout): Consider only
stored discriminants and check that original fields are present
in the old type. Deal with derived types. Adjust call to
create_variant_part_from.
2017-05-02 Ed Schonberg <schonberg@adacore.com>
* exp_ch6.adb (Expand_Call_Helper): When locating the
accessibility entity created for an access parameter, handle
properly a reference to a formal of an enclosing subprogram. if
the reference appears in an inherited class-wide condition, it
is the rewriting of the reference in the ancestor expression,
but the accessibility entity must be that of the current formal.
2017-05-02 Javier Miranda <miranda@adacore.com>
* exp_ch4.adb (Expand_Non_Binary_Modular_Op): New subprogram.
(Expand_N_Op_Add, Expand_N_Op_Divide, Expand_N_Op_Minus,
Expand_N_Op_Multiply, Expand_N_Op_Or, Expand_N_Op_Subtract):
Call Expand_Non_Binary_Modular_Op.
2017-05-02 Eric Botcazou <ebotcazou@adacore.com>
* sem_ch3.adb (Build_Derived_Private_Type): If the parent type * sem_ch3.adb (Build_Derived_Private_Type): If the parent type
has discriminants, do not override the Stored_Constraint list of has discriminants, do not override the Stored_Constraint list of
the full view of the derived type with that of the derived type. the full view of the derived type with that of the derived type.
......
...@@ -185,6 +185,7 @@ package body Einfo is ...@@ -185,6 +185,7 @@ package body Einfo is
-- Scalar_Range Node20 -- Scalar_Range Node20
-- Accept_Address Elist21 -- Accept_Address Elist21
-- Corresponding_Record_Component Node21
-- Default_Expr_Function Node21 -- Default_Expr_Function Node21
-- Discriminant_Constraint Elist21 -- Discriminant_Constraint Elist21
-- Interface_Name Node21 -- Interface_Name Node21
...@@ -950,6 +951,12 @@ package body Einfo is ...@@ -950,6 +951,12 @@ package body Einfo is
return Node18 (Id); return Node18 (Id);
end Corresponding_Protected_Entry; end Corresponding_Protected_Entry;
function Corresponding_Record_Component (Id : E) return E is
begin
pragma Assert (Ekind_In (Id, E_Component, E_Discriminant));
return Node21 (Id);
end Corresponding_Record_Component;
function Corresponding_Record_Type (Id : E) return E is function Corresponding_Record_Type (Id : E) return E is
begin begin
pragma Assert (Is_Concurrent_Type (Id)); pragma Assert (Is_Concurrent_Type (Id));
...@@ -4083,6 +4090,12 @@ package body Einfo is ...@@ -4083,6 +4090,12 @@ package body Einfo is
Set_Node18 (Id, V); Set_Node18 (Id, V);
end Set_Corresponding_Protected_Entry; end Set_Corresponding_Protected_Entry;
procedure Set_Corresponding_Record_Component (Id : E; V : E) is
begin
pragma Assert (Ekind_In (Id, E_Component, E_Discriminant));
Set_Node21 (Id, V);
end Set_Corresponding_Record_Component;
procedure Set_Corresponding_Record_Type (Id : E; V : E) is procedure Set_Corresponding_Record_Type (Id : E; V : E) is
begin begin
pragma Assert (Is_Concurrent_Type (Id)); pragma Assert (Is_Concurrent_Type (Id));
...@@ -10402,6 +10415,11 @@ package body Einfo is ...@@ -10402,6 +10415,11 @@ package body Einfo is
when Entry_Kind => when Entry_Kind =>
Write_Str ("Accept_Address"); Write_Str ("Accept_Address");
when E_Component
| E_Discriminant
=>
Write_Str ("Corresponding_Record_Component");
when E_In_Parameter => when E_In_Parameter =>
Write_Str ("Default_Expr_Function"); Write_Str ("Default_Expr_Function");
......
...@@ -762,6 +762,14 @@ package Einfo is ...@@ -762,6 +762,14 @@ package Einfo is
-- Defined in subprogram bodies. Set for subprogram bodies that implement -- Defined in subprogram bodies. Set for subprogram bodies that implement
-- a protected type entry to point to the entity for the entry. -- a protected type entry to point to the entity for the entry.
-- Corresponding_Record_Component (Node21)
-- Defined in components of a derived untagged record type, including
-- discriminants. For a regular component or a girder discriminant,
-- points to the corresponding component in the parent type. Set to
-- Empty for a non-girder discriminant. It is used by the back end to
-- ensure the layout of the derived type matches that of the parent
-- type when there is no representation clause on the derived type.
-- Corresponding_Record_Type (Node18) -- Corresponding_Record_Type (Node18)
-- Defined in protected and task types and subtypes. References the -- Defined in protected and task types and subtypes. References the
-- entity for the corresponding record type constructed by the expander -- entity for the corresponding record type constructed by the expander
...@@ -5815,6 +5823,7 @@ package Einfo is ...@@ -5815,6 +5823,7 @@ package Einfo is
-- Prival (Node17) -- Prival (Node17)
-- Renamed_Object (Node18) (always Empty) -- Renamed_Object (Node18) (always Empty)
-- Discriminant_Checking_Func (Node20) -- Discriminant_Checking_Func (Node20)
-- Corresponding_Record_Component (Node21)
-- Original_Record_Component (Node22) -- Original_Record_Component (Node22)
-- DT_Offset_To_Top_Func (Node25) -- DT_Offset_To_Top_Func (Node25)
-- Related_Type (Node27) -- Related_Type (Node27)
...@@ -5908,6 +5917,7 @@ package Einfo is ...@@ -5908,6 +5917,7 @@ package Einfo is
-- Renamed_Object (Node18) (always Empty) -- Renamed_Object (Node18) (always Empty)
-- Corresponding_Discriminant (Node19) -- Corresponding_Discriminant (Node19)
-- Discriminant_Default_Value (Node20) -- Discriminant_Default_Value (Node20)
-- Corresponding_Record_Component (Node21)
-- Original_Record_Component (Node22) -- Original_Record_Component (Node22)
-- CR_Discriminant (Node23) -- CR_Discriminant (Node23)
-- Is_Completely_Hidden (Flag103) -- Is_Completely_Hidden (Flag103)
...@@ -6943,6 +6953,7 @@ package Einfo is ...@@ -6943,6 +6953,7 @@ package Einfo is
function Corresponding_Function (Id : E) return E; function Corresponding_Function (Id : E) return E;
function Corresponding_Procedure (Id : E) return E; function Corresponding_Procedure (Id : E) return E;
function Corresponding_Protected_Entry (Id : E) return E; function Corresponding_Protected_Entry (Id : E) return E;
function Corresponding_Record_Component (Id : E) return E;
function Corresponding_Record_Type (Id : E) return E; function Corresponding_Record_Type (Id : E) return E;
function Corresponding_Remote_Type (Id : E) return E; function Corresponding_Remote_Type (Id : E) return E;
function CR_Discriminant (Id : E) return E; function CR_Discriminant (Id : E) return E;
...@@ -7632,6 +7643,7 @@ package Einfo is ...@@ -7632,6 +7643,7 @@ package Einfo is
procedure Set_Corresponding_Function (Id : E; V : E); procedure Set_Corresponding_Function (Id : E; V : E);
procedure Set_Corresponding_Procedure (Id : E; V : E); procedure Set_Corresponding_Procedure (Id : E; V : E);
procedure Set_Corresponding_Protected_Entry (Id : E; V : E); procedure Set_Corresponding_Protected_Entry (Id : E; V : E);
procedure Set_Corresponding_Record_Component (Id : E; V : E);
procedure Set_Corresponding_Record_Type (Id : E; V : E); procedure Set_Corresponding_Record_Type (Id : E; V : E);
procedure Set_Corresponding_Remote_Type (Id : E; V : E); procedure Set_Corresponding_Remote_Type (Id : E; V : E);
procedure Set_CR_Discriminant (Id : E; V : E); procedure Set_CR_Discriminant (Id : E; V : E);
...@@ -8435,6 +8447,7 @@ package Einfo is ...@@ -8435,6 +8447,7 @@ package Einfo is
pragma Inline (Corresponding_Discriminant); pragma Inline (Corresponding_Discriminant);
pragma Inline (Corresponding_Equality); pragma Inline (Corresponding_Equality);
pragma Inline (Corresponding_Protected_Entry); pragma Inline (Corresponding_Protected_Entry);
pragma Inline (Corresponding_Record_Component);
pragma Inline (Corresponding_Record_Type); pragma Inline (Corresponding_Record_Type);
pragma Inline (Corresponding_Remote_Type); pragma Inline (Corresponding_Remote_Type);
pragma Inline (CR_Discriminant); pragma Inline (CR_Discriminant);
...@@ -8960,6 +8973,7 @@ package Einfo is ...@@ -8960,6 +8973,7 @@ package Einfo is
pragma Inline (Set_Corresponding_Discriminant); pragma Inline (Set_Corresponding_Discriminant);
pragma Inline (Set_Corresponding_Equality); pragma Inline (Set_Corresponding_Equality);
pragma Inline (Set_Corresponding_Protected_Entry); pragma Inline (Set_Corresponding_Protected_Entry);
pragma Inline (Set_Corresponding_Record_Component);
pragma Inline (Set_Corresponding_Record_Type); pragma Inline (Set_Corresponding_Record_Type);
pragma Inline (Set_Corresponding_Remote_Type); pragma Inline (Set_Corresponding_Remote_Type);
pragma Inline (Set_CR_Discriminant); pragma Inline (Set_CR_Discriminant);
......
...@@ -2938,6 +2938,16 @@ package body Exp_Ch6 is ...@@ -2938,6 +2938,16 @@ package body Exp_Ch6 is
and then Is_Aliased_View (Prev_Orig) and then Is_Aliased_View (Prev_Orig)
then then
Prev_Orig := Prev; Prev_Orig := Prev;
-- If the actual is a formal of an enclosing subprogram it is
-- the right entity, even if it is a rewriting. This happens
-- when the call is within an inherited condition or predicate.
elsif Is_Entity_Name (Actual)
and then Is_Formal (Entity (Actual))
and then In_Open_Scopes (Scope (Entity (Actual)))
then
Prev_Orig := Prev;
end if; end if;
-- Ada 2005 (AI-251): Thunks must propagate the extra actuals of -- Ada 2005 (AI-251): Thunks must propagate the extra actuals of
......
...@@ -18147,6 +18147,7 @@ package body Sem_Ch3 is ...@@ -18147,6 +18147,7 @@ package body Sem_Ch3 is
if not Is_Tagged then if not Is_Tagged then
Set_Original_Record_Component (New_C, New_C); Set_Original_Record_Component (New_C, New_C);
Set_Corresponding_Record_Component (New_C, Old_C);
end if; end if;
-- Set the proper type of an access discriminant -- Set the proper type of an access discriminant
...@@ -18245,6 +18246,7 @@ package body Sem_Ch3 is ...@@ -18245,6 +18246,7 @@ package body Sem_Ch3 is
and then Original_Record_Component (Corr_Discrim) = Old_C and then Original_Record_Component (Corr_Discrim) = Old_C
then then
Set_Original_Record_Component (Discrim, New_C); Set_Original_Record_Component (Discrim, New_C);
Set_Corresponding_Record_Component (Discrim, Empty);
end if; end if;
Next_Discriminant (Discrim); Next_Discriminant (Discrim);
......
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