diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-07-18 12:01:26 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-07-18 12:01:26 +0200 |
commit | daff5ab71e8de29f3b3bd91a9151401f6a8ea197 (patch) | |
tree | 2a171b963b83e699b1397ae128743d670dbf52ba /gcc | |
parent | c45e5332cc03dc81591dfc409fdc224e4e1643c0 (diff) | |
download | gcc-daff5ab71e8de29f3b3bd91a9151401f6a8ea197.zip gcc-daff5ab71e8de29f3b3bd91a9151401f6a8ea197.tar.gz gcc-daff5ab71e8de29f3b3bd91a9151401f6a8ea197.tar.bz2 |
[multiple changes]
2014-07-18 Robert Dewar <dewar@adacore.com>
* repinfo.ads: Add documentation on handling of back annotation
for dynamic case.
2014-07-18 Ed Schonberg <schonberg@adacore.com>
* sinfo.ads, sinfo.adb (Incomplete_View): New semantic attribute
of full type declaration, denotes previous declaration for
incomplete view of the type.
* sem_ch3.adb (Analyze_Full_Type_Declaration): Set Incomplete_View
of declaration if one is present.
(Replace_Type): When constructing the signature of an inherited
operation, handle properly the case where the operation has a
formal whose type is an incomplete view.
* sem_util.adb (Collect_Primitive_Operations): Handle properly
the case of an operation declared after an incomplete declaration
for a type T and before the full declaration of T.
2014-07-18 Pascal Obry <obry@adacore.com>
* i-cstrea.ads: Add documentation for set_wide_text_mode.
From-SVN: r212802
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 23 | ||||
-rw-r--r-- | gcc/ada/i-cstrea.ads | 8 | ||||
-rw-r--r-- | gcc/ada/sem_ch3.adb | 27 | ||||
-rw-r--r-- | gcc/ada/sem_util.adb | 19 | ||||
-rw-r--r-- | gcc/ada/sinfo.adb | 16 | ||||
-rw-r--r-- | gcc/ada/sinfo.ads | 18 |
6 files changed, 98 insertions, 13 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index fc5a3be..f136cc7 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,28 @@ 2014-07-18 Robert Dewar <dewar@adacore.com> + * repinfo.ads: Add documentation on handling of back annotation + for dynamic case. + +2014-07-18 Ed Schonberg <schonberg@adacore.com> + + * sinfo.ads, sinfo.adb (Incomplete_View): New semantic attribute + of full type declaration, denotes previous declaration for + incomplete view of the type. + * sem_ch3.adb (Analyze_Full_Type_Declaration): Set Incomplete_View + of declaration if one is present. + (Replace_Type): When constructing the signature of an inherited + operation, handle properly the case where the operation has a + formal whose type is an incomplete view. + * sem_util.adb (Collect_Primitive_Operations): Handle properly + the case of an operation declared after an incomplete declaration + for a type T and before the full declaration of T. + +2014-07-18 Pascal Obry <obry@adacore.com> + + * i-cstrea.ads: Add documentation for set_wide_text_mode. + +2014-07-18 Robert Dewar <dewar@adacore.com> + * a-witeio.adb: Minor code reorganization. * i-cstrea.ads: Add comment. diff --git a/gcc/ada/i-cstrea.ads b/gcc/ada/i-cstrea.ads index 020701e..67ca62f 100644 --- a/gcc/ada/i-cstrea.ads +++ b/gcc/ada/i-cstrea.ads @@ -221,8 +221,6 @@ package Interfaces.C_Streams is -- Control of Text/Binary Mode -- --------------------------------- - -- Is the above section title good enough, given the new addition??? - -- If text_translation_required is true, then the following functions may -- be used to dynamically switch a file from binary to text mode or vice -- versa. These functions have no effect if text_translation_required is @@ -231,7 +229,11 @@ package Interfaces.C_Streams is procedure set_binary_mode (handle : int); procedure set_text_mode (handle : int); - -- The following needs documentation ??? + -- set_wide_text_mode is as set_text_mode but switches the translation to + -- 16-bits wide-character instead of 8-bits character. Again this routine + -- has not effect if text_translation_required is false. On Windows this + -- is used to have proper 16-bits wide string output on the console for + -- example. procedure set_wide_text_mode (handle : int); diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index e3bf564..b18d668 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -2464,6 +2464,8 @@ package body Sem_Ch3 is Prev := Find_Type_Name (N); -- The full view, if present, now points to the current type + -- If there is an incomplete partial view, set a link to it, to + -- simplify the retrieval of primitive operations of the type. -- Ada 2005 (AI-50217): If the type was previously decorated when -- imported through a LIMITED WITH clause, it appears as incomplete @@ -2472,6 +2474,7 @@ package body Sem_Ch3 is if Ekind (Prev) = E_Incomplete_Type and then Present (Full_View (Prev)) then T := Full_View (Prev); + Set_Incomplete_View (N, Parent (Prev)); else T := Prev; end if; @@ -13537,6 +13540,7 @@ package body Sem_Ch3 is ------------------ procedure Replace_Type (Id, New_Id : Entity_Id) is + Id_Type : constant Entity_Id := Etype (Id); Acc_Type : Entity_Id; Par : constant Node_Id := Parent (Derived_Type); @@ -13547,9 +13551,9 @@ package body Sem_Ch3 is -- be out of the proper scope for Gigi, so we insert a reference to -- it after the derivation. - if Ekind (Etype (Id)) = E_Anonymous_Access_Type then + if Ekind (Id_Type) = E_Anonymous_Access_Type then declare - Desig_Typ : Entity_Id := Designated_Type (Etype (Id)); + Desig_Typ : Entity_Id := Designated_Type (Id_Type); begin if Ekind (Desig_Typ) = E_Record_Type_With_Private @@ -13567,7 +13571,7 @@ package body Sem_Ch3 is or else (Is_Interface (Desig_Typ) and then not Is_Class_Wide_Type (Desig_Typ)) then - Acc_Type := New_Copy (Etype (Id)); + Acc_Type := New_Copy (Id_Type); Set_Etype (Acc_Type, Acc_Type); Set_Scope (Acc_Type, New_Subp); @@ -13599,16 +13603,23 @@ package body Sem_Ch3 is Build_Itype_Reference (Acc_Type, Parent (Derived_Type)); else - Set_Etype (New_Id, Etype (Id)); + Set_Etype (New_Id, Id_Type); end if; end; - elsif Base_Type (Etype (Id)) = Base_Type (Parent_Type) + -- In Ada2012, a formal may have an incomplete type but the type + -- derivation that inherits the primitive follows the full view. + + elsif Base_Type (Id_Type) = Base_Type (Parent_Type) or else - (Ekind (Etype (Id)) = E_Record_Type_With_Private - and then Present (Full_View (Etype (Id))) + (Ekind (Id_Type) = E_Record_Type_With_Private + and then Present (Full_View (Id_Type)) and then - Base_Type (Full_View (Etype (Id))) = Base_Type (Parent_Type)) + Base_Type (Full_View (Id_Type)) = Base_Type (Parent_Type)) + or else + (Ada_Version >= Ada_2012 + and then Ekind (Id_Type) = E_Incomplete_Type + and then Full_View (Id_Type) = Parent_Type) then -- Constraint checks on formals are generated during expansion, -- based on the signature of the original subprogram. The bounds diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 06f2815..d6b46c3 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -3400,7 +3400,14 @@ package body Sem_Util is Etyp := Designated_Type (Etyp); end if; - return Base_Type (Etyp) = B_Type; + -- In Ada 2012 a primitive operation may have a formal of an + -- incomplete view of the parent type. + + return Base_Type (Etyp) = B_Type + or else + (Ada_Version >= Ada_2012 + and then Ekind (Etyp) = E_Incomplete_Type + and then Full_View (Etyp) = B_Type); end Match; -- Start of processing for Collect_Primitive_Operations @@ -3454,6 +3461,16 @@ package body Sem_Util is and then In_Private_Part (B_Scope) then Id := Next_Entity (T); + + -- In Ada 2012, If the type has an incomplete partial view, there + -- may be primitive operations declared before the full view, so + -- we need to start scanning from the incomplete view. + + elsif Nkind (Parent (B_Type)) = N_Full_Type_Declaration + and then Present (Incomplete_View (Parent (B_Type))) + then + Id := Defining_Entity (Next (Incomplete_View (Parent (B_Type)))); + else Id := Next_Entity (B_Type); end if; diff --git a/gcc/ada/sinfo.adb b/gcc/ada/sinfo.adb index d2a19e2..ec7a23f 100644 --- a/gcc/ada/sinfo.adb +++ b/gcc/ada/sinfo.adb @@ -1713,6 +1713,14 @@ package body Sinfo is return Flag11 (N); end Includes_Infinities; + function Incomplete_View + (N : Node_Id) return Node_Id is + begin + pragma Assert (False + or else NT (N).Nkind = N_Full_Type_Declaration); + return Node2 (N); + end Incomplete_View; + function Inherited_Discriminant (N : Node_Id) return Boolean is begin @@ -4879,6 +4887,14 @@ package body Sinfo is Set_Flag11 (N, Val); end Set_Includes_Infinities; + procedure Set_Incomplete_View + (N : Node_Id; Val : Node_Id) is + begin + pragma Assert (False + or else NT (N).Nkind = N_Full_Type_Declaration); + Set_Node2 (N, Val); -- semantic field, no Parent set + end Set_Incomplete_View; + procedure Set_Inherited_Discriminant (N : Node_Id; Val : Boolean := True) is begin diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index 31ebb59..d06bb4b 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -1450,6 +1450,13 @@ package Sinfo is -- range is given by the programmer, even if that range is identical to -- the range for Float. + -- Incomplete_View (Node2-Sem) + -- Present in full type declarations that are completions of incomplete + -- type declarations. Denotes the corresponding incomplete type + -- declaration. Used to simplify the retrieval of primitive operations + -- that may be declared between the partial and the full view of an + -- untagged type. + -- Inherited_Discriminant (Flag13-Sem) -- This flag is present in N_Component_Association nodes. It indicates -- that a given component association in an extension aggregate is the @@ -2488,6 +2495,7 @@ package Sinfo is -- N_Full_Type_Declaration -- Sloc points to TYPE -- Defining_Identifier (Node1) + -- Incomplete_View (Node2-Sem) -- Discriminant_Specifications (List4) (set to No_List if none) -- Type_Definition (Node3) -- Discr_Check_Funcs_Built (Flag11-Sem) @@ -9120,6 +9128,9 @@ package Sinfo is function Includes_Infinities (N : Node_Id) return Boolean; -- Flag11 + function Incomplete_View + (N : Node_Id) return Node_Id; -- Node2 + function Inherited_Discriminant (N : Node_Id) return Boolean; -- Flag13 @@ -10128,6 +10139,9 @@ package Sinfo is procedure Set_Includes_Infinities (N : Node_Id; Val : Boolean := True); -- Flag11 + procedure Set_Incomplete_View + (N : Node_Id; Val : Node_Id); -- Node2 + procedure Set_Inherited_Discriminant (N : Node_Id; Val : Boolean := True); -- Flag13 @@ -10801,7 +10815,7 @@ package Sinfo is N_Full_Type_Declaration => (1 => True, -- Defining_Identifier (Node1) - 2 => False, -- unused + 2 => False, -- Incomplete_View (Node2-Sem) 3 => True, -- Type_Definition (Node3) 4 => True, -- Discriminant_Specifications (List4) 5 => False), -- unused @@ -12543,6 +12557,7 @@ package Sinfo is pragma Inline (Includes_Infinities); pragma Inline (Import_Interface_Present); pragma Inline (In_Present); + pragma Inline (Incomplete_View); pragma Inline (Inherited_Discriminant); pragma Inline (Instance_Spec); pragma Inline (Intval); @@ -12873,6 +12888,7 @@ package Sinfo is pragma Inline (Set_Import_Interface_Present); pragma Inline (Set_In_Present); pragma Inline (Set_Includes_Infinities); + pragma Inline (Set_Incomplete_View); pragma Inline (Set_Inherited_Discriminant); pragma Inline (Set_Instance_Spec); pragma Inline (Set_Interface_List); |