The procedure Apply_Universal_Integer_Attribute_Checks is called from
the expander when an attribute nominally returning Universal_Integer
is seen so that, if resolution has determined another type for the
result, then Universal_Integer is nevertheless forced on the attribute
and a conversion is added to ensure type consistency.

But this also occurs if resolution has left Universal_Integer as type
for the result, for example in a comparison context, so the procedure
ends up generating a conversion from the type to itself.

No functional changes.

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

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

gcc/ada/

        * checks.adb (Apply_Universal_Integer_Attribute_Checks): Do not do
        anything when the type of the node is already Universal_Integer.
--- gcc/ada/checks.adb
+++ gcc/ada/checks.adb
@@ -3823,6 +3823,11 @@ package body Checks is
       if Inside_A_Generic then
          return;
 
+      --  Nothing to do if the result type is universal integer
+
+      elsif Typ = Universal_Integer then
+         return;
+
       --  Nothing to do if checks are suppressed
 
       elsif Range_Checks_Suppressed (Typ)

Reply via email to