[Ada] Spurious condition warning on type conversion in return
authorJustin Squirek <squirek@adacore.com>
Thu, 30 Apr 2020 20:04:26 +0000 (16:04 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 19 Jun 2020 08:17:22 +0000 (04:17 -0400)
2020-06-19  Justin Squirek  <squirek@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

index fe9c46714d6a87e8ae51c7d0c54addee3090f239..97d8a944f56da2c994868d180a29bd33bbeb5407 100644 (file)
@@ -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