]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Avoid extra conversion in expansion of packed array assignments
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 3 Oct 2023 19:33:32 +0000 (21:33 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 7 Nov 2023 09:15:02 +0000 (10:15 +0100)
Expansion of assignments to packed array objects with string literals on
the right-hand side, created an unnecessary conversion, i.e.:

  ... :=
    component_type
      (declare
         temp : component_type := "string_literal";
       begin
         temp)

Now the expansion omits the outer type conversion.

Cleanup; behavior is unaffected.

gcc/ada/

* exp_pakd.adb (Expand_Bit_Packed_Element_Set): Simplify handling of
assignments with string literals.

gcc/ada/exp_pakd.adb

index ef0ec1e001400a5c7662958c748542e1a086df3f..e197211736a6135f57792915f91ac83c670e991d 100644 (file)
@@ -1143,9 +1143,10 @@ package body Exp_Pakd is
             Insert_Actions (N, New_List (Decl));
             Rhs := New_Occurrence_Of (Defining_Identifier (Decl), Loc);
          end;
+      else
+         Rhs := Convert_To (Ctyp, Rhs);
       end if;
 
-      Rhs := Convert_To (Ctyp, Rhs);
       Set_Parent (Rhs, N);
 
       --  If we are building the initialization procedure for a packed array,