aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/einfo.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2015-05-12 14:47:19 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2015-05-12 14:47:19 +0200
commitcaf07df9db933fc7c97c41060dfa940fa78bb345 (patch)
tree58ad2c244f063e7749fa8e4f7f3f84954975f6ac /gcc/ada/einfo.adb
parentc944345b5d210e9f003bd1088f0087b9a22068c0 (diff)
downloadgcc-caf07df9db933fc7c97c41060dfa940fa78bb345.zip
gcc-caf07df9db933fc7c97c41060dfa940fa78bb345.tar.gz
gcc-caf07df9db933fc7c97c41060dfa940fa78bb345.tar.bz2
[multiple changes]
2015-05-12 Hristian Kirtchev <kirtchev@adacore.com> * einfo.adb Node32 is now used as Encapsulating_State. Node37 is now used as Associated_Entity. (Associated_Entity): New routine. (Encapsulating_State): Update the assertion guard to include constants. (Set_Associated_Entity): New routine. (Set_Encapsulating_State): Update the assertion guard to include constants. (Write_Field10_Name): Remove the output for Encapsulating_State. (Write_Field32_Name): Add output for Encapsulating_State. (Write_Field37_Name): Add output for Associated_Entity. * einfo.ads New attribute Associated_Entity along with placement in entities. Attribute Encapsulating_State now uses Node32. (Associated_Entity): New routine along with pragma Inline. (Set_Associated_Entity): New routine along with pragma Inline. * inline.ads Code reformatting. * sem_attr.adb (Analyze_Attribute): Correct the prefix of attribute 'Result when the context is a generic instantiation. (Analyze_Attribute_Old_Result): Pragmas Depends and Refined_Depends are a valid context for attribute 'Result. (Denote_Same_Function): Allow attribute 'Result to denote generic functions. * sem_ch3.adb Add with and use clauses for Sem_Ch12. (Analyze_Declarations): Capture global references within the contracts of packages, subprograms and their respective bodies. * sem_ch6.adb (Analyze_Aspects_On_Body_Or_Stub): Removed. (Analyze_Completion_Contract): Removed. (Analyze_Generic_Subprogram_Body): Enchange the aspects after creating the generic copy. Create a generic contract for the template. Analyze the aspects of the generic body. Analyze the contract of the generic body when it is a compilation unit and capture global references. (Analyze_Subprogram_Body_Contract): Code cleanup. (Analyze_Subprogram_Contract): Do not save global references here. (Save_Global_References_In_List): Removed. * sem_ch7.adb (Analyze_Package_Body_Contract): Code cleanup. (Analyze_Package_Body_Helper): Create a generic contract for the template. (Analyze_Package_Contract): Code cleanup. * sem_ch10.adb Add with and use clauses for Sem_Ch12. (Analyze_Compilation_Unit): Capture global references in a generic subprogram declaration that acts as a compilation unit. * sem_ch12.adb Add with and use clauses for Sem_Prag. Illustrate the implementation of generic contracts. Alphabetize various subprograms. (Analyze_Generic_Package_Declaration): Create a generic contract for the template. (Analyze_Generic_Subprogram_Declaration): Create a generic contract for the template. (Analyze_Subprogram_Instantiation): Instantiate the contract of the subprogram. (Copy_Generic_Node): Link defining entities of the generic template with the corresponding defining entities of the generic copy. Update the processing of pragmas. (Instantiate_Contract): Removed. (Instantiate_Subprogram_Contract): New routine. (Requires_Delayed_Save): New routine. (Save_Global_References): Rename formal parameter N to Templ. Various cleanups. (Save_Global_References_In_Aspects): Moved from the spec. (Save_Global_References_In_Contract): New routine. (Save_References_In_Aggregate): New routine. (Save_References_In_Char_Lit_Or_Op_Symbol): New routine. (Save_References_In_Descendants): New routine. (Save_References_In_Identifier): New routine. (Save_References_In_Operator): New routine. (Save_References_In_Pragma): New routine. * sem_ch12.ads (Save_Global_References): Rename formal parameter N to Templ. Update the comment on usage. (Save_Global_References_In_Aspects): Moved to the body. (Save_Global_References_In_Contract): New routine. * sem_ch13.adb (Analyze_Aspect_Specifications_On_Body_Or_Stub): New routine. * sem_ch13.ads (Analyze_Aspect_Specifications_On_Body_Or_Stub): New routine. * sem_prag.adb (Add_Item_To_Name_Buffer): Add support for generic parameters. (Analyze_Contract_Cases_In_Decl_Part): Code cleanup. (Analyze_Depends_Global): New routine. (Analyze_Depends_In_Decl_Part): Code cleanup. (Analyze_Global_In_Decl_Part): Code cleanup. (Analyze_Global_Item): Constants are now valid global items. Do not perform state-related checks in an instance. Change the way renamings are handled. (Analyze_Initial_Condition_In_Decl_Part): Code cleanup. (Analyze_Initializes_In_Decl_Part): Code cleanup. (Analyze_Input_Output): The analysis of attribute 'Result in the context of pragmas Depends or Refined_Depends now reuses the existing attribute analysis machinery. Constants and generic parameters are now valid dependency items. Do not perform state-related checks in an instance. Change the way renamings are handled. (Analyze_Pragma): Add a "characteristics" section for pragmas Abstract_State, Contract_Cases, Depends, Extensions_Visible, Global, Initial_Condition, Initializes, Post, Post_Class, Postcondition, Pre, Pre_Class, Precondition, Refined_Depends, Refined_Global, Refined_Post, Refined_State, Test_Case. (Analyze_Pre_Post_Condition): Do not create a generic template here. (Analyze_Pre_Post_Condition_In_Decl_Part): Code cleanup. (Analyze_Refined_Depends_Global_Post): New routine. (Analyze_Refined_Depends_In_Decl_Part): Code cleanup. (Analyze_Refined_Global_In_Decl_Part): Code cleanup. (Analyze_Refined_Pragma): Removed. (Analyze_Refined_State_In_Decl_Part): Code cleanup. (Analyze_Test_Case_In_Decl_Part): Code cleanup. (Check_Dependency_Clause): Do not perform this check in an instance. (Check_Function_Return): Add support for generic functions. (Check_In_Out_States): Do not perform this check in an instance. (Check_Input_States): Do not perform this check in an instance. (Check_Mode_Restriction_In_Function): Add support for generic functions. (Check_Output_States): Do not perform this check in an instance. (Check_Postcondition_Use_In_Inlined_Subprogram): Rename parameter Subp_Id to Spec_Id and update comment on usage. (Check_Proof_In_States): Do not perform this check in an instance. (Check_Refined_Global_Item): Add support for constants. (Check_Refined_Global_List): Do not perform this check in an instance. (Collect_Global_Items): Reimplemented. (Collect_Subprogram_Inputs_Outputs): Add support for generic parameters. (Create_Generic_Template): Removed. (Find_Related_Package_Or_Body): Moved to spec. (Find_Role): Add support for generic parameters and constants. (Get_Argument): Moved to spec. Rename parameter Spec_Id to Context_Id. (Match_Item): Add support for constants. (Preanalyze_Test_Case_Arg): Reimplemented. (Report_Extra_Clauses): Do not perform this check in an instance. (Report_Extra_Constituents): Do not perform this check in an instance. * sem_prag.ads (Collect_Subprogram_Inputs_Outputs): Update the comment on usage. (Find_Related_Package_Or_Body): Moved from body. (Get_Argument): Moved from body. * sem_util.adb Add with and use clauses for Sem_Ch12. (Corresponding_Spec_Of): Add support for packages and package bodies. (Create_Generic_Contract): New routine. (Is_Contract_Annotation): Reimplemented. (Is_Generic_Declaration_Or_Body): New routine. (Is_Package_Contract_Annotation): New routine. (Is_Subprogram_Contract_Annotation): New routine. * sem_util.ads (Corresponding_Spec_Of): Update the comment on usage. (Create_Generic_Contract): New routine. (Is_Generic_Declaration_Or_Body): New routine. (Is_Package_Contract_Annotation): New routine. (Is_Subprogram_Contract_Annotation): New routine. * sinfo.adb (Is_Generic_Contract_Pragma): New routine. (Set_Is_Generic_Contract_Pragma): New routine. * sinfo.ads Add new attribute Is_Generic_Contract_Pragma along with occurrences in nodes. (Is_Generic_Contract_Pragma): New routine along with pragma Inline. (Set_Is_Generic_Contract_Pragma): New routine along with pragma Inline. * treepr.adb (Print_Entity_Info): Output fields 36 to 41. 2015-05-12 Robert Dewar <dewar@adacore.com> * a-taster.ads: Minor comment fix: fix bad header, this is a pure RM unit. From-SVN: r223064
Diffstat (limited to 'gcc/ada/einfo.adb')
-rw-r--r--gcc/ada/einfo.adb69
1 files changed, 40 insertions, 29 deletions
diff --git a/gcc/ada/einfo.adb b/gcc/ada/einfo.adb
index 772195b..f364960 100644
--- a/gcc/ada/einfo.adb
+++ b/gcc/ada/einfo.adb
@@ -70,6 +70,7 @@ package body Einfo is
-- Homonym Node4
-- First_Rep_Item Node6
-- Freeze_Node Node7
+ -- Associated_Entity Node37
-- The usage of other fields (and the entity kinds to which it applies)
-- depends on the particular field (see Einfo spec for details).
@@ -88,7 +89,6 @@ package body Einfo is
-- Part_Of_Constituents Elist9
-- Renaming_Map Uint9
- -- Encapsulating_State Node10
-- Direct_Primitive_Operations Elist10
-- Discriminal_Link Node10
-- Float_Rep Uint10 (but returns Float_Rep_Kind)
@@ -215,10 +215,10 @@ package body Einfo is
-- Related_Expression Node24
-- Subps_Index Uint24
- -- Interface_Alias Node25
- -- Interfaces Elist25
-- Debug_Renaming_Link Node25
-- DT_Offset_To_Top_Func Node25
+ -- Interface_Alias Node25
+ -- Interfaces Elist25
-- PPC_Wrapper Node25
-- Related_Array_Object Node25
-- Static_Discrete_Predicate List25
@@ -253,6 +253,7 @@ package body Einfo is
-- Thunk_Entity Node31
-- Activation_Record_Component Node31
+ -- Encapsulating_State Node32
-- SPARK_Pragma Node32
-- No_Tagged_Streams_Pragma Node32
@@ -264,7 +265,6 @@ package body Einfo is
-- Import_Pragma Node35
-- (unused) Node36
- -- (unused) Node37
-- (unused) Node38
-- (unused) Node39
-- (unused) Node40
@@ -753,6 +753,11 @@ package body Einfo is
return Uint14 (Id);
end Alignment;
+ function Associated_Entity (Id : E) return E is
+ begin
+ return Node37 (Id);
+ end Associated_Entity;
+
function Associated_Formal_Package (Id : E) return E is
begin
pragma Assert (Ekind (Id) = E_Package);
@@ -1111,8 +1116,8 @@ package body Einfo is
function Encapsulating_State (Id : E) return N is
begin
- pragma Assert (Ekind_In (Id, E_Abstract_State, E_Variable));
- return Node10 (Id);
+ pragma Assert (Ekind_In (Id, E_Abstract_State, E_Constant, E_Variable));
+ return Node32 (Id);
end Encapsulating_State;
function Enclosing_Scope (Id : E) return E is
@@ -1176,7 +1181,8 @@ package body Einfo is
E_Package,
E_Package_Body,
E_Subprogram_Body,
- E_Variable)
+ E_Variable,
+ E_Void)
or else Is_Subprogram_Or_Generic_Subprogram (Id));
return Node34 (Id);
end Contract;
@@ -3558,6 +3564,11 @@ package body Einfo is
Set_Elist16 (Id, V);
end Set_Access_Disp_Table;
+ procedure Set_Associated_Entity (Id : E; V : E) is
+ begin
+ Set_Node37 (Id, V);
+ end Set_Associated_Entity;
+
procedure Set_Associated_Formal_Package (Id : E; V : E) is
begin
Set_Node12 (Id, V);
@@ -3733,13 +3744,13 @@ package body Einfo is
begin
pragma Assert
(Ekind_In (Id, E_Entry,
- E_Entry_Family,
- E_Generic_Package,
- E_Package,
- E_Package_Body,
- E_Subprogram_Body,
- E_Variable,
- E_Void)
+ E_Entry_Family,
+ E_Generic_Package,
+ E_Package,
+ E_Package_Body,
+ E_Subprogram_Body,
+ E_Variable,
+ E_Void)
or else Is_Subprogram_Or_Generic_Subprogram (Id));
Set_Node34 (Id, V);
end Set_Contract;
@@ -3993,8 +4004,8 @@ package body Einfo is
procedure Set_Encapsulating_State (Id : E; V : E) is
begin
- pragma Assert (Ekind_In (Id, E_Abstract_State, E_Variable));
- Set_Node10 (Id, V);
+ pragma Assert (Ekind_In (Id, E_Abstract_State, E_Constant, E_Variable));
+ Set_Node32 (Id, V);
end Set_Encapsulating_State;
procedure Set_Enclosing_Scope (Id : E; V : E) is
@@ -8993,7 +9004,7 @@ package body Einfo is
-----------------------
procedure Write_Field6_Name (Id : Entity_Id) is
- pragma Warnings (Off, Id);
+ pragma Unreferenced (Id);
begin
Write_Str ("First_Rep_Item");
end Write_Field6_Name;
@@ -9003,7 +9014,7 @@ package body Einfo is
-----------------------
procedure Write_Field7_Name (Id : Entity_Id) is
- pragma Warnings (Off, Id);
+ pragma Unreferenced (Id);
begin
Write_Str ("Freeze_Node");
end Write_Field7_Name;
@@ -9083,10 +9094,6 @@ package body Einfo is
procedure Write_Field10_Name (Id : Entity_Id) is
begin
case Ekind (Id) is
- when E_Abstract_State |
- E_Variable =>
- Write_Str ("Encapsulating_State");
-
when Class_Wide_Kind |
Incomplete_Kind |
E_Record_Type |
@@ -9095,13 +9102,13 @@ package body Einfo is
Concurrent_Kind =>
Write_Str ("Direct_Primitive_Operations");
- when Float_Kind =>
- Write_Str ("Float_Rep");
-
when E_In_Parameter |
E_Constant =>
Write_Str ("Discriminal_Link");
+ when Float_Kind =>
+ Write_Str ("Float_Rep");
+
when E_Function |
E_Package |
E_Package_Body |
@@ -9995,6 +10002,11 @@ package body Einfo is
procedure Write_Field32_Name (Id : Entity_Id) is
begin
case Ekind (Id) is
+ when E_Abstract_State |
+ E_Constant |
+ E_Variable =>
+ Write_Str ("Encapsulating_State");
+
when E_Function |
E_Generic_Function |
E_Generic_Package |
@@ -10050,6 +10062,7 @@ package body Einfo is
E_Package_Body |
E_Subprogram_Body |
E_Variable |
+ E_Void |
Generic_Subprogram_Kind |
Subprogram_Kind =>
Write_Str ("Contract");
@@ -10091,11 +10104,9 @@ package body Einfo is
------------------------
procedure Write_Field37_Name (Id : Entity_Id) is
+ pragma Unreferenced (Id);
begin
- case Ekind (Id) is
- when others =>
- Write_Str ("Field37??");
- end case;
+ Write_Str ("Associated_Entity");
end Write_Field37_Name;
------------------------