This gets rid of one more case where the front-end would create a
temporary in Universal_Integer type, which is unnecessary.

The reason is that Universal_Integer must be a type as large as the
largest supported integer type and, therefore, can be much larger than
what is really needed here.

No functional changes.

Tested on x86_64-pc-linux-gnu, committed on trunk

2020-06-03  Eric Botcazou  <ebotca...@adacore.com>

gcc/ada/

        * exp_util.adb (Remove_Side_Effects): For a type conversion, do
        not remove the side effects of the expression only if it is of
        universal integer type.
--- gcc/ada/exp_util.adb
+++ gcc/ada/exp_util.adb
@@ -11428,12 +11428,15 @@ package body Exp_Util is
          goto Leave;
 
       --  If this is a type conversion, leave the type conversion and remove
-      --  the side effects in the expression. This is important in several
-      --  circumstances: for change of representations, and also when this is a
-      --  view conversion to a smaller object, where gigi can end up creating
-      --  its own temporary of the wrong size.
-
-      elsif Nkind (Exp) = N_Type_Conversion then
+      --  side effects in the expression, unless it is of universal integer,
+      --  which is a very large type for a temporary. This is important in
+      --  several circumstances: for change of representations and also when
+      --  this is a view conversion to a smaller object, where gigi can end
+      --  up creating its own temporary of the wrong size.
+
+      elsif Nkind (Exp) = N_Type_Conversion
+        and then Etype (Expression (Exp)) /= Universal_Integer
+      then
          Remove_Side_Effects (Expression (Exp), Name_Req, Variable_Ref);
 
          --  Generating C code the type conversion of an access to constrained

Reply via email to