diff mbox series

[COMMITTED,2/7] ada: Simplify code for inserting checks into expressions

Message ID 20240910074521.448168-2-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,1/7] ada: Whitespace cleanup in declaration of calendar-related routines | expand

Commit Message

Marc Poulhiès Sept. 10, 2024, 7:45 a.m. UTC
From: Piotr Trojanek <trojanek@adacore.com>

Code cleanup; semantics is unaffected.

gcc/ada/

	* checks.adb (Remove_Checks): Combine CASE alternatives.

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

---
 gcc/ada/checks.adb | 34 ++++++++++++----------------------
 1 file changed, 12 insertions(+), 22 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 5d7f4cca70a..57307c3da1b 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -9712,10 +9712,6 @@  package body Checks is
          Set_Do_Range_Check (N, False);
 
          case Nkind (N) is
-            when N_And_Then =>
-               Traverse (Left_Opnd (N));
-               return Skip;
-
             when N_Attribute_Reference =>
                Set_Do_Overflow_Check (N, False);
 
@@ -9723,35 +9719,29 @@  package body Checks is
                Set_Do_Overflow_Check (N, False);
 
                case Nkind (N) is
-                  when N_Op_Divide =>
-                     Set_Do_Division_Check (N, False);
-
-                  when N_Op_And =>
-                     Set_Do_Length_Check (N, False);
-
-                  when N_Op_Mod =>
-                     Set_Do_Division_Check (N, False);
-
-                  when N_Op_Or =>
-                     Set_Do_Length_Check (N, False);
-
-                  when N_Op_Rem =>
+                  when N_Op_Divide
+                     | N_Op_Mod
+                     | N_Op_Rem
+                  =>
                      Set_Do_Division_Check (N, False);
 
-                  when N_Op_Xor =>
+                  when N_Op_And
+                     | N_Op_Or
+                     | N_Op_Xor
+                  =>
                      Set_Do_Length_Check (N, False);
 
                   when others =>
                      null;
                end case;
 
-            when N_Or_Else =>
-               Traverse (Left_Opnd (N));
-               return Skip;
-
             when N_Selected_Component =>
                Set_Do_Discriminant_Check (N, False);
 
+            when N_Short_Circuit =>
+               Traverse (Left_Opnd (N));
+               return Skip;
+
             when N_Type_Conversion =>
                Set_Do_Length_Check   (N, False);
                Set_Do_Overflow_Check (N, False);