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 spurious 'invalid initial value' with non-std enum index


Hello,

Compilation of the Ada testcase below should be silent and yields an
unexpected sequence of 

  "error: invalid initial value for member 'data'"

instead.

    package Nested_Float_Packed is

       type Float_Type is record
	  Value : Float;
	  Valid : Boolean;
       end record;

       type Data_Type is record
	  Data : Float_Type;
       end record;

       Default_Data : constant Data_Type :=
	 (Data => (Value => 1.0, Valid => False));

       type Range_Type is (RV1, RV2, RV3);
       for Range_Type use (1, 2, 3);

       Data_Block : array (Range_Type)
	 of Data_Type := (others => Default_Data);
    end;

The rep clause on the enumeral type causes packing of the dependant
array type. The bug is that the associated aggregate ((others => ...)
constructor) is deemed CONSTANT/STATIC despite a nested float
bitfield that output_constructor doesn't handle.

The bits are initially set on an unpacked version of the constructor
and should be cleared across conversions to the packed type. The latter
doesn't happen as of today and this patch fixes that.

Tested on x86_64-suse-linux. Committing to mainline.

Olivier

2009-06-01  Olivier Hainque  <hainque@adacore.com>
            Eric Botcazou  <botcazou@adacore.com>

	ada/
        * gcc-interface/utils.c (convert) <CONSTRUCTOR case>: When converting
        to the packable version of the type, clear TREE_STATIC/TREE_CONSTANT
        on the result if at least one of the input fields couldn't be output
        as a static constant any more.

	testsuite/
	* gnat.dg/nested_float_packed.ads: New test.

Attachment: nested_float_packed.dif
Description: Text document


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