diff mbox series

[COMMITTED,1/9] ada: Remove repeated guards in validity checks

Message ID 20240902082430.1863631-1-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,1/9] ada: Remove repeated guards in validity checks | expand

Commit Message

Marc Poulhiès Sept. 2, 2024, 8:24 a.m. UTC
From: Piotr Trojanek <trojanek@adacore.com>

Routine Insert_Valid_Check only applies checks when Expr_Known_Valid
query returns False; there is no need to call this query before
inserting checks.

Code cleanup; behavior is unaffected.

gcc/ada/

	* exp_imgv.adb (Expand_User_Defined_Enumeration_Image)
	(Expand_Image_Attribute): Remove redundant guards.

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

---
 gcc/ada/exp_imgv.adb | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb
index e5d84cc52e3..ce052c13c88 100644
--- a/gcc/ada/exp_imgv.adb
+++ b/gcc/ada/exp_imgv.adb
@@ -896,9 +896,7 @@  package body Exp_Imgv is
          --  Apply a validity check, since it is a bit drastic to get a
          --  completely junk image value for an invalid value.
 
-         if not Expr_Known_Valid (Expr) then
-            Insert_Valid_Check (Expr);
-         end if;
+         Insert_Valid_Check (Expr);
 
          --  Generate:
          --    P1 : constant Natural := Typ'Pos (Typ?(Expr));
@@ -1249,9 +1247,7 @@  package body Exp_Imgv is
             --  Apply a validity check, since it is a bit drastic to get a
             --  completely junk image value for an invalid value.
 
-            if not Expr_Known_Valid (Expr) then
-               Insert_Valid_Check (Expr);
-            end if;
+            Insert_Valid_Check (Expr);
 
             Enum_Case := True;
          end if;