The Safe_Unchecked_Type_Conversion predicate was invoking the
Has_Discriminant predicate without checking that the Etype really
Is_Type, which is not the case for Standard_Void_Type "returned" by
entry calls.

No functional changes.

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

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

gcc/ada/

        * exp_util.adb (Safe_Unchecked_Type_Conversion): Add missing
        Is_Type guard before calling Has_Discriminants on Etype.
--- gcc/ada/exp_util.adb
+++ gcc/ada/exp_util.adb
@@ -12551,13 +12551,10 @@ package body Exp_Util is
       elsif Nkind (Pexp) = N_Selected_Component
         and then Prefix (Pexp) = Exp
       then
-         if No (Etype (Pexp)) then
-            return True;
-         else
-            return
-              not Has_Discriminants (Etype (Pexp))
-                or else Is_Constrained (Etype (Pexp));
-         end if;
+         return No (Etype (Pexp))
+           or else not Is_Type (Etype (Pexp))
+           or else not Has_Discriminants (Etype (Pexp))
+           or else Is_Constrained (Etype (Pexp));
       end if;
 
       --  Set the output type, this comes from Etype if it is set, otherwise we

Reply via email to