[COMMITTED,20/51] ada: Refactor Has_Assertion_Level_Argument for consistency

Message ID 20260602084541.3829876-20-poulhies@adacore.com
State Committed
Commit 7fbb8361a5ffe4782cb22d114a8be057ac96bd03
Headers
Series [COMMITTED,01/51] ada: Rename Private_Component function |

Commit Message

Marc Poulhiès June 2, 2026, 8:45 a.m. UTC
  From: Mathias Aparicio <aparicio@adacore.com>

First branches of `Has_Assertion_Level_Argument` test an equality and if
met return False.

This patch apply this logic for the two other if that returned False
after the if.

gcc/ada/ChangeLog:

	* sem_util.adb (Has_Assertion_Level_Argument): Invert the final
	check in aspect branch and the check in pragma branch to use
	early returns for consistency.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_util.adb | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
  

Patch

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 43850d6cfc2..2590e411f0c 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -11517,20 +11517,20 @@  package body Sem_Util is
 
          Choice := First (Choices (Assoc));
 
-         if Nkind (Choice) = N_Identifier then
-            return Present (Get_Assertion_Level (Chars (Choice)));
+         if Nkind (Choice) /= N_Identifier then
+            return False;
          end if;
 
-         return False;
+         return Present (Get_Assertion_Level (Chars (Choice)));
       else
          pragma Assert (Nkind (N) = N_Pragma);
          Assocs := Pragma_Argument_Associations (N);
          Assoc := First (Assocs);
-         if Present (Assoc) and then Chars (Assoc) /= No_Name then
-            return Present (Get_Assertion_Level (Chars (Assoc)));
+         if No (Assoc) or else Chars (Assoc) = No_Name then
+            return False;
          end if;
 
-         return False;
+         return Present (Get_Assertion_Level (Chars (Assoc)));
       end if;
    end Has_Assertion_Level_Argument;