From cefce34c6701df7ddd07ece4874465f9049b812c Mon Sep 17 00:00:00 2001 From: Javier Miranda Date: Tue, 10 Aug 2010 14:29:36 +0000 Subject: sem_aggr.adb (Resolve_Extension_Aggregate): Warn on the use of C++ constructors that leave the object partially initialized. 2010-08-10 Javier Miranda * sem_aggr.adb (Resolve_Extension_Aggregate): Warn on the use of C++ constructors that leave the object partially initialized. * exp_atag.ads, exp_atags.adb (Build_Inherit_CPP_Prims): New subprogram that copies from parent of Typ the dispatch table slots of inherited C++ primitives. It handles primary and secondary dispatch tables. * einfo.adb (Related_Type): Moved from Node26 to Node27. Required to use this attribute with E_Variable entities. (Set_Is_Tag): Relax assertion to allow its use with variables that store tags. (Set_Related_Type): Relax assertion to allow its use with variables that store the tag of a C++ class. (Write_26_Field_Name): Remove Related_Type. (Write_27_Field_Name): Add Related_Type. * einfo.ads (Related_Type): Moved from Node26 to Node27. Available also with E_Variable entities. * sem_prag.adb (CPP_Constructor): Warn on duplicated occurrence of this pragma. * sem_util.adb (Search_Tag): Add missing support for CPP types. (Enclosing_CPP_Parent): New subprogram. (Has_Suffix): New subprogram. * sem_util.ads (Enclosing_CPP_Parent): New subprogram that returns the closest ancestor of a type that is a C++ type. (Has_Suffix): New subprogram. Used in assertions to check the suffix of internal entities. * sem_attr.adb (Analyze_Access_Attribute): Check wrong use of current instance in derivations of C++ types. * exp_tss.adb (CPP_Init_Proc): New subprogram. (Is_CPP_Init_Proc): New subprogram. (Set_TSS): Handle new C++ init routines. * exp_tss.ads (TSS_CPP_Init): New TSS name. For initialization of C++ dispatch tables. (CPP_Init_Proc): New subprogram. (Is_CPP_Init_Proc): New subprogram. * exp_disp.adb (CPP_Num_Prims): New subprogram. (Has_CPP_Constructors): New subprogram. (Make_Secondary_DT, Make_DT): For derivations of CPP types, do not initialize slots located in the C++ part of the dispatch table. (Make_Tags): For CPP types declare variables used by the IP routine to store the C++ tag values after the first invocation of the C++ constructor. (Build_CPP_Init_DT): New subprogram. (Set_CPP_Constructors): New implementation that builds an IP for each CPP constructor. These IP are wrappers of the C++ constructors that, after the first invocation of the constructor, read the C++ tags from the object and save them locally. These copies of the C++ tags are used by the IC routines to initialize tables of Ada derivations of CPP types. (Write_DT): Indicate what primitives are imported from C++ * exp_disp.ads (CPP_Num_Prims): New subprogram. (Has_CPP_Constructors): New subprogram. * exp_aggr.adb (Build_Record_Aggr_Code): For derivations of C++ types invoke the IC routine to inherit the slots of the parents. * sem_ch13.adb (Analyze_Freeze_Entity): Add new warnings on CPP types. * exp_ch3.adb (Is_Variable_Size_Array): New subprogram. (Is_Variable_Size_Record): Factorize code calling Is_Variable_Size_Array. (Build_CPP_Init_Procedure): New subprogram that builds the tree corresponding to the procedure that initializes the C++ part of the dispatch table of an Ada tagged type that is a derivation of a CPP type. (Build_Init_Procedure): Adding documentation plus code reorganization to leave more clear the construction of the IP with C++ types. (Expand_Freeze_Record_Type): Delay call to Set_CPP_Constructors because it cannot be called after Make_Tags has been invoked. (Inherit_CPP_Tag): Removed. (Init_Secondary_Tags): For derivations of CPP types, warn on tags located at variable offset. * freeze.ads: Minor reformating. * sem_ch8.adb (Write_Scopes): Add pragma export. Required to have it available in gdb. * gcc-interface/Make-lang.in: Update dependencies. From-SVN: r163065 --- gcc/ada/exp_tss.ads | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'gcc/ada/exp_tss.ads') diff --git a/gcc/ada/exp_tss.ads b/gcc/ada/exp_tss.ads index 07415fc..d6a18fb 100644 --- a/gcc/ada/exp_tss.ads +++ b/gcc/ada/exp_tss.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -84,6 +84,7 @@ package Exp_Tss is TSS_Composite_Equality : constant TNT := "EQ"; -- Composite Equality TSS_From_Any : constant TNT := "FA"; -- PolyORB/DSA From_Any TSS_Init_Proc : constant TNT := "IP"; -- Initialization Procedure + TSS_CPP_Init_Proc : constant TNT := "IC"; -- Init C++ dispatch tables TSS_RAS_Access : constant TNT := "RA"; -- RAS type access TSS_RAS_Dereference : constant TNT := "RD"; -- RAS type dereference TSS_Rep_To_Pos : constant TNT := "RP"; -- Rep to Pos conversion @@ -104,6 +105,7 @@ package Exp_Tss is TSS_Composite_Equality, TSS_From_Any, TSS_Init_Proc, + TSS_CPP_Init_Proc, TSS_RAS_Access, TSS_RAS_Dereference, TSS_Rep_To_Pos, @@ -140,15 +142,18 @@ package Exp_Tss is function Make_Init_Proc_Name (Typ : Entity_Id) return Name_Id; -- Version for init procs, same as Make_TSS_Name (Typ, TSS_Init_Proc) + function Is_CPP_Init_Proc (E : Entity_Id) return Boolean; + -- Version for CPP init procs, same as Is_TSS (E, TSS_CPP_Init_Proc); + + function Is_Init_Proc (E : Entity_Id) return Boolean; + -- Version for init procs, same as Is_TSS (E, TSS_Init_Proc); + function Is_TSS (E : Entity_Id; Nam : TSS_Name_Type) return Boolean; -- Determines if given entity (E) is the name of a TSS identified by Nam function Is_TSS (N : Name_Id; Nam : TSS_Name_Type) return Boolean; -- Same test applied directly to a Name_Id value - function Is_Init_Proc (E : Entity_Id) return Boolean; - -- Version for init procs, same as Is_TSS (E, TSS_Init_Proc); - ----------------------------------------- -- TSS Data structures and Subprograms -- ----------------------------------------- @@ -188,6 +193,11 @@ package Exp_Tss is -- used to initially install a TSS in the case where the subprogram for the -- TSS has already been created and its declaration processed. + function CPP_Init_Proc (Typ : Entity_Id) return Entity_Id; + -- Obtains the CPP_Init TSS entity the given type. The CPP_Init TSS is a + -- procedure used to initialize the C++ part of the primary and secondary + -- dispatch tables of a tagged type derived from CPP types. + function Init_Proc (Typ : Entity_Id; Ref : Entity_Id := Empty) return Entity_Id; -- cgit v1.1