]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Remove unnecessary "return;" statements
authorBob Duff <duff@adacore.com>
Fri, 30 May 2025 18:53:41 +0000 (14:53 -0400)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 3 Jul 2025 08:16:21 +0000 (10:16 +0200)
A "return;" at the end of a procedure is unnecessary and
misleading. This patch removes them.

gcc/ada/ChangeLog:

* checks.adb: Remove unnecessary "return;" statements.
* eval_fat.adb: Likewise.
* exp_aggr.adb: Likewise.
* exp_attr.adb: Likewise.
* exp_ch3.adb: Likewise.
* exp_ch4.adb: Likewise.
* exp_ch5.adb: Likewise.
* exp_ch6.adb: Likewise.
* exp_unst.adb: Likewise.
* krunch.adb: Likewise.
* layout.adb: Likewise.
* libgnat/s-excdeb.adb: Likewise.
* libgnat/s-trasym__dwarf.adb: Likewise.
* par-endh.adb: Likewise.
* par-tchk.adb: Likewise.
* sem.adb: Likewise.
* sem_attr.adb: Likewise.
* sem_ch6.adb: Likewise.
* sem_elim.adb: Likewise.
* sem_eval.adb: Likewise.
* sfn_scan.adb: Likewise.

21 files changed:
gcc/ada/checks.adb
gcc/ada/eval_fat.adb
gcc/ada/exp_aggr.adb
gcc/ada/exp_attr.adb
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch4.adb
gcc/ada/exp_ch5.adb
gcc/ada/exp_ch6.adb
gcc/ada/exp_unst.adb
gcc/ada/krunch.adb
gcc/ada/layout.adb
gcc/ada/libgnat/s-excdeb.adb
gcc/ada/libgnat/s-trasym__dwarf.adb
gcc/ada/par-endh.adb
gcc/ada/par-tchk.adb
gcc/ada/sem.adb
gcc/ada/sem_attr.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_elim.adb
gcc/ada/sem_eval.adb
gcc/ada/sfn_scan.adb

index 6a98292d1cc163f09a786bfe2955a066b961664a..0b3ae02259e3586a47ff29da88c82b5052f854ee 100644 (file)
@@ -750,7 +750,7 @@ package body Checks is
       --  mode then just skip the check (it is not required in any case).
 
       when RE_Not_Available =>
-         return;
+         null;
    end Apply_Address_Clause_Check;
 
    -------------------------------------
@@ -1078,7 +1078,7 @@ package body Checks is
 
       exception
          when RE_Not_Available =>
-            return;
+            null;
       end;
    end Apply_Arithmetic_Overflow_Strict;
 
@@ -6437,8 +6437,6 @@ package body Checks is
          if Debug_Flag_CC then
             w ("  exception occurred, overflow flag set");
          end if;
-
-         return;
    end Enable_Overflow_Check;
 
    ------------------------
@@ -6686,8 +6684,6 @@ package body Checks is
          if Debug_Flag_CC then
             w ("  exception occurred, range flag set");
          end if;
-
-         return;
    end Enable_Range_Check;
 
    ------------------
@@ -7091,8 +7087,6 @@ package body Checks is
       end loop;
 
       --  If we fall through entry was not found
-
-      return;
    end Find_Check;
 
    ---------------------------------
index 09a5b3fa1b7a7cc0bce1ea9453afe81d6654e27c..5a2e43ef59785da634b792dd150b9a4297a8838b 100644 (file)
@@ -146,8 +146,6 @@ package body Eval_Fat is
       if UR_Is_Negative (X) then
          Fraction := -Fraction;
       end if;
-
-      return;
    end Decompose;
 
    -------------------
index e3734a2d8c9cc306ca674b8084092c47c41e8d6b..fcf57bf9c31cb2fc4059a286cc8265889c501927 100644 (file)
@@ -6633,7 +6633,7 @@ package body Exp_Aggr is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Expand_N_Aggregate;
 
    -------------------------------
@@ -7957,7 +7957,7 @@ package body Exp_Aggr is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Expand_N_Extension_Aggregate;
 
    -----------------------------
index 0f09ba587accd8448a915adf18a98af83e701f9e..4f9f16cfa55b59683b01d82b9be26027fab2eb3f 100644 (file)
@@ -8776,7 +8776,7 @@ package body Exp_Attr is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Expand_N_Attribute_Reference;
 
    --------------------------------
index 7c18f81cb07ebd679feaa42c2f843cd0f2616a2e..2372a9f11df1db6ae4d2e43671b32f62a63895c8 100644 (file)
@@ -5956,7 +5956,7 @@ package body Exp_Ch3 is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Expand_Freeze_Enumeration_Type;
 
    -------------------------------
@@ -9239,7 +9239,7 @@ package body Exp_Ch3 is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Expand_N_Object_Declaration;
 
    ---------------------------------
@@ -9501,7 +9501,7 @@ package body Exp_Ch3 is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Expand_Tagged_Root;
 
    ------------------------------
index a845982d6908dafb758f78e62f3edf12400d9778..76386fc9f6a5a70c8d3a834709c85ad25cee7122 100644 (file)
@@ -432,7 +432,7 @@ package body Exp_Ch4 is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Build_Boolean_Array_Proc_Call;
 
    ---------------------------------
@@ -1236,7 +1236,7 @@ package body Exp_Ch4 is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Expand_Allocator_Expression;
 
    -----------------------------
@@ -5067,7 +5067,7 @@ package body Exp_Ch4 is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Expand_N_Allocator;
 
    -----------------------
@@ -7758,7 +7758,7 @@ package body Exp_Ch4 is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Expand_N_Null;
 
    ---------------------
@@ -9143,7 +9143,7 @@ package body Exp_Ch4 is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Expand_N_Op_Expon;
 
    --------------------
@@ -13573,7 +13573,7 @@ package body Exp_Ch4 is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Insert_Dereference_Action;
 
    --------------------------------
index f46fb4779a615c29a101100ba24cbfcdc275a9ab..66a4fc0512b0c4c58144a0c333b6e6eef8b28ccf 100644 (file)
@@ -1154,7 +1154,7 @@ package body Exp_Ch5 is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Expand_Assign_Array;
 
    ------------------------------
@@ -3455,7 +3455,7 @@ package body Exp_Ch5 is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Expand_N_Assignment_Statement;
 
    ------------------------------
index 621619220a0b514a66d1e14be9dce764fd6eb3d2..72d00bcb3189f693a00de616912e54bf358e0355 100644 (file)
@@ -5764,7 +5764,7 @@ package body Exp_Ch6 is
 
    exception
       when RE_Not_Available =>
-         return;
+         null;
    end Expand_N_Simple_Return_Statement;
 
    ------------------------------
index 4dc75693d8f84793ebd72255bedfc2d6dc64282f..58f668944a0ad878624f0d17f4c872b2a66cdd63 100644 (file)
@@ -2305,8 +2305,6 @@ package body Exp_Unst is
             end if;
          end Adjust_One_Call;
       end loop Adjust_Calls;
-
-      return;
    end Unnest_Subprogram;
 
    ------------------------
index 35df625f3bf94e26d8dc3316a0ea07c50e2b8fb2..409431d5a69536e1435b044fb6dca202c41f436a 100644 (file)
@@ -271,6 +271,4 @@ begin
          Buffer (Len) := Buffer (J);
       end if;
    end loop;
-
-   return;
 end Krunch;
index 08bbcc0d9a42f1a3ef0ae1931d94ee37182b5c26..099ea49656d926c7af0319d56c9f2d3a76fab0a1 100644 (file)
@@ -227,9 +227,7 @@ package body Layout is
    procedure Layout_Object (E : Entity_Id) is
       pragma Unreferenced (E);
    begin
-      --  Nothing to do for now, assume backend does the layout
-
-      return;
+      null; -- Nothing to do for now, assume backend does the layout
    end Layout_Object;
 
    -----------------
index 5cbd6c09d830dd42ed478432e51253f1ecccabe5..4ad847817bf686214299391f6edf2be48aad21fd 100644 (file)
@@ -69,7 +69,7 @@ package body System.Exceptions_Debug is
    procedure Local_Raise (Excep : System.Address) is
       pragma Warnings (Off, Excep);
    begin
-      return;
+      null;
    end Local_Raise;
 
 end System.Exceptions_Debug;
index 1b4b807f5669d5c141854fad201089f183bc2038..479b5d34d118cfd845e052b787e76ca4ba94239a 100644 (file)
@@ -479,7 +479,7 @@ package body System.Traceback.Symbolic is
 
    exception
       when others =>
-         return;
+         null;
    end Module_Symbolic_Traceback;
 
    -------------------------------------
index b045d74bd0eef5d1a123c003cc005eb0f384cf1e..816670568a670a46ac15ddc3353e1e913a602293 100644 (file)
@@ -658,8 +658,6 @@ package body Endh is
             Scan; -- past junk token on same line
          end loop;
       end if;
-
-      return;
    end End_Skip;
 
    --------------------
index 803d3a22f2df449937c82c0e69a91101f7364606..e59d6b496a7fc412596316e1e98974ea3afe07a4 100644 (file)
@@ -513,7 +513,6 @@ package body Tchk is
 
       Error_Msg_AP -- CODEFIX
         ("|missing "";""");
-      return;
    end T_Semicolon;
 
    ------------
index dcff62e63bc8f23de73511782b9d733a73429709..e168d62eafbb49610f57ccd6e72afdf3f21936af 100644 (file)
@@ -1401,7 +1401,6 @@ package body Sem is
            Prev     => Global_Suppress_Stack_Top,
            Next     => Suppress_Stack_Entries);
       Suppress_Stack_Entries := Global_Suppress_Stack_Top;
-      return;
    end Push_Global_Suppress_Stack_Entry;
 
    -------------------------------------
@@ -1422,8 +1421,6 @@ package body Sem is
            Prev     => Local_Suppress_Stack_Top,
            Next     => Suppress_Stack_Entries);
       Suppress_Stack_Entries := Local_Suppress_Stack_Top;
-
-      return;
    end Push_Local_Suppress_Stack_Entry;
 
    ---------------
index 40963b0b8bc5e068e82ad4bfeac41e5fb280a5f6..960294447172b0ab3a6af8c411e0c2e1c7605e6e 100644 (file)
@@ -7767,7 +7767,6 @@ package body Sem_Attr is
       when Bad_Attribute =>
          Set_Analyzed (N);
          Set_Etype (N, Any_Type);
-         return;
    end Analyze_Attribute;
 
    --------------------
index 7bce7fb19a7b001fd05d86cba1f49f22eaee118d..48dcf8e4f1b178cb67f7f5c5d602c01ca2538aa4 100644 (file)
@@ -7831,7 +7831,6 @@ package body Sem_Ch6 is
          end if;
 
          Overridden_Subp := Candidate;
-         return;
       end;
    end Check_Synchronized_Overriding;
 
index 6bd3b77e2d494e6e5b96770ecfde1dc1c289edcf..7d9dca824c02d4f71e97498de724ae7e90041143 100644 (file)
@@ -713,8 +713,6 @@ package body Sem_Elim is
       <<Continue>>
          Elmt := Elmt.Homonym;
       end loop;
-
-      return;
    end Check_Eliminated;
 
    -------------------------------------
index 2d64d845ae24366c75e22fd8ef38826d5acf33b1..f970932df8f96e86021b76ef0597fd26a2434b6f 100644 (file)
@@ -3997,7 +3997,6 @@ package body Sem_Eval is
       --  Otherwise the result depends on the right operand
 
       Fold_Uint (N, Expr_Value (Right), Rstat);
-      return;
    end Eval_Short_Circuit;
 
    ----------------
index d96a5e9f914f1fba018a7617c8c1eed38b815e81..a0f26aa5fe3db46143ec57502f16abddb0c04eea 100644 (file)
@@ -261,8 +261,6 @@ package body SFN_Scan is
       if At_EOF then
          Error ("unexpected end of file");
       end if;
-
-      return;
    end Check_Not_At_EOF;
 
    -----------------