[gcc r11-1174] [Ada] Don't build equivalent record aggregate if type has predicates

Pierre-Marie de Rodat pmderodat@gcc.gnu.org
Wed Jun 10 13:37:51 GMT 2020


https://gcc.gnu.org/g:8439cae845f2148c2df5aefa120b968ec73dd07e

commit r11-1174-g8439cae845f2148c2df5aefa120b968ec73dd07e
Author: Ghjuvan Lacambre <lacambre@adacore.com>
Date:   Wed Mar 11 08:55:56 2020 +0100

    [Ada] Don't build equivalent record aggregate if type has predicates
    
    2020-06-10  Ghjuvan Lacambre  <lacambre@adacore.com>
    
    gcc/ada/
    
            * exp_ch3.adb (Build_Equivalent_Record_Aggregate): Return Empty
            if Etype of record component has predicates.

Diff:
---
 gcc/ada/exp_ch3.adb | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index 76b62019778..3bc1f607f9a 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -1211,6 +1211,17 @@ package body Exp_Ch3 is
             then
                Initialization_Warning (T);
                return Empty;
+
+               --  We need to return empty if the type has predicates because
+               --  this would otherwise duplicate calls to the predicate
+               --  function. If the type hasn't been frozen before being
+               --  referenced in the current record, the extraneous call to
+               --  the predicate function would be inserted somewhere before
+               --  the predicate function is elaborated, which would result in
+               --  an invalid tree.
+
+            elsif Has_Predicates (Etype (Comp)) then
+               return Empty;
             end if;
 
          elsif Is_Scalar_Type (Etype (Comp)) then


More information about the Gcc-cvs mailing list