[Ada] Simplify returning from Enclosing_Comp_Unit_Node
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 11 May 2021 11:01:35 +0000 (13:01 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 6 Jul 2021 14:46:57 +0000 (14:46 +0000)
gcc/ada/

* sem_util.adb (Enclosing_Comp_Unit_Node): When the loop exits
the Current_Node is either an N_Compilation_Unit node or Empty,
so simply return it without redundant checks.

gcc/ada/sem_util.adb

index cfb3293..9d54309 100644 (file)
@@ -8037,11 +8037,7 @@ package body Sem_Util is
          Current_Node := Parent (Current_Node);
       end loop;
 
-      if Nkind (Current_Node) /= N_Compilation_Unit then
-         return Empty;
-      else
-         return Current_Node;
-      end if;
+      return Current_Node;
    end Enclosing_Comp_Unit_Node;
 
    --------------------------