@@ -352,13 +352,37 @@ package body Tree_Walk is
352
352
Old_Type : Entity_Id;
353
353
New_Type : Entity_Id) return Irep;
354
354
355
+ type Construct is (Declaration, Statement);
356
+
357
+ procedure Warn_Unhandled_Construct (C : Construct; Mess : String);
358
+
359
+ procedure Process_Declaration (N : Node_Id; Block : Irep);
360
+ -- with Pre => Nkind (N) in N_Declaration or else
361
+ -- Nkind (N) in N_Number_Declaration or else
362
+ -- Nkind (N) in N_Later_Decl_Item or else
363
+ -- Nkind (N) in N_Pragma or else
364
+ -- Nkind (N) in N_Exception_Declaration or else
365
+ -- Nkind (N) in N_Freeze_Entity;
366
+ -- Precondition commented out because full extend of declrations not yet known
367
+ -- Handles both a basic declaration and a declarative item.
368
+
369
+ procedure Process_Declarations (L : List_Id; Block : Irep);
370
+ -- Processes the declarations and is used for both a package specification
371
+ -- where only basic declarations are allowed (no subprogram bodies etc.)
372
+ -- and declarative parts where such declaratios are allowed.
373
+ -- The Gnat front end will check that only allowed declarations are used
374
+ -- where only basic declarations permitted.
375
+ -- Process_Declarations is a procedure rather than a function like its
376
+ -- sister Process_Statements because the Irep (an I_Code_Block) has to be
377
+ -- extended in package_specifications when it has private declarations.
378
+
355
379
procedure Process_Statement (N : Node_Id; Block : Irep)
356
380
with Pre => Kind (Block) = I_Code_Block;
357
- -- Process statement or declaration
381
+ -- Process statement
358
382
359
383
function Process_Statements (L : List_Id) return Irep
360
384
with Post => Kind (Process_Statements'Result) = I_Code_Block;
361
- -- Process list of statements or declarations
385
+ -- Process list of statements
362
386
363
387
procedure Register_Subprogram_Specification (N : Node_Id)
364
388
with Pre => Nkind (N) in N_Subprogram_Specification;
@@ -4833,81 +4857,247 @@ package body Tree_Walk is
4833
4857
end ;
4834
4858
end Maybe_Make_Typecast ;
4835
4859
4860
+ -- ------------------------------
4861
+ -- Warn_Unhandled_Construct --
4862
+ -- ------------------------------
4863
+
4864
+ procedure Warn_Unhandled_Construct (C : Construct; Mess : String) is
4865
+ S : constant String :=
4866
+ (case C is
4867
+ when Declaration => " declarations " ,
4868
+ when Statement => " statements " ) & " unhandled" ;
4869
+ begin
4870
+ Put_Line (Standard_Error, " Warning: " & Mess & S);
4871
+ end Warn_Unhandled_Construct ;
4872
+
4873
+ -- ------------------------
4874
+ -- Process_Declaration --
4875
+ -- ------------------------
4876
+
4877
+ procedure Process_Declaration (N : Node_Id; Block : Irep) is
4878
+ begin
4879
+ -- Deal with the declaration
4880
+
4881
+ case Nkind (N) is
4882
+
4883
+ -- basic_declarations --
4884
+
4885
+ when N_Full_Type_Declaration =>
4886
+ Do_Full_Type_Declaration (N);
4887
+
4888
+ when N_Subtype_Declaration =>
4889
+ Do_Subtype_Declaration (N);
4890
+
4891
+ when N_Object_Declaration =>
4892
+ Do_Object_Declaration (N, Block);
4893
+
4894
+ when N_Number_Declaration =>
4895
+ Warn_Unhandled_Construct (Declaration, " Number" );
4896
+
4897
+ when N_Subprogram_Declaration =>
4898
+ Do_Subprogram_Declaration (N);
4899
+
4900
+ when N_Abstract_Subprogram_Declaration =>
4901
+ Warn_Unhandled_Construct
4902
+ (Declaration, " Abstract subprogram" );
4903
+
4904
+ when N_Package_Declaration =>
4905
+ Warn_Unhandled_Construct (Declaration, " Package" );
4906
+
4907
+ when N_Renaming_Declaration =>
4908
+ Warn_Unhandled_Construct (Declaration, " Renaming" );
4909
+
4910
+ when N_Exception_Declaration =>
4911
+ Warn_Unhandled_Construct (Declaration, " Exception" );
4912
+
4913
+ when N_Generic_Declaration =>
4914
+ Warn_Unhandled_Construct (Declaration, " Generic" );
4915
+
4916
+ when N_Generic_Instantiation =>
4917
+ Warn_Unhandled_Construct (Declaration, " Generic instantiation" );
4918
+
4919
+ -- basic_declarative_items --
4920
+
4921
+ when N_Representation_Clause =>
4922
+ Warn_Unhandled_Construct (Declaration, " Representation clause" );
4923
+
4924
+ when N_Use_Package_Clause =>
4925
+ Warn_Unhandled_Construct (Declaration, " Use package clause" );
4926
+
4927
+ when N_Use_Type_Clause =>
4928
+ Warn_Unhandled_Construct (Declaration, " Use type clause" );
4929
+
4930
+ -- remaining declarative items --
4931
+
4932
+ -- proper_body --
4933
+
4934
+ when N_Subprogram_Body =>
4935
+ Do_Subprogram_Body (N);
4936
+
4937
+ when N_Package_Body =>
4938
+ Warn_Unhandled_Construct (Declaration, " Package body" );
4939
+
4940
+ when N_Task_Body =>
4941
+ Warn_Unhandled_Construct (Declaration, " Task body" );
4942
+
4943
+ when N_Protected_Body =>
4944
+ Warn_Unhandled_Construct (Declaration, " Protected body" );
4945
+
4946
+ -- body_stub --
4947
+
4948
+ when N_Subprogram_Body_Stub =>
4949
+ Warn_Unhandled_Construct (Declaration, " Subprogram body stub" );
4950
+
4951
+ when N_Package_Body_Stub =>
4952
+ Warn_Unhandled_Construct (Declaration, " Package body stub" );
4953
+
4954
+ when N_Task_Body_Stub =>
4955
+ Warn_Unhandled_Construct (Declaration, " Task body stub" );
4956
+
4957
+ when N_Protected_Body_Stub =>
4958
+ Warn_Unhandled_Construct (Declaration, " Protected body stub" );
4959
+
4960
+ -- Pragmas may appear in declarations --
4961
+
4962
+ when N_Pragma =>
4963
+ Warn_Unhandled_Construct (Declaration, " Pragmas in" );
4964
+
4965
+ -- Every code lable is implicitly declared in --
4966
+ -- the closest surrounding block --
4967
+
4968
+ when N_Implicit_Label_Declaration =>
4969
+ -- Ignore for now, as I guess an implicit label can't be
4970
+ -- referenced.
4971
+ -- Yes it can: this is the declaration of the name it appears
4972
+ -- the declaritve section but is used on a statement.
4973
+ null ;
4974
+
4975
+ -- Not sure the nex two should be here --
4976
+ when N_Itype_Reference =>
4977
+ Do_Itype_Reference (N);
4978
+
4979
+ when N_Freeze_Entity =>
4980
+ -- Ignore, nothing to generate
4981
+ null ;
4982
+
4983
+ when others =>
4984
+ Report_Unhandled_Node_Empty (N, " Process_Declaration" ,
4985
+ " Unknown declaration kind" );
4986
+
4987
+ end case ;
4988
+
4989
+ end Process_Declaration ;
4990
+
4991
+ -- ------------------------
4992
+ -- Process_Declarations --
4993
+ -- ------------------------
4994
+
4995
+ procedure Process_Declarations (L : List_Id; Block : Irep) is
4996
+ Decl : Node_Id := First (L);
4997
+ begin
4998
+ while Present (Decl) loop
4999
+ Process_Declaration (Decl, Block);
5000
+ Next (Decl);
5001
+ end loop ;
5002
+
5003
+ end Process_Declarations ;
5004
+
4836
5005
-- -----------------------
4837
5006
-- Process_Statement --
4838
5007
-- -----------------------
4839
5008
4840
5009
procedure Process_Statement (N : Node_Id; Block : Irep) is
4841
- procedure Warn_Unhandled_Statement (M : String);
4842
- procedure Warn_Unhandled_Statement (M : String) is
4843
- begin
4844
- Put_Line (Standard_Error, " Warning: " & M & " statements unhandled" );
4845
- end Warn_Unhandled_Statement ;
4846
5010
begin
4847
5011
-- Deal with the statement
4848
5012
case Nkind (N) is
5013
+ -- Simple statements --
5014
+ when N_Null_Statement =>
5015
+ null ;
5016
+
4849
5017
when N_Assignment_Statement =>
4850
5018
Append_Op (Block, Do_Assignment_Statement (N));
4851
5019
5020
+ when N_Exit_Statement =>
5021
+ Append_Op (Block, Do_Exit_Statement (N));
5022
+
5023
+ when N_Goto_Statement =>
5024
+ Warn_Unhandled_Construct (Statement, " goto" );
5025
+
4852
5026
when N_Procedure_Call_Statement =>
4853
5027
Append_Op (Block, Do_Procedure_Call_Statement (N));
4854
5028
4855
5029
when N_Simple_Return_Statement =>
4856
5030
Append_Op (Block, Do_Simple_Return_Statement (N));
4857
5031
4858
- when N_Object_Declaration =>
4859
- Do_Object_Declaration (N, Block );
5032
+ when N_Entry_Call_Statement =>
5033
+ Warn_Unhandled_Construct (Statement, " entry_call " );
4860
5034
4861
- when N_Handled_Sequence_Of_Statements =>
4862
- Append_Op (Block, Do_Handled_Sequence_Of_Statements (N));
5035
+ when N_Requeue_Statement =>
5036
+ Warn_Unhandled_Construct (Statement, " requeue" );
5037
+
5038
+ when N_Delay_Statement =>
5039
+ Warn_Unhandled_Construct (Statement, " delay" );
5040
+
5041
+ when N_Abort_Statement =>
5042
+ Warn_Unhandled_Construct (Statement, " abort" );
5043
+
5044
+ when N_Raise_Statement =>
5045
+ Warn_Unhandled_Construct (Statement, " raise" );
5046
+
5047
+ when N_Code_Statement =>
5048
+ Warn_Unhandled_Construct (Statement, " code" );
5049
+
5050
+ -- Compound statements
4863
5051
4864
5052
when N_If_Statement =>
4865
5053
Append_Op (Block, Do_If_Statement (N));
4866
5054
4867
- when N_Implicit_Label_Declaration =>
4868
- -- Ignore for now, as I guess an implicit label can't be
4869
- -- referenced.
4870
- null ;
5055
+ when N_Case_Statement =>
5056
+ Warn_Unhandled_Construct (Statement, " case" );
4871
5057
4872
5058
when N_Loop_Statement =>
4873
5059
Append_Op (Block, Do_Loop_Statement (N));
4874
5060
4875
- when N_Full_Type_Declaration =>
4876
- Do_Full_Type_Declaration (N );
5061
+ when N_Block_Statement =>
5062
+ Warn_Unhandled_Construct (Statement, " block " );
4877
5063
4878
- when N_Subtype_Declaration =>
4879
- Do_Subtype_Declaration (N);
5064
+ when N_Handled_Sequence_Of_Statements => -- this seems incorrct
5065
+ -- It should be block_statement
5066
+ Append_Op (Block, Do_Handled_Sequence_Of_Statements (N));
4880
5067
4881
- when N_Freeze_Entity =>
4882
- -- Ignore, nothing to generate
4883
- null ;
5068
+ when N_Extended_Return_Statement =>
5069
+ Warn_Unhandled_Construct (Statement, " extended_return" );
4884
5070
4885
- when N_Itype_Reference =>
4886
- Do_Itype_Reference (N );
5071
+ when N_Accept_Statement =>
5072
+ Warn_Unhandled_Construct (Statement, " accept " );
4887
5073
4888
- when N_Subprogram_Declaration =>
4889
- Do_Subprogram_Declaration (N);
5074
+ -- Select statements --
4890
5075
4891
- when N_Subprogram_Body =>
4892
- Do_Subprogram_Body (N );
5076
+ when N_Selective_Accept =>
5077
+ Warn_Unhandled_Construct (Statement, " selective_accept " );
4893
5078
4894
- when N_Null_Statement =>
4895
- null ;
5079
+ when N_Timed_Entry_Call =>
5080
+ Warn_Unhandled_Construct (Statement, " timed_entry_call " ) ;
4896
5081
4897
- when N_Exit_Statement =>
4898
- Append_Op (Block, Do_Exit_Statement (N));
5082
+ when N_Conditional_Entry_Call =>
5083
+ Warn_Unhandled_Construct (Statement, " conditional_entry_call" );
5084
+
5085
+ when N_Asynchronous_Select =>
5086
+ Warn_Unhandled_Construct (Statement, " asychronous select" );
5087
+
5088
+ -- Pragmas may placed in sequences of statements --
4899
5089
4900
5090
when N_Pragma =>
4901
5091
Do_Pragma (N, Block);
4902
5092
4903
- when N_Raise_Statement =>
4904
- Warn_Unhandled_Statement (" Raise" );
5093
+ -- Not sure the nex two should be here -
5094
+ -- should they be in declarations? --
5095
+ -- when N_Itype_Reference =>
5096
+ -- Do_Itype_Reference (N);
4905
5097
4906
- when N_Number_Declaration =>
4907
- Warn_Unhandled_Statement (" Number declaration" );
4908
-
4909
- when N_Case_Statement =>
4910
- Warn_Unhandled_Statement (" Case" );
5098
+ -- when N_Freeze_Entity =>
5099
+ -- -- Ignore, nothing to generate
5100
+ -- null;
4911
5101
4912
5102
when others =>
4913
5103
Report_Unhandled_Node_Empty (N, " Process_Statement" ,
0 commit comments