This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Ada: fix handling of atomic components


Tested on x86-linux

The problem that is being addressed with this patch is that if you have an
array whose component type is atomic, then you can't use a bit block compare
or a bit block move for assignment, since you need to ensure that the
accesses to the atomic item are done properly element by element. The
code in Expand_N_Op_Eq, and analogous code in Exp_Ch5.Expand_Assign_Array
were failing to do this check. The resulting bit block compares and bit
block moves could end up violating the atomic requirement, either by
reading to little (e.g. compare by bytes, when multi-byte atomic objects
are present, or move by 32-bit wordsl when 1- or 2-byte atomic objects
are present). The fixes simply involve a test for the atomic case (we already
have machinery to expand loops, used for other cases where loops are required).

Test case:
procedure t1 is
   type r is mod 2 ** 16;
   pragma Atomic (r);
   type a is array (1 .. 10) of r;
   a1, a2 : a;
begin
   a1 := a2;
   if a1 = a2 then
      null;
   end if;
end;

$ gcc -c t1.adb -gnatws -gnatG | grep for

No output expected

2004-10-26  Robert Dewar  <dewar@gnat.com>

	* exp_ch4.adb (Expand_N_Op_Eq): Make sure we expand a loop for array
	compares if the component is atomic.

	* exp_ch5.adb (Expand_Assign_Array): Make sure we expand a loop for
	array assignment if the component type is atomic.

Attachment: difs.13
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]