[Ada] Bug in composition of equality for variant records
authorEd Schonberg <schonberg@adacore.com>
Thu, 4 Jul 2019 08:06:35 +0000 (08:06 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Thu, 4 Jul 2019 08:06:35 +0000 (08:06 +0000)
commitbdbb2a405541671bb427f6ff2f463a98c62b0a46
tree3260367cd1c04b40b87c5d06b29c5333cb04cddf
parentfa528281a9d056bf5beb867333ea4eea638a102d
[Ada] Bug in composition of equality for variant records

This patch fixes an omission in the construction of equality routines
for variant records, to take into account user-defined equality
functions for components of the record. Previously the constructed
equality routine for variant records used the predefined equality for
all components, When composavility of equality was introduced for
untagged records, expansion of record equality was modified properly,
but not for the case of variant records, which use a different and more
complex process to build the equality function.

2019-07-04  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* exp_ch4.ads, exp_ch4.adb (Build_Eq_Call): New visible
subprogram, extracted from Expand_Composite_Equality, to handle
properly the composition of equality for variant record types.
* exp_ch3.adb (MAke_Eq_If): Use Build_Eq_Call for each
component, to handle properly the case of a component with a
user-defined equality. Revert to predefined equality if the
user-defined operation is abstract, to maintain compatibility
with older versions,

gcc/testsuite/

* gnat.dg/equal6.adb, gnat.dg/equal6_types.adb,
gnat.dg/equal6_types.ads: New testcase.

From-SVN: r273062
gcc/ada/ChangeLog
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch4.adb
gcc/ada/exp_ch4.ads
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/equal6.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/equal6_types.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/equal6_types.ads [new file with mode: 0644]