]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Add pragma Annotate for GNATcheck exemptions
authorSheri Bernstein <bernstein@adacore.com>
Tue, 25 Jul 2023 17:16:55 +0000 (17:16 +0000)
committerMarc Poulhiès <poulhies@adacore.com>
Thu, 3 Aug 2023 12:07:36 +0000 (14:07 +0200)
Exempt the GNATcheck rule "Improper_Returns" with the rationale
"early returns for performance".

gcc/ada/

* libgnat/s-aridou.adb: Add pragma to exempt Improper_Returns.
* libgnat/s-atopri.adb (Lock_Free_Try_Write): Likewise.
* libgnat/s-bitops.adb (Bit_Eq): Likewise.
* libgnat/s-carsi8.adb: Likewise.
* libgnat/s-carun8.adb: Likewise.
* libgnat/s-casi16.adb: Likewise.
* libgnat/s-casi32.adb: Likewise.
* libgnat/s-casi64.adb: Likewise.
* libgnat/s-caun16.adb: Likewise.
* libgnat/s-caun32.adb: Likewise.
* libgnat/s-caun64.adb: Likewise.
* libgnat/s-exponn.adb: Likewise.
* libgnat/s-expont.adb: Likewise.
* libgnat/s-valspe.adb: Likewise.
* libgnat/s-vauspe.adb: Likewise.

15 files changed:
gcc/ada/libgnat/s-aridou.adb
gcc/ada/libgnat/s-atopri.adb
gcc/ada/libgnat/s-bitops.adb
gcc/ada/libgnat/s-carsi8.adb
gcc/ada/libgnat/s-carun8.adb
gcc/ada/libgnat/s-casi16.adb
gcc/ada/libgnat/s-casi32.adb
gcc/ada/libgnat/s-casi64.adb
gcc/ada/libgnat/s-caun16.adb
gcc/ada/libgnat/s-caun32.adb
gcc/ada/libgnat/s-caun64.adb
gcc/ada/libgnat/s-exponn.adb
gcc/ada/libgnat/s-expont.adb
gcc/ada/libgnat/s-valspe.adb
gcc/ada/libgnat/s-vauspe.adb

index 2f1fbd554531656bbfb59fa589b9b8979126500f..beb56bfabe1d4ae9b58548e0c0ab2ad4ffa98325 100644 (file)
@@ -90,6 +90,9 @@ is
      (On, "non-preelaborable call not allowed in preelaborated unit");
    pragma Warnings (On, "non-static constant in preelaborated unit");
 
+   pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                    "early returns for performance");
+
    -----------------------
    -- Local Subprograms --
    -----------------------
@@ -3653,4 +3656,5 @@ is
       end if;
    end To_Pos_Int;
 
+   pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
 end System.Arith_Double;
index 9e23fa0ac91050401f276baa82a0e64b2231d682..5fc2a123a7127b6bf9fc148701fad4dcafa5c3e7 100644 (file)
@@ -59,6 +59,9 @@ package body System.Atomic_Primitives is
         new Atomic_Compare_Exchange (Atomic_Type);
 
    begin
+      pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                       "early returns for performance");
+
       if Expected /= Desired then
          if Atomic_Type'Atomic_Always_Lock_Free then
             return My_Atomic_Compare_Exchange (Ptr, Expected'Address, Desired);
@@ -68,6 +71,8 @@ package body System.Atomic_Primitives is
       end if;
 
       return True;
+
+      pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
    end Lock_Free_Try_Write;
 
 end System.Atomic_Primitives;
index 30699d73175a4c7a055cacba75b6aecfbe5cc182..acddd52892ceec2511b94472238f9d3b7644607c 100644 (file)
@@ -112,6 +112,9 @@ package body System.Bit_Ops is
       RightB : constant Bits := To_Bits (Right);
 
    begin
+      pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                       "early returns for performance");
+
       if Llen /= Rlen then
          return False;
 
@@ -134,6 +137,8 @@ package body System.Bit_Ops is
             end if;
          end;
       end if;
+
+      pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
    end Bit_Eq;
 
    -------------
index 807dceefc589e7acb5766c1abbc8ab164a04272a..839f157a2eeba05b3c872edb4e05303ba09d2b11 100644 (file)
@@ -58,6 +58,9 @@ package body System.Compare_Array_Signed_8 is
    function To_Big_Bytes is new
      Ada.Unchecked_Conversion (System.Address, Big_Bytes_Ptr);
 
+   pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                    "early returns for performance");
+
    ----------------------
    -- Compare_Array_S8 --
    ----------------------
@@ -147,4 +150,5 @@ package body System.Compare_Array_Signed_8 is
       end if;
    end Compare_Array_S8_Unaligned;
 
+   pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
 end System.Compare_Array_Signed_8;
index b0f2d94bf8acb16076e0a80decc04ded38840bd1..b20e4e1b92221994c9adc0bf2bdbd6059513ae60 100644 (file)
@@ -57,6 +57,9 @@ package body System.Compare_Array_Unsigned_8 is
    function To_Big_Bytes is new
      Ada.Unchecked_Conversion (System.Address, Big_Bytes_Ptr);
 
+   pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                    "early returns for performance");
+
    ----------------------
    -- Compare_Array_U8 --
    ----------------------
@@ -146,4 +149,5 @@ package body System.Compare_Array_Unsigned_8 is
       end if;
    end Compare_Array_U8_Unaligned;
 
+   pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
 end System.Compare_Array_Unsigned_8;
index 6d35d33b9d7f79f01beaa42c53e43e92b9950427..fa529c9d559c67dbf8f752ae5b498fdefbac4542 100644 (file)
@@ -58,6 +58,9 @@ package body System.Compare_Array_Signed_16 is
    -- Compare_Array_S16 --
    -----------------------
 
+   pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                    "early returns for performance");
+
    function Compare_Array_S16
      (Left      : System.Address;
       Right     : System.Address;
@@ -130,4 +133,5 @@ package body System.Compare_Array_Signed_16 is
       end if;
    end Compare_Array_S16;
 
+   pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
 end System.Compare_Array_Signed_16;
index 52acd30794a4329643ef4517d72dd64c2b891127..7ed9ec5c5199c0a3bf6667e05f7aa4dcf66adf41 100644 (file)
@@ -53,6 +53,9 @@ package body System.Compare_Array_Signed_32 is
    -- Compare_Array_S32 --
    -----------------------
 
+   pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                    "early returns for performance");
+
    function Compare_Array_S32
      (Left      : System.Address;
       Right     : System.Address;
@@ -113,4 +116,5 @@ package body System.Compare_Array_Signed_32 is
       end if;
    end Compare_Array_S32;
 
+   pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
 end System.Compare_Array_Signed_32;
index 50b6f6d1cf94ab3e514f0c6805957914b330cee3..f0211107baf97c447786d7a5a77de85e0c8619d2 100644 (file)
@@ -53,6 +53,9 @@ package body System.Compare_Array_Signed_64 is
    -- Compare_Array_S64 --
    -----------------------
 
+   pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                    "early returns for performance");
+
    function Compare_Array_S64
      (Left      : System.Address;
       Right     : System.Address;
@@ -113,4 +116,5 @@ package body System.Compare_Array_Signed_64 is
       end if;
    end Compare_Array_S64;
 
+   pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
 end System.Compare_Array_Signed_64;
index 641cf292e716ce842ba7244caba8b5f3e79d156e..43bf35b907a79e5c189ed7b5e62b717e9ea26ec5 100644 (file)
@@ -58,6 +58,9 @@ package body System.Compare_Array_Unsigned_16 is
    -- Compare_Array_U16 --
    -----------------------
 
+   pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                    "early returns for performance");
+
    function Compare_Array_U16
      (Left      : System.Address;
       Right     : System.Address;
@@ -130,4 +133,5 @@ package body System.Compare_Array_Unsigned_16 is
       end if;
    end Compare_Array_U16;
 
+   pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
 end System.Compare_Array_Unsigned_16;
index 2c0b77212970963d0e01f0f83f44cf3de9402b16..0a5ca12144e9f95f501a144652c64986c2421e1e 100644 (file)
@@ -53,6 +53,9 @@ package body System.Compare_Array_Unsigned_32 is
    -- Compare_Array_U32 --
    -----------------------
 
+   pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                    "early returns for performance");
+
    function Compare_Array_U32
      (Left      : System.Address;
       Right     : System.Address;
@@ -113,4 +116,5 @@ package body System.Compare_Array_Unsigned_32 is
       end if;
    end Compare_Array_U32;
 
+   pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
 end System.Compare_Array_Unsigned_32;
index 8a9720ffcb65e125530e756f2bb4f18f95eee649..cca2069a62b3d83869d36972315da8fd7b2c1e74 100644 (file)
@@ -52,6 +52,9 @@ package body System.Compare_Array_Unsigned_64 is
    -- Compare_Array_U64 --
    -----------------------
 
+   pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                    "early returns for performance");
+
    function Compare_Array_U64
      (Left      : System.Address;
       Right     : System.Address;
@@ -112,4 +115,5 @@ package body System.Compare_Array_Unsigned_64 is
       end if;
    end Compare_Array_U64;
 
+   pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
 end System.Compare_Array_Unsigned_64;
index d7a5342b82aa0494c77b1a42d4e190c8ceb7e1ab..a6b87eadd156af71c24fdf72a26dcbd6652359f2 100644 (file)
@@ -108,6 +108,9 @@ is
       --  Ghost variable to hold Factor**Exp between Exp and Factor updates
 
    begin
+      pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                       "early returns for performance");
+
       --  We use the standard logarithmic approach, Exp gets shifted right
       --  testing successive low order bits and Factor is the value of the
       --  base raised to the next power of 2.
@@ -173,6 +176,8 @@ is
       pragma Assert (Big (Result) = Big (Left) ** Right);
 
       return Result;
+
+      pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
    end Expon;
 
    ----------------------
index f6b030de50c4005d4134495e8ef701c8760a67b2..e8260610d5849a30139fd8f4bb60f57fa4112de0 100644 (file)
@@ -108,6 +108,9 @@ is
       --  Ghost variable to hold Factor**Exp between Exp and Factor updates
 
    begin
+      pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                       "early returns for performance");
+
       --  We use the standard logarithmic approach, Exp gets shifted right
       --  testing successive low order bits and Factor is the value of the
       --  base raised to the next power of 2.
@@ -173,6 +176,8 @@ is
       pragma Assert (Big (Result) = Big (Left) ** Right);
 
       return Result;
+
+      pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
    end Expon;
 
    ----------------------
index 56e6ed77209c088d3307a3a4a84d7b4e0957c30a..e6d9df69bb75253f8eab364b4bfae1fbb15bc8b1 100644 (file)
@@ -67,6 +67,9 @@ is
 
    function Last_Number_Ghost (Str : String) return Positive is
    begin
+      pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                       "occurs in ghost code, not executable");
+
       for J in Str'Range loop
          if Str (J) not in '0' .. '9' | '_' then
             return J - 1;
@@ -77,6 +80,8 @@ is
       end loop;
 
       return Str'Last;
+
+      pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
    end Last_Number_Ghost;
 
 end System.Val_Spec;
index b2fe1870b862df13fa731d71b6eca14c726cd7a3..c58fb21899982e2706ecb44240ab26d1fafad4f5 100644 (file)
@@ -56,6 +56,9 @@ package body System.Value_U_Spec with SPARK_Mode is
 
    function Last_Hexa_Ghost (Str : String) return Positive is
    begin
+      pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns",
+                       "occurs in ghost code, not executable");
+
       for J in Str'Range loop
          if Str (J) not in '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' | '_' then
             return J - 1;
@@ -67,6 +70,8 @@ package body System.Value_U_Spec with SPARK_Mode is
       end loop;
 
       return Str'Last;
+
+      pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns");
    end Last_Hexa_Ghost;
 
    -----------------------------