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] |
Box-initialized components are replaced with calls to the corresponding initialization procedures during resolution of the aggregate. This requires that the type of the aggregate and that of all its components be frozen before resolution is completed. In addition, such an aggregate may be the designated object of an access-to-constant object, and it can legally appear as an in-out parameter in a call to the corresponding initialization procedure. The following commands gnatmake -q -gnat05 main main must yield: 3.14150000000000E+00 3.14150000000000E+00 --- with A; with Text_IO; use Text_IO; procedure Main is Instance_OK : A.T_Record_Access := new A.T_Record'(My_Record => <>); Instance_KO : A.T_Record_Access_Constant := new A.T_Record'(My_Record => <>); begin Put_Line (Long_Float'Image (Instance_KO.My_Record.A_Value)); Put_Line (Long_Float'Image (A.Local_Instance_OK.My_Record.A_Value)); end Main; --- package A is type T_Inner_Record is record A_Value : Long_Float := 3.1415; end record; type T_Record is record My_Record : T_Inner_Record; end record; type T_Record_Access_Constant is access constant T_Record; type T_Record_Access is access T_Record; Local_Instance_OK : T_Record_Access_Constant := new T_Record'(My_Record => <>); end A; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-04 Ed Schonberg <schonberg@adacore.com> * sem_aggr.adb (Resolve_Aggregate): If aggregate has box-initialized components, freeze type before resolution, to ensure that default initializations are present for all components. * sem_res.adb (Resolve_Actuals): the designated object of an accces-to-constant type is a legal actual in a call to an initialization procedure.
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] |