[Ada] Enable checks on runtime by default
authorArnaud Charlet <charlet@adacore.com>
Mon, 2 Nov 2020 17:27:55 +0000 (12:27 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 30 Nov 2020 14:16:21 +0000 (09:16 -0500)
gcc/ada/

* gcc-interface/Makefile.in (GNATLIBFLAGS): Enable checks by
default.
* libgnat/s-bitfie.ads: Suppress alignment checks.
* libgnat/s-bituti.adb: Minor reformatting.
* libgnat/s-secsta.adb (SS_Allocate): Support Size = 0.

gcc/ada/gcc-interface/Makefile.in
gcc/ada/libgnat/s-bitfie.ads
gcc/ada/libgnat/s-bituti.adb
gcc/ada/libgnat/s-secsta.adb

index bdf6ae2..a6325aa 100644 (file)
@@ -110,7 +110,7 @@ NO_INLINE_ADAFLAGS = -fno-inline
 NO_OMIT_ADAFLAGS = -fno-omit-frame-pointer
 NO_SIBLING_ADAFLAGS = -fno-optimize-sibling-calls
 NO_REORDER_ADAFLAGS = -fno-toplevel-reorder
-GNATLIBFLAGS = -W -Wall -gnatpg -nostdinc
+GNATLIBFLAGS = -W -Wall -gnatg -nostdinc
 GNATLIBCFLAGS = -g -O2
 # Pretend that _Unwind_GetIPInfo is available for the target by default.  This
 # should be autodetected during the configuration of libada and passed down to
index 4f17a9c..21b7294 100644 (file)
@@ -47,6 +47,12 @@ package System.Bitfields is
    pragma Provide_Shift_Operators (Val_2);
    type Val is mod 2**Val_Bits with Alignment => Val_Bytes;
 
+   --  ??? It turns out that enabling checks on the instantiation of
+   --  System.Bitfield_Utils.G makes a latent visibility bug appear on strict
+   --  alignment platforms related to alignment checks. Work around it by
+   --  suppressing these checks explicitly.
+
+   pragma Suppress (Alignment_Check);
    package Utils is new System.Bitfield_Utils.G (Val, Val_2);
 
    procedure Copy_Bitfield
index e3bd70a..ef839a8 100644 (file)
@@ -317,6 +317,7 @@ package body System.Bitfield_Utils is
                  Get_Val_2 (S_Addr, S_Off, Initial_Size);
                Initial_Val : constant Val :=
                  Get_Bitfield (Initial_Val_2, S_Off, Initial_Size);
+
             begin
                Set_Bitfield
                  (Initial_Val, D_Addr, D_Off, Initial_Size);
index 7ec8462..f2d264d 100644 (file)
@@ -587,15 +587,18 @@ package body System.Secondary_Stack is
    --  Start of processing for SS_Allocate
 
    begin
-      --  It should not be possible to request an allocation of negative or
-      --  zero size.
-
-      pragma Assert (Storage_Size > 0);
-
       --  Round the requested size up to the nearest multiple of the maximum
       --  alignment to ensure efficient access.
 
-      Mem_Size := Round_Up (Storage_Size);
+      if Storage_Size = 0 then
+         Mem_Size := Memory_Alignment;
+      else
+         --  It should not be possible to request an allocation of negative
+         --  size.
+
+         pragma Assert (Storage_Size >= 0);
+         Mem_Size := Round_Up (Storage_Size);
+      end if;
 
       if Sec_Stack_Dynamic then
          Allocate_Dynamic (Stack, Mem_Size, Addr);