]> gcc.gnu.org Git - gcc.git/commitdiff
[Ada] Fix invalid expression sharing in Expand_Array_Equality
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 21 Apr 2020 10:58:23 +0000 (12:58 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 18 Jun 2020 09:08:16 +0000 (05:08 -0400)
2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_ch4.adb (Expand_Array_Equality): For the optimization of
the 2-element case, build new expression lists for the indices.

gcc/ada/exp_ch4.adb

index c4cd9b59f7ba8581e5acdc52034484c89a114263..2735a480bd41086e23bd113cab95f12f8edf843a 100644 (file)
@@ -2009,34 +2009,33 @@ package body Exp_Ch4 is
             Ctyp         : constant Entity_Id := Component_Type (Ltyp);
             L, R         : Node_Id;
             TestL, TestH : Node_Id;
-            Index_List   : List_Id;
 
          begin
-            Index_List := New_List (New_Copy_Tree (Low_Bound (First_Idx)));
-
             L :=
               Make_Indexed_Component (Loc,
                 Prefix      => New_Copy_Tree (New_Lhs),
-                Expressions => Index_List);
+                Expressions =>
+                  New_List (New_Copy_Tree (Low_Bound (First_Idx))));
 
             R :=
               Make_Indexed_Component (Loc,
                 Prefix      => New_Copy_Tree (New_Rhs),
-                Expressions => Index_List);
+                Expressions =>
+                  New_List (New_Copy_Tree (Low_Bound (First_Idx))));
 
             TestL := Expand_Composite_Equality (Nod, Ctyp, L, R, Bodies);
 
-            Index_List := New_List (New_Copy_Tree (High_Bound (First_Idx)));
-
             L :=
               Make_Indexed_Component (Loc,
                 Prefix      => New_Lhs,
-                Expressions => Index_List);
+                Expressions =>
+                  New_List (New_Copy_Tree (High_Bound (First_Idx))));
 
             R :=
               Make_Indexed_Component (Loc,
                 Prefix      => New_Rhs,
-                Expressions => Index_List);
+                Expressions =>
+                  New_List (New_Copy_Tree (High_Bound (First_Idx))));
 
             TestH := Expand_Composite_Equality (Nod, Ctyp, L, R, Bodies);
 
This page took 0.078503 seconds and 5 git commands to generate.