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] Repair No_Strict_Aliasing configuration pragma


This reimplements the No_Strict_Aliasing configuration pragma, which didn't
work neither for private types nor for access-to-unconstrained-array types.

The following program must compile quietly with -O2:

pragma No_Strict_Aliasing;
with Q; use Q;

package P is

   type Ptr is private;

   type Arr is array (Natural range <>) of Integer;

   type Array_Ptr is access all Arr;

   procedure Dummy;

private

   type Rec is record
      Data : Integer;
   end record;

   type Ptr is access Rec;

end P;
with Ada.Unchecked_Conversion;

package body P is

   function Any_Ptr_To_Map_Ptr is
      new Ada.Unchecked_Conversion (Q.T_ANY_PTR, Ptr);

   function Any_Array_Ptr_To_Map_Ptr is
      new Ada.Unchecked_Conversion (Q.T_ANY_ARRAY_PTR, Array_Ptr);

   procedure Dummy is begin null; end;

end P;
package Q is

   type T_BYTE is new INTEGER range 0 .. 255;
   for T_BYTE'size use 8;

   type T_ANY_PTR is access T_BYTE;

   type T_BYTE_ARRAY is array (Natural range <>) of T_BYTE;

   type T_ANY_ARRAY_PTR is access T_BYTE_ARRAY;

end Q;

Tested on x86_64-pc-linux-gnu, committed on trunk

2015-01-07  Eric Botcazou  <ebotcazou@adacore.com>

	* sem_ch3.adb (Analyze_Full_Type_Declaration): Do not
	automatically set No_Strict_Aliasing on access types.
	* fe.h (No_Strict_Aliasing_CP): Declare.
	* gcc-interface/trans.c (gigi): Force flag_strict_aliasing to 0 if
	No_Strict_Aliasing_CP is set.

Attachment: difs
Description: Text document


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