diff mbox

[Ada] Ensure record type equality treated correctly for codepeer

Message ID 20141017084247.GA4657@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Oct. 17, 2014, 8:42 a.m. UTC
This is an internal change that does not affect the compiler, but fixes
a problem in which a record comparison was not properly expanded. The
compiler back end handled this, but it blew up codepeer. No further
test required.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-10-17  Robert Dewar  <dewar@adacore.com>

	* exp_ch4.adb (Expand_N_Op_Eq): Make sure we deal with the
	implementation base type.
	* sinfo.ads: Add a note for N_Op_Eq and N_Op_Ne that record
	operands are always expanded out into component comparisons.
diff mbox

Patch

Index: exp_ch4.adb
===================================================================
--- exp_ch4.adb	(revision 216367)
+++ exp_ch4.adb	(working copy)
@@ -7152,8 +7152,11 @@ 
          return;
       end if;
 
-      Typl := Base_Type (Typl);
+      --  Now get the implementation base type (note that plain Base_Type here
+      --  might lead us back to the private type, which is not what we want!)
 
+      Typl := Implementation_Base_Type (Typl);
+
       --  Equality between variant records results in a call to a routine
       --  that has conditional tests of the discriminant value(s), and hence
       --  violates the No_Implicit_Conditionals restriction.
Index: sinfo.ads
===================================================================
--- sinfo.ads	(revision 216367)
+++ sinfo.ads	(working copy)
@@ -4246,6 +4246,11 @@ 
       --  point operands if the Treat_Fixed_As_Integer flag is set and will
       --  thus treat these nodes in identical manner, ignoring small values.
 
+      --  Note on equality/inequality tests for records. In the expanded tree,
+      --  record comparisons are always expanded to be a series of component
+      --  comparisons, so the back end will never see an equality or inequality
+      --  operation with operands of a record type.
+
       --  Note on overflow handling: When the overflow checking mode is set to
       --  MINIMIZED or ELIMINATED, nodes for signed arithmetic operations may
       --  be modified to use a larger type for the operands and result. In