diff mbox series

[COMMITTED] ada: Replace redundant conditions with assertions

Message ID 20240506091807.1585450-1-poulhies@adacore.com
State New
Headers show
Series [COMMITTED] ada: Replace redundant conditions with assertions | expand

Commit Message

Marc Poulhiès May 6, 2024, 9:18 a.m. UTC
From: Piotr Trojanek <trojanek@adacore.com>

Fix warnings from the CodePeer. The code structure is essentially:

  if A and B then ...
  elsif not A and not B then ...
  elsif A then ...
  elsif B then ...  --  this condition is redundant
  end if;

and it causes CodePeer to say "exception is raised in a conditional
branch", which most likely means that the condition is redundant.

gcc/ada/

	* make.adb (Scan_Make_Arg): Remove redundant condition.
	* switch-b.adb (Scan_Debug_Switches): Likewise.
	* switch-c.adb (Scan_Front_End_Switches): Likewise.

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

---
 gcc/ada/make.adb     | 2 +-
 gcc/ada/switch-b.adb | 2 +-
 gcc/ada/switch-c.adb | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb
index 01d3ccab8af..24b2d099bfe 100644
--- a/gcc/ada/make.adb
+++ b/gcc/ada/make.adb
@@ -4508,7 +4508,7 @@  package body Make is
                      Make_Failed
                        ("RTS path not valid: missing adainclude directory");
 
-                  elsif Lib_Path_Name = null then
+                  else pragma Assert (Lib_Path_Name = null);
                      Make_Failed
                        ("RTS path not valid: missing adalib directory");
                   end if;
diff --git a/gcc/ada/switch-b.adb b/gcc/ada/switch-b.adb
index 2c4fc0c6039..8d8dc58937c 100644
--- a/gcc/ada/switch-b.adb
+++ b/gcc/ada/switch-b.adb
@@ -703,7 +703,7 @@  package body Switch.B is
                      elsif Src_Path_Name = null then
                         Osint.Fail
                           ("RTS path not valid: missing adainclude directory");
-                     elsif Lib_Path_Name = null then
+                     else pragma Assert (Lib_Path_Name = null);
                         Osint.Fail
                           ("RTS path not valid: missing adalib directory");
                      end if;
diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb
index 7668fce885a..43b69f1dde1 100644
--- a/gcc/ada/switch-c.adb
+++ b/gcc/ada/switch-c.adb
@@ -274,7 +274,7 @@  package body Switch.C is
                      Osint.Fail ("RTS path not valid: missing "
                                  & "adainclude directory");
 
-                  elsif RTS_Lib_Path_Name = null then
+                  else pragma Assert (RTS_Lib_Path_Name = null);
                      Osint.Fail ("RTS path not valid: missing "
                                  & "adalib directory");
                   end if;