Commit 6b670dcf by Arnaud Charlet

[multiple changes]

2013-04-11  Johannes Kanig  <kanig@adacore.com>

	* debug.adb: Remove comment for -gnatd.G.

2013-04-11  Thomas Quinot  <quinot@adacore.com>

	* exp_ch4.adb (Expand_Record_Equality.Suitable_Element):
	Remove recursive routine, replace with...
	(Expand_Record_Equality.Element_To_Compare): New subroutine,
	implement iterative search for next element to compare.
	Add explanatory comment in the tagged case.

From-SVN: r197747
parent ac7d724d
2013-04-11 Johannes Kanig <kanig@adacore.com>
* debug.adb: Remove comment for -gnatd.G.
2013-04-11 Thomas Quinot <quinot@adacore.com>
* exp_ch4.adb (Expand_Record_Equality.Suitable_Element):
Remove recursive routine, replace with...
(Expand_Record_Equality.Element_To_Compare): New subroutine,
implement iterative search for next element to compare.
Add explanatory comment in the tagged case.
2013-04-11 Ed Schonberg <schonberg@adacore.com> 2013-04-11 Ed Schonberg <schonberg@adacore.com>
* sem_ch5.adb: remove spurious warning from non-empty loop. * sem_ch5.adb: remove spurious warning from non-empty loop.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2013, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -124,7 +124,7 @@ package body Debug is ...@@ -124,7 +124,7 @@ package body Debug is
-- d.D Strict Alfa mode -- d.D Strict Alfa mode
-- d.E Force Alfa mode for gnat2why -- d.E Force Alfa mode for gnat2why
-- d.F Alfa mode -- d.F Alfa mode
-- d.G Precondition only mode for gnat2why -- d.G
-- d.H Standard package only mode for gnat2why -- d.H Standard package only mode for gnat2why
-- d.I SCIL generation mode -- d.I SCIL generation mode
-- d.J Disable parallel SCIL generation mode -- d.J Disable parallel SCIL generation mode
......
...@@ -10889,53 +10889,60 @@ package body Exp_Ch4 is ...@@ -10889,53 +10889,60 @@ package body Exp_Ch4 is
First_Time : Boolean := True; First_Time : Boolean := True;
function Suitable_Element (C : Entity_Id) return Entity_Id; function Element_To_Compare (C : Entity_Id) return Entity_Id;
-- Return the first field to compare beginning with C, skipping the -- Return the next discriminant or component to compare, starting with
-- inherited components. -- C, skipping inherited components.
---------------------- ------------------------
-- Suitable_Element -- -- Element_To_Compare --
---------------------- ------------------------
function Suitable_Element (C : Entity_Id) return Entity_Id is function Element_To_Compare (C : Entity_Id) return Entity_Id is
Comp : Entity_Id;
begin begin
if No (C) then Comp := C;
return Empty;
elsif Ekind (C) /= E_Discriminant loop
and then Ekind (C) /= E_Component -- Exit loop when the next element to be compared is found, or
then -- there is no more such element.
return Suitable_Element (Next_Entity (C));
-- Below test for C /= Original_Record_Component (C) is dubious exit when No (Comp);
-- if Typ is a constrained record subtype???
elsif Is_Tagged_Type (Typ) exit when Ekind_In (Comp, E_Discriminant, E_Component)
and then C /= Original_Record_Component (C) and then not (
then
return Suitable_Element (Next_Entity (C));
elsif Chars (C) = Name_uTag then -- Skip inherited components
return Suitable_Element (Next_Entity (C));
-- The .NET/JVM version of type Root_Controlled contains two fields -- Note: for a tagged type, we always generate the "=" primitive
-- which should not be considered part of the object. To achieve -- for the base type (not on the first subtype), so the test for
-- proper equiality between two controlled objects on .NET/JVM, skip -- Comp /= Original_Record_Component (Comp) is True for
-- field _parent whenever it is of type Root_Controlled. -- inherited components only.
elsif Chars (C) = Name_uParent (Is_Tagged_Type (Typ)
and then VM_Target /= No_VM and then Comp /= Original_Record_Component (Comp))
and then Etype (C) = RTE (RE_Root_Controlled)
then
return Suitable_Element (Next_Entity (C));
elsif Is_Interface (Etype (C)) then -- Skip _Tag
return Suitable_Element (Next_Entity (C));
else or else Chars (Comp) = Name_uTag
return C;
end if; -- The .NET/JVM version of type Root_Controlled contains two
end Suitable_Element; -- fields which should not be considered part of the object. To
-- achieve proper equiality between two controlled objects on
-- .NET/JVM, skip _Parent whenever it has type Root_Controlled.
or else (Chars (Comp) = Name_uParent
and then VM_Target /= No_VM
and then Etype (Comp) = RTE (RE_Root_Controlled))
-- Skip interface elements (secondary tags???)
or else Is_Interface (Etype (Comp)));
Next_Entity (Comp);
end loop;
return Comp;
end Element_To_Compare;
-- Start of processing for Expand_Record_Equality -- Start of processing for Expand_Record_Equality
...@@ -10951,7 +10958,7 @@ package body Exp_Ch4 is ...@@ -10951,7 +10958,7 @@ package body Exp_Ch4 is
-- and then Lhs.Cmpn = Rhs.Cmpn -- and then Lhs.Cmpn = Rhs.Cmpn
Result := New_Reference_To (Standard_True, Loc); Result := New_Reference_To (Standard_True, Loc);
C := Suitable_Element (First_Entity (Typ)); C := Element_To_Compare (First_Entity (Typ));
while Present (C) loop while Present (C) loop
declare declare
New_Lhs : Node_Id; New_Lhs : Node_Id;
...@@ -10995,7 +11002,7 @@ package body Exp_Ch4 is ...@@ -10995,7 +11002,7 @@ package body Exp_Ch4 is
end if; end if;
end; end;
C := Suitable_Element (Next_Entity (C)); C := Element_To_Compare (Next_Entity (C));
end loop; end loop;
return Result; return Result;
......
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