This patch fixes the compiler whereby a conversion to Interfaces.C.Bool
within a return statement may cause a spurious "condition always X"
warning.

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

2020-06-19  Justin Squirek  <squi...@adacore.com>

gcc/ada/

        * sem_warn.adb (Warn_On_Known_Condition): Add general sanity
        check that asserts the original source node being checked
        contains an entity. If not, it could be the result of special
        case expansion for type conversions.
--- gcc/ada/sem_warn.adb
+++ gcc/ada/sem_warn.adb
@@ -3520,6 +3520,7 @@ package body Sem_Warn is
       if Constant_Condition_Warnings
         and then Is_Known_Branch
         and then Comes_From_Source (Orig)
+        and then Nkind (Orig) in N_Has_Entity
         and then not In_Instance
       then
          --  Don't warn if comparison of result of attribute against a constant

Reply via email to