]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Replace redundant conditions with assertions
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 19 Dec 2023 09:23:55 +0000 (10:23 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 6 May 2024 09:11:27 +0000 (11:11 +0200)
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.

gcc/ada/make.adb
gcc/ada/switch-b.adb
gcc/ada/switch-c.adb

index 01d3ccab8afdcd77eca1ddee02f67404d2ebb834..24b2d099bfebae1758f2888966864c919e1a6c89 100644 (file)
@@ -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;
index 2c4fc0c60398d120028a79dd6bc4b926af011568..8d8dc58937c1f85684485e62d74afd2da6e15c09 100644 (file)
@@ -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;
index 7668fce885a0bd27b82680f4fe88c468c199ae23..43b69f1dde150f2d6873e24719368c388f77c910 100644 (file)
@@ -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;