[Ada] Simplify expansion of "and then" in CodePeer mode
authorArnaud Charlet <charlet@adacore.com>
Mon, 11 Jun 2018 09:18:39 +0000 (09:18 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Mon, 11 Jun 2018 09:18:39 +0000 (09:18 +0000)
2018-06-11  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

* exp_ch4.adb (Expand_Record_Equality): Remove extraneous "True and
then" and general logical "ada" in codepeer mode.

From-SVN: r261418

gcc/ada/ChangeLog
gcc/ada/exp_ch4.adb

index cafac4fcf2abd67b47fabca000992e40c4adc6df..97dbbf3f41d94d0cc51cde1619081b9600eebc7d 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-11  Arnaud Charlet  <charlet@adacore.com>
+
+       * exp_ch4.adb (Expand_Record_Equality): Remove extraneous "True and
+       then" and general logical "ada" in codepeer mode.
+
 2018-06-11  Javier Miranda  <miranda@adacore.com>
 
        * exp_ch9.adb (Expand_N_Protected_Body): Add missing handling of
index 0d836f856987bf0127a0acc3e155fc70cecff1cf..c29ba76f11328e9358348eedbe5e56c8aca1ea4a 100644 (file)
@@ -12154,12 +12154,11 @@ package body Exp_Ch4 is
       --  Generates the following code: (assuming that Typ has one Discr and
       --  component C2 is also a record)
 
-      --   True
-      --     and then Lhs.Discr1 = Rhs.Discr1
-      --     and then Lhs.C1 = Rhs.C1
-      --     and then Lhs.C2.C1=Rhs.C2.C1 and then ... Lhs.C2.Cn=Rhs.C2.Cn
-      --     and then ...
-      --     and then Lhs.Cmpn = Rhs.Cmpn
+      --  Lhs.Discr1 = Rhs.Discr1
+      --    and then Lhs.C1 = Rhs.C1
+      --    and then Lhs.C2.C1=Rhs.C2.C1 and then ... Lhs.C2.Cn=Rhs.C2.Cn
+      --    and then ...
+      --    and then Lhs.Cmpn = Rhs.Cmpn
 
       Result := New_Occurrence_Of (Standard_True, Loc);
       C := Element_To_Compare (First_Entity (Typ));
@@ -12171,7 +12170,6 @@ package body Exp_Ch4 is
 
          begin
             if First_Time then
-               First_Time := False;
                New_Lhs := Lhs;
                New_Rhs := Rhs;
             else
@@ -12199,13 +12197,28 @@ package body Exp_Ch4 is
                Set_Etype (Result, Standard_Boolean);
                exit;
             else
-               Result :=
-                 Make_And_Then (Loc,
-                   Left_Opnd  => Result,
-                   Right_Opnd => Check);
+               if First_Time then
+                  Result := Check;
+
+               --  Generate logical "and" for CodePeer to simplify the
+               --  generated code and analysis.
+
+               elsif CodePeer_Mode then
+                  Result :=
+                    Make_Op_And (Loc,
+                      Left_Opnd  => Result,
+                      Right_Opnd => Check);
+
+               else
+                  Result :=
+                    Make_And_Then (Loc,
+                      Left_Opnd  => Result,
+                      Right_Opnd => Check);
+               end if;
             end if;
          end;
 
+         First_Time := False;
          C := Element_To_Compare (Next_Entity (C));
       end loop;