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] Preelaborable initialization for derived types


This change fixes a bug in the predicate testing whether a type has
preelaborable initialization, in the case of a derived record types that
changes the default value of a discriminant of its parent type.

The following compilation must be rejected:
$ gcc -c preelab_der_pvt.ads
preelab_der_pvt.ads:12:09: full view of "T2" does not have preelaborable initialization

package Preelab_Der_Pvt is
   type T1 is private;
   pragma Preelaborable_Initialization (T1);

   type T2 is private;
   pragma Preelaborable_Initialization (T2);

private
   type T1 (D : Integer := 0) is null record;

   function F return Integer;
   type T2 (D : Integer := F) is new T1 (D => D);
   --  Error: T2 does not have preelaborable initialization

end Preelab_Der_Pvt;

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

2010-10-26  Thomas Quinot  <quinot@adacore.com>

	* sem_util.adb (Has_Preelaborable_Initialization.Check_Components):
	For a discriminant, use Discriminant_Default_Value rather than
	Expression (Declaration_Node (D)).

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]