1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 pragma Style_Checks (All_Checks);
27 -- Turn off subprogram body ordering check. Subprograms are in order
28 -- by RM section rather than alphabetical
30 with Sinfo.CN; use Sinfo.CN;
35 -- Local subprograms, used only in this chapter
37 function P_Defining_Designator return Node_Id;
38 function P_Defining_Operator_Symbol return Node_Id;
39 function P_Return_Object_Declaration return Node_Id;
41 procedure P_Return_Subtype_Indication (Decl_Node : Node_Id);
42 -- Decl_Node is a N_Object_Declaration.
43 -- Set the Null_Exclusion_Present and Object_Definition fields of
46 procedure Check_Junk_Semicolon_Before_Return;
48 -- Check for common error of junk semicolon before RETURN keyword of
49 -- function specification. If present, skip over it with appropriate
50 -- error message, leaving Scan_Ptr pointing to the RETURN after. This
51 -- routine also deals with a possibly misspelled version of Return.
53 ----------------------------------------
54 -- Check_Junk_Semicolon_Before_Return --
55 ----------------------------------------
57 procedure Check_Junk_Semicolon_Before_Return is
58 Scan_State : Saved_Scan_State;
61 if Token = Tok_Semicolon then
62 Save_Scan_State (Scan_State);
63 Scan; -- past the semicolon
65 if Token = Tok_Return then
66 Restore_Scan_State (Scan_State);
67 Error_Msg_SC -- CODEFIX
68 ("|extra "";"" ignored");
69 Scan; -- rescan past junk semicolon
71 Restore_Scan_State (Scan_State);
74 elsif Bad_Spelling_Of (Tok_Return) then
77 end Check_Junk_Semicolon_Before_Return;
79 -----------------------------------------------------
80 -- 6.1 Subprogram (Also 6.3, 8.5.4, 10.1.3, 12.3) --
81 -----------------------------------------------------
83 -- This routine scans out a subprogram declaration, subprogram body,
84 -- subprogram renaming declaration or subprogram generic instantiation.
85 -- It also handles the new Ada 2012 expression function form
87 -- SUBPROGRAM_DECLARATION ::=
88 -- SUBPROGRAM_SPECIFICATION
89 -- [ASPECT_SPECIFICATIONS];
91 -- ABSTRACT_SUBPROGRAM_DECLARATION ::=
92 -- SUBPROGRAM_SPECIFICATION is abstract
93 -- [ASPECT_SPECIFICATIONS];
95 -- SUBPROGRAM_SPECIFICATION ::=
96 -- procedure DEFINING_PROGRAM_UNIT_NAME PARAMETER_PROFILE
97 -- | function DEFINING_DESIGNATOR PARAMETER_AND_RESULT_PROFILE
99 -- PARAMETER_PROFILE ::= [FORMAL_PART]
101 -- PARAMETER_AND_RESULT_PROFILE ::= [FORMAL_PART] return SUBTYPE_MARK
103 -- SUBPROGRAM_BODY ::=
104 -- SUBPROGRAM_SPECIFICATION is
107 -- HANDLED_SEQUENCE_OF_STATEMENTS
110 -- SUBPROGRAM_RENAMING_DECLARATION ::=
111 -- SUBPROGRAM_SPECIFICATION renames callable_entity_NAME;
113 -- SUBPROGRAM_BODY_STUB ::=
114 -- SUBPROGRAM_SPECIFICATION is separate;
116 -- GENERIC_INSTANTIATION ::=
117 -- procedure DEFINING_PROGRAM_UNIT_NAME is
118 -- new generic_procedure_NAME [GENERIC_ACTUAL_PART];
119 -- | function DEFINING_DESIGNATOR is
120 -- new generic_function_NAME [GENERIC_ACTUAL_PART];
122 -- NULL_PROCEDURE_DECLARATION ::=
123 -- SUBPROGRAM_SPECIFICATION is null;
125 -- Null procedures are an Ada 2005 feature. A null procedure declaration
126 -- is classified as a basic declarative item, but it is parsed here, with
127 -- other subprogram constructs.
129 -- EXPRESSION_FUNCTION ::=
130 -- FUNCTION SPECIFICATION IS (EXPRESSION);
132 -- The value in Pf_Flags indicates which of these possible declarations
133 -- is acceptable to the caller:
135 -- Pf_Flags.Decl Set if declaration OK
136 -- Pf_Flags.Gins Set if generic instantiation OK
137 -- Pf_Flags.Pbod Set if proper body OK
138 -- Pf_Flags.Rnam Set if renaming declaration OK
139 -- Pf_Flags.Stub Set if body stub OK
140 -- Pf_Flags.Pexp Set if expression function OK
142 -- If an inappropriate form is encountered, it is scanned out but an
143 -- error message indicating that it is appearing in an inappropriate
144 -- context is issued. The only possible values for Pf_Flags are those
145 -- defined as constants in the Par package.
147 -- The caller has checked that the initial token is FUNCTION, PROCEDURE,
148 -- NOT or OVERRIDING.
150 -- Error recovery: cannot raise Error_Resync
152 function P_Subprogram (Pf_Flags : Pf_Rec) return Node_Id is
153 Specification_Node : Node_Id;
155 Fpart_List : List_Id;
156 Fpart_Sloc : Source_Ptr;
157 Result_Not_Null : Boolean := False;
158 Result_Node : Node_Id;
162 Rename_Node : Node_Id;
163 Absdec_Node : Node_Id;
165 Fproc_Sloc : Source_Ptr;
167 Scan_State : Saved_Scan_State;
169 -- Flags for optional overriding indication. Two flags are needed,
170 -- to distinguish positive and negative overriding indicators from
171 -- the absence of any indicator.
173 Is_Overriding : Boolean := False;
174 Not_Overriding : Boolean := False;
177 -- Set up scope stack entry. Note that the Labl field will be set later
179 SIS_Entry_Active := False;
180 SIS_Missing_Semicolon_Message := No_Error_Msg;
182 Scope.Table (Scope.Last).Sloc := Token_Ptr;
183 Scope.Table (Scope.Last).Etyp := E_Name;
184 Scope.Table (Scope.Last).Ecol := Start_Column;
185 Scope.Table (Scope.Last).Lreq := False;
187 -- Ada2005: scan leading NOT OVERRIDING indicator
189 if Token = Tok_Not then
192 if Token = Tok_Overriding then
193 Scan; -- past OVERRIDING
194 Not_Overriding := True;
196 -- Overriding keyword used in non Ada 2005 mode
198 elsif Token = Tok_Identifier
199 and then Token_Name = Name_Overriding
201 Error_Msg_SC ("overriding indicator is an Ada 2005 extension");
202 Error_Msg_SC ("\unit must be compiled with -gnat05 switch");
203 Scan; -- past Overriding
204 Not_Overriding := True;
207 Error_Msg_SC -- CODEFIX
208 ("OVERRIDING expected!");
211 -- Ada 2005: scan leading OVERRIDING indicator
213 -- Note: in the case of OVERRIDING keyword used in Ada 95 mode, the
214 -- declaration circuit already gave an error message and changed the
215 -- token to Tok_Overriding.
217 elsif Token = Tok_Overriding then
218 Scan; -- past OVERRIDING
219 Is_Overriding := True;
222 if Is_Overriding or else Not_Overriding then
224 -- Note that if we are not in Ada_2005 mode, error messages have
225 -- already been given, so no need to give another message here.
227 -- An overriding indicator is allowed for subprogram declarations,
228 -- bodies (including subunits), renamings, stubs, and instantiations.
229 -- The test against Pf_Decl_Pbod is added to account for the case of
230 -- subprograms declared in a protected type, where only subprogram
231 -- declarations and bodies can occur. The Pf_Pbod case is for
234 if Pf_Flags /= Pf_Decl_Gins_Pbod_Rnam_Stub_Pexp
236 Pf_Flags /= Pf_Decl_Pbod_Pexp
238 Pf_Flags /= Pf_Pbod_Pexp
240 Error_Msg_SC ("overriding indicator not allowed here!");
242 elsif Token /= Tok_Function and then Token /= Tok_Procedure then
243 Error_Msg_SC -- CODEFIX
244 ("FUNCTION or PROCEDURE expected!");
248 Func := (Token = Tok_Function);
249 Fproc_Sloc := Token_Ptr;
250 Scan; -- past FUNCTION or PROCEDURE
255 Name_Node := P_Defining_Designator;
257 if Nkind (Name_Node) = N_Defining_Operator_Symbol
258 and then Scope.Last = 1
260 Error_Msg_SP ("operator symbol not allowed at library level");
261 Name_Node := New_Entity (N_Defining_Identifier, Sloc (Name_Node));
263 -- Set name from file name, we need some junk name, and that's
264 -- as good as anything. This is only approximate, since we do
265 -- not do anything with non-standard name translations.
267 Get_Name_String (File_Name (Current_Source_File));
269 for J in 1 .. Name_Len loop
270 if Name_Buffer (J) = '.' then
276 Set_Chars (Name_Node, Name_Find);
277 Set_Error_Posted (Name_Node);
281 Name_Node := P_Defining_Program_Unit_Name;
284 Scope.Table (Scope.Last).Labl := Name_Node;
287 -- Deal with generic instantiation, the one case in which we do not
288 -- have a subprogram specification as part of whatever we are parsing
290 if Token = Tok_Is then
291 Save_Scan_State (Scan_State); -- at the IS
292 T_Is; -- checks for redundant IS
294 if Token = Tok_New then
295 if not Pf_Flags.Gins then
296 Error_Msg_SC ("generic instantiation not allowed here!");
302 Inst_Node := New_Node (N_Function_Instantiation, Fproc_Sloc);
303 Set_Name (Inst_Node, P_Function_Name);
305 Inst_Node := New_Node (N_Procedure_Instantiation, Fproc_Sloc);
306 Set_Name (Inst_Node, P_Qualified_Simple_Name);
309 Set_Defining_Unit_Name (Inst_Node, Name_Node);
310 Set_Generic_Associations (Inst_Node, P_Generic_Actual_Part_Opt);
311 P_Aspect_Specifications (Inst_Node);
312 Pop_Scope_Stack; -- Don't need scope stack entry in this case
314 if Is_Overriding then
315 Set_Must_Override (Inst_Node);
317 elsif Not_Overriding then
318 Set_Must_Not_Override (Inst_Node);
324 Restore_Scan_State (Scan_State); -- to the IS
328 -- If not a generic instantiation, then we definitely have a subprogram
329 -- specification (all possibilities at this stage include one here)
331 Fpart_Sloc := Token_Ptr;
333 Check_Misspelling_Of (Tok_Return);
335 -- Scan formal part. First a special error check. If we have an
336 -- identifier here, then we have a definite error. If this identifier
337 -- is on the same line as the designator, then we assume it is the
338 -- first formal after a missing left parenthesis
340 if Token = Tok_Identifier
341 and then not Token_Is_At_Start_Of_Line
343 T_Left_Paren; -- to generate message
344 Fpart_List := P_Formal_Part;
346 -- Otherwise scan out an optional formal part in the usual manner
349 Fpart_List := P_Parameter_Profile;
352 -- We treat what we have as a function specification if FUNCTION was
353 -- used, or if a RETURN is present. This gives better error recovery
354 -- since later RETURN statements will be valid in either case.
356 Check_Junk_Semicolon_Before_Return;
357 Result_Node := Error;
359 if Token = Tok_Return then
362 ("PROCEDURE should be FUNCTION", Fproc_Sloc);
368 Result_Not_Null := P_Null_Exclusion; -- Ada 2005 (AI-231)
370 -- Ada 2005 (AI-318-02)
372 if Token = Tok_Access then
373 if Ada_Version < Ada_2005 then
375 ("anonymous access result type is an Ada 2005 extension");
376 Error_Msg_SC ("\unit must be compiled with -gnat05 switch");
379 Result_Node := P_Access_Definition (Result_Not_Null);
382 Result_Node := P_Subtype_Mark;
387 -- Skip extra parenthesis at end of formal part
389 Ignore (Tok_Right_Paren);
391 -- For function, scan result subtype
396 if Prev_Token = Tok_Return then
397 Result_Node := P_Subtype_Mark;
403 Specification_Node :=
404 New_Node (N_Function_Specification, Fproc_Sloc);
406 Set_Null_Exclusion_Present (Specification_Node, Result_Not_Null);
407 Set_Result_Definition (Specification_Node, Result_Node);
410 Specification_Node :=
411 New_Node (N_Procedure_Specification, Fproc_Sloc);
414 Set_Defining_Unit_Name (Specification_Node, Name_Node);
415 Set_Parameter_Specifications (Specification_Node, Fpart_List);
417 if Is_Overriding then
418 Set_Must_Override (Specification_Node);
420 elsif Not_Overriding then
421 Set_Must_Not_Override (Specification_Node);
424 -- Error check: barriers not allowed on protected functions/procedures
426 if Token = Tok_When then
428 Error_Msg_SC ("barrier not allowed on function, only on entry");
430 Error_Msg_SC ("barrier not allowed on procedure, only on entry");
434 Discard_Junk_Node (P_Expression);
437 -- Deal with semicolon followed by IS. We want to treat this as IS
439 if Token = Tok_Semicolon then
440 Save_Scan_State (Scan_State);
441 Scan; -- past semicolon
443 if Token = Tok_Is then
444 Error_Msg_SP -- CODEFIX
445 ("extra "";"" ignored");
447 Restore_Scan_State (Scan_State);
451 -- Subprogram declaration ended by aspect specifications
453 if Aspect_Specifications_Present then
454 goto Subprogram_Declaration;
456 -- Deal with case of semicolon ending a subprogram declaration
458 elsif Token = Tok_Semicolon then
459 if not Pf_Flags.Decl then
463 Save_Scan_State (Scan_State);
464 Scan; -- past semicolon
466 -- If semicolon is immediately followed by IS, then ignore the
467 -- semicolon, and go process the body.
469 if Token = Tok_Is then
470 Error_Msg_SP -- CODEFIX
471 ("|extra "";"" ignored");
472 T_Is; -- scan past IS
473 goto Subprogram_Body;
475 -- If BEGIN follows in an appropriate column, we immediately
476 -- commence the error action of assuming that the previous
477 -- subprogram declaration should have been a subprogram body,
478 -- i.e. that the terminating semicolon should have been IS.
480 elsif Token = Tok_Begin
481 and then Start_Column >= Scope.Table (Scope.Last).Ecol
483 Error_Msg_SP -- CODEFIX
484 ("|"";"" should be IS!");
485 goto Subprogram_Body;
488 Restore_Scan_State (Scan_State);
489 goto Subprogram_Declaration;
492 -- Case of not followed by semicolon
495 -- Subprogram renaming declaration case
497 Check_Misspelling_Of (Tok_Renames);
499 if Token = Tok_Renames then
500 if not Pf_Flags.Rnam then
501 Error_Msg_SC ("renaming declaration not allowed here!");
505 New_Node (N_Subprogram_Renaming_Declaration, Token_Ptr);
506 Scan; -- past RENAMES
507 Set_Name (Rename_Node, P_Name);
508 Set_Specification (Rename_Node, Specification_Node);
513 -- Case of IS following subprogram specification
515 elsif Token = Tok_Is then
516 T_Is; -- ignore redundant Is's
518 if Token_Name = Name_Abstract then
519 Check_95_Keyword (Tok_Abstract, Tok_Semicolon);
522 -- Deal nicely with (now obsolete) use of <> in place of abstract
524 if Token = Tok_Box then
525 Error_Msg_SC -- CODEFIX
526 ("ABSTRACT expected");
527 Token := Tok_Abstract;
530 -- Abstract subprogram declaration case
532 if Token = Tok_Abstract then
534 New_Node (N_Abstract_Subprogram_Declaration, Token_Ptr);
535 Set_Specification (Absdec_Node, Specification_Node);
536 Pop_Scope_Stack; -- discard unneeded entry
537 Scan; -- past ABSTRACT
538 P_Aspect_Specifications (Absdec_Node);
541 -- Ada 2005 (AI-248): Parse a null procedure declaration
543 elsif Token = Tok_Null then
544 if Ada_Version < Ada_2005 then
545 Error_Msg_SP ("null procedures are an Ada 2005 extension");
546 Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
552 Error_Msg_SP ("only procedures can be null");
554 Set_Null_Present (Specification_Node);
557 goto Subprogram_Declaration;
559 -- Check for IS NEW with Formal_Part present and handle nicely
561 elsif Token = Tok_New then
563 ("formal part not allowed in instantiation", Fpart_Sloc);
567 Inst_Node := New_Node (N_Function_Instantiation, Fproc_Sloc);
570 New_Node (N_Procedure_Instantiation, Fproc_Sloc);
573 Set_Defining_Unit_Name (Inst_Node, Name_Node);
574 Set_Name (Inst_Node, P_Name);
575 Set_Generic_Associations (Inst_Node, P_Generic_Actual_Part_Opt);
577 Pop_Scope_Stack; -- Don't need scope stack entry in this case
581 goto Subprogram_Body;
584 -- Aspect specifications present
586 elsif Aspect_Specifications_Present then
587 goto Subprogram_Declaration;
589 -- Here we have a missing IS or missing semicolon, we always guess
590 -- a missing semicolon, since we are pretty good at fixing up a
591 -- semicolon which should really be an IS
594 Error_Msg_AP -- CODEFIX
596 SIS_Missing_Semicolon_Message := Get_Msg_Id;
597 goto Subprogram_Declaration;
601 -- Processing for stub or subprogram body or expression function
605 -- Subprogram body stub case
607 if Separate_Present then
608 if not Pf_Flags.Stub then
609 Error_Msg_SC ("body stub not allowed here!");
612 if Nkind (Name_Node) = N_Defining_Operator_Symbol then
614 ("operator symbol cannot be used as subunit name",
619 New_Node (N_Subprogram_Body_Stub, Sloc (Specification_Node));
620 Set_Specification (Stub_Node, Specification_Node);
621 Scan; -- past SEPARATE
626 -- Subprogram body or expression function case
629 Scan_Body_Or_Expression_Function : declare
631 Body_Is_Hidden_In_SPARK : Boolean;
632 Hidden_Region_Start : Source_Ptr;
634 function Likely_Expression_Function return Boolean;
635 -- Returns True if we have a probable case of an expression
636 -- function omitting the parentheses, if so, returns True
637 -- and emits an appropriate error message, else returns False.
639 --------------------------------
640 -- Likely_Expression_Function --
641 --------------------------------
643 function Likely_Expression_Function return Boolean is
645 -- If currently pointing to BEGIN or a declaration keyword
646 -- or a pragma, then we definitely have a subprogram body.
647 -- This is a common case, so worth testing first.
650 or else Token in Token_Class_Declk
651 or else Token = Tok_Pragma
655 -- Test for tokens which could only start an expression and
656 -- thus signal the case of a expression function.
658 elsif Token in Token_Class_Literal
659 or else Token in Token_Class_Unary_Addop
660 or else Token = Tok_Left_Paren
661 or else Token = Tok_Abs
662 or else Token = Tok_Null
663 or else Token = Tok_New
664 or else Token = Tok_Not
668 -- Anything other than an identifier must be a body
670 elsif Token /= Tok_Identifier then
673 -- Here for an identifier
676 -- If the identifier is the first token on its line, then
677 -- let's assume that we have a missing begin and this is
678 -- intended as a subprogram body.
680 if Token_Is_At_Start_Of_Line then
683 -- Otherwise we have to scan ahead. If the identifier is
684 -- followed by a colon or a comma, it is a declaration
685 -- and hence we have a subprogram body. Otherwise assume
686 -- a expression function.
690 Scan_State : Saved_Scan_State;
694 Save_Scan_State (Scan_State);
695 Scan; -- past identifier
697 Restore_Scan_State (Scan_State);
699 if Tok = Tok_Colon or else Tok = Tok_Comma then
706 -- Fall through if we have a likely expression function
709 ("expression function must be enclosed in parentheses");
711 end Likely_Expression_Function;
713 -- Start of processing for Scan_Body_Or_Expression_Function
716 -- Expression_Function case
718 if Token = Tok_Left_Paren
719 or else Likely_Expression_Function
721 -- Check expression function allowed here
723 if not Pf_Flags.Pexp then
724 Error_Msg_SC ("expression function not allowed here!");
727 -- Check we are in Ada 2012 mode
729 if Ada_Version < Ada_2012 then
731 ("expression function is an Ada 2012 feature!");
733 ("\unit must be compiled with -gnat2012 switch!");
736 -- Parse out expression and build expression function
740 (N_Expression_Function, Sloc (Specification_Node));
741 Set_Specification (Body_Node, Specification_Node);
742 Set_Expression (Body_Node, P_Expression);
746 -- Subprogram body case
749 -- Check body allowed here
751 if not Pf_Flags.Pbod then
752 Error_Msg_SP ("subprogram body not allowed here!");
755 -- Here is the test for a suspicious IS (i.e. one that
756 -- looks like it might more properly be a semicolon).
757 -- See separate section describing use of IS instead
758 -- of semicolon in package Parse.
760 if (Token in Token_Class_Declk
762 Token = Tok_Identifier)
763 and then Start_Column <= Scope.Table (Scope.Last).Ecol
764 and then Scope.Last /= 1
766 Scope.Table (Scope.Last).Etyp := E_Suspicious_Is;
767 Scope.Table (Scope.Last).S_Is := Prev_Token_Ptr;
770 -- Build and return subprogram body, parsing declarations
771 -- and statement sequence that belong to the body.
774 New_Node (N_Subprogram_Body, Sloc (Specification_Node));
775 Set_Specification (Body_Node, Specification_Node);
777 -- In SPARK, a HIDE directive can be placed at the beginning
778 -- of a subprogram implementation, thus hiding the
779 -- subprogram body from SPARK tool-set. No violation of the
780 -- SPARK restriction should be issued on nodes in a hidden
781 -- part, which is obtained by marking such hidden parts.
783 if Token = Tok_SPARK_Hide then
784 Body_Is_Hidden_In_SPARK := True;
785 Hidden_Region_Start := Token_Ptr;
786 Scan; -- past HIDE directive
788 Body_Is_Hidden_In_SPARK := False;
791 Parse_Decls_Begin_End (Body_Node);
793 if Body_Is_Hidden_In_SPARK then
794 Set_Hidden_Part_In_SPARK (Hidden_Region_Start, Token_Ptr);
799 end Scan_Body_Or_Expression_Function;
802 -- Processing for subprogram declaration
804 <<Subprogram_Declaration>>
806 New_Node (N_Subprogram_Declaration, Sloc (Specification_Node));
807 Set_Specification (Decl_Node, Specification_Node);
808 P_Aspect_Specifications (Decl_Node);
810 -- If this is a context in which a subprogram body is permitted,
811 -- set active SIS entry in case (see section titled "Handling
812 -- Semicolon Used in Place of IS" in body of Parser package)
813 -- Note that SIS_Missing_Semicolon_Message is already set properly.
815 if Pf_Flags.Pbod then
816 SIS_Labl := Scope.Table (Scope.Last).Labl;
817 SIS_Sloc := Scope.Table (Scope.Last).Sloc;
818 SIS_Ecol := Scope.Table (Scope.Last).Ecol;
819 SIS_Declaration_Node := Decl_Node;
820 SIS_Semicolon_Sloc := Prev_Token_Ptr;
821 SIS_Entry_Active := True;
828 ---------------------------------
829 -- 6.1 Subprogram Declaration --
830 ---------------------------------
832 -- Parsed by P_Subprogram (6.1)
834 ------------------------------------------
835 -- 6.1 Abstract Subprogram Declaration --
836 ------------------------------------------
838 -- Parsed by P_Subprogram (6.1)
840 -----------------------------------
841 -- 6.1 Subprogram Specification --
842 -----------------------------------
844 -- SUBPROGRAM_SPECIFICATION ::=
845 -- procedure DEFINING_PROGRAM_UNIT_NAME PARAMETER_PROFILE
846 -- | function DEFINING_DESIGNATOR PARAMETER_AND_RESULT_PROFILE
848 -- PARAMETER_PROFILE ::= [FORMAL_PART]
850 -- PARAMETER_AND_RESULT_PROFILE ::= [FORMAL_PART] return SUBTYPE_MARK
852 -- Subprogram specifications that appear in subprogram declarations
853 -- are parsed by P_Subprogram (6.1). This routine is used in other
854 -- contexts where subprogram specifications occur.
856 -- Note: this routine does not affect the scope stack in any way
858 -- Error recovery: can raise Error_Resync
860 function P_Subprogram_Specification return Node_Id is
861 Specification_Node : Node_Id;
862 Result_Not_Null : Boolean;
863 Result_Node : Node_Id;
866 if Token = Tok_Function then
867 Specification_Node := New_Node (N_Function_Specification, Token_Ptr);
868 Scan; -- past FUNCTION
870 Set_Defining_Unit_Name (Specification_Node, P_Defining_Designator);
871 Set_Parameter_Specifications
872 (Specification_Node, P_Parameter_Profile);
873 Check_Junk_Semicolon_Before_Return;
876 Result_Not_Null := P_Null_Exclusion; -- Ada 2005 (AI-231)
878 -- Ada 2005 (AI-318-02)
880 if Token = Tok_Access then
881 if Ada_Version < Ada_2005 then
883 ("anonymous access result type is an Ada 2005 extension");
884 Error_Msg_SC ("\unit must be compiled with -gnat05 switch");
887 Result_Node := P_Access_Definition (Result_Not_Null);
890 Result_Node := P_Subtype_Mark;
894 Set_Null_Exclusion_Present (Specification_Node, Result_Not_Null);
895 Set_Result_Definition (Specification_Node, Result_Node);
896 return Specification_Node;
898 elsif Token = Tok_Procedure then
899 Specification_Node := New_Node (N_Procedure_Specification, Token_Ptr);
900 Scan; -- past PROCEDURE
902 Set_Defining_Unit_Name
903 (Specification_Node, P_Defining_Program_Unit_Name);
904 Set_Parameter_Specifications
905 (Specification_Node, P_Parameter_Profile);
906 return Specification_Node;
909 Error_Msg_SC ("subprogram specification expected");
912 end P_Subprogram_Specification;
914 ---------------------
916 ---------------------
919 -- [PARENT_UNIT_NAME .] IDENTIFIER | OPERATOR_SYMBOL
921 -- The caller has checked that the initial token is an identifier,
922 -- operator symbol, or string literal. Note that we don't bother to
923 -- do much error diagnosis in this routine, since it is only used for
924 -- the label on END lines, and the routines in package Par.Endh will
925 -- check that the label is appropriate.
927 -- Error recovery: cannot raise Error_Resync
929 function P_Designator return Node_Id is
930 Ident_Node : Node_Id;
932 Prefix_Node : Node_Id;
934 function Real_Dot return Boolean;
935 -- Tests if a current token is an interesting period, i.e. is followed
936 -- by an identifier or operator symbol or string literal. If not, it is
937 -- probably just incorrect punctuation to be caught by our caller. Note
938 -- that the case of an operator symbol or string literal is also an
939 -- error, but that is an error that we catch here. If the result is
940 -- True, a real dot has been scanned and we are positioned past it,
941 -- if the result is False, the scan position is unchanged.
947 function Real_Dot return Boolean is
948 Scan_State : Saved_Scan_State;
951 if Token /= Tok_Dot then
955 Save_Scan_State (Scan_State);
958 if Token = Tok_Identifier
959 or else Token = Tok_Operator_Symbol
960 or else Token = Tok_String_Literal
965 Restore_Scan_State (Scan_State);
971 -- Start of processing for P_Designator
974 Ident_Node := Token_Node;
975 Scan; -- past initial token
977 if Prev_Token = Tok_Operator_Symbol
978 or else Prev_Token = Tok_String_Literal
986 Prefix_Node := Ident_Node;
988 -- Loop through child names, on entry to this loop, Prefix contains
989 -- the name scanned so far, and Ident_Node is the last identifier.
992 Name_Node := New_Node (N_Selected_Component, Prev_Token_Ptr);
993 Set_Prefix (Name_Node, Prefix_Node);
994 Ident_Node := P_Identifier;
995 Set_Selector_Name (Name_Node, Ident_Node);
996 Prefix_Node := Name_Node;
997 exit when not Real_Dot;
1000 -- On exit from the loop, Ident_Node is the last identifier scanned,
1001 -- i.e. the defining identifier, and Prefix_Node is a node for the
1002 -- entire name, structured (incorrectly!) as a selected component.
1004 Name_Node := Prefix (Prefix_Node);
1005 Change_Node (Prefix_Node, N_Designator);
1006 Set_Name (Prefix_Node, Name_Node);
1007 Set_Identifier (Prefix_Node, Ident_Node);
1012 when Error_Resync =>
1013 while Token = Tok_Dot or else Token = Tok_Identifier loop
1020 ------------------------------
1021 -- 6.1 Defining Designator --
1022 ------------------------------
1024 -- DEFINING_DESIGNATOR ::=
1025 -- DEFINING_PROGRAM_UNIT_NAME | DEFINING_OPERATOR_SYMBOL
1027 -- Error recovery: cannot raise Error_Resync
1029 function P_Defining_Designator return Node_Id is
1031 if Token = Tok_Operator_Symbol then
1032 return P_Defining_Operator_Symbol;
1034 elsif Token = Tok_String_Literal then
1035 Error_Msg_SC ("invalid operator name");
1036 Scan; -- past junk string
1040 return P_Defining_Program_Unit_Name;
1042 end P_Defining_Designator;
1044 -------------------------------------
1045 -- 6.1 Defining Program Unit Name --
1046 -------------------------------------
1048 -- DEFINING_PROGRAM_UNIT_NAME ::=
1049 -- [PARENT_UNIT_NAME .] DEFINING_IDENTIFIER
1051 -- Note: PARENT_UNIT_NAME may be present only in 95 mode at the outer level
1053 -- Error recovery: cannot raise Error_Resync
1055 function P_Defining_Program_Unit_Name return Node_Id is
1056 Ident_Node : Node_Id;
1057 Name_Node : Node_Id;
1058 Prefix_Node : Node_Id;
1061 -- Set identifier casing if not already set and scan initial identifier
1063 if Token = Tok_Identifier
1064 and then Identifier_Casing (Current_Source_File) = Unknown
1066 Set_Identifier_Casing (Current_Source_File, Determine_Token_Casing);
1069 Ident_Node := P_Identifier (C_Dot);
1070 Merge_Identifier (Ident_Node, Tok_Return);
1072 -- Normal case (not child library unit name)
1074 if Token /= Tok_Dot then
1075 Change_Identifier_To_Defining_Identifier (Ident_Node);
1078 -- Child library unit name case
1081 if Scope.Last > 1 then
1082 Error_Msg_SP ("child unit allowed only at library level");
1085 elsif Ada_Version = Ada_83 then
1086 Error_Msg_SP ("(Ada 83) child unit not allowed!");
1090 Prefix_Node := Ident_Node;
1092 -- Loop through child names, on entry to this loop, Prefix contains
1093 -- the name scanned so far, and Ident_Node is the last identifier.
1096 exit when Token /= Tok_Dot;
1097 Name_Node := New_Node (N_Selected_Component, Token_Ptr);
1098 Scan; -- past period
1099 Set_Prefix (Name_Node, Prefix_Node);
1100 Ident_Node := P_Identifier (C_Dot);
1101 Set_Selector_Name (Name_Node, Ident_Node);
1102 Prefix_Node := Name_Node;
1105 -- On exit from the loop, Ident_Node is the last identifier scanned,
1106 -- i.e. the defining identifier, and Prefix_Node is a node for the
1107 -- entire name, structured (incorrectly!) as a selected component.
1109 Name_Node := Prefix (Prefix_Node);
1110 Change_Node (Prefix_Node, N_Defining_Program_Unit_Name);
1111 Set_Name (Prefix_Node, Name_Node);
1112 Change_Identifier_To_Defining_Identifier (Ident_Node);
1113 Set_Defining_Identifier (Prefix_Node, Ident_Node);
1115 -- All set with unit name parsed
1121 when Error_Resync =>
1122 while Token = Tok_Dot or else Token = Tok_Identifier loop
1127 end P_Defining_Program_Unit_Name;
1129 --------------------------
1130 -- 6.1 Operator Symbol --
1131 --------------------------
1133 -- OPERATOR_SYMBOL ::= STRING_LITERAL
1135 -- Operator symbol is returned by the scanner as Tok_Operator_Symbol
1137 -----------------------------------
1138 -- 6.1 Defining Operator Symbol --
1139 -----------------------------------
1141 -- DEFINING_OPERATOR_SYMBOL ::= OPERATOR_SYMBOL
1143 -- The caller has checked that the initial symbol is an operator symbol
1145 function P_Defining_Operator_Symbol return Node_Id is
1149 Op_Node := Token_Node;
1150 Change_Operator_Symbol_To_Defining_Operator_Symbol (Op_Node);
1151 Scan; -- past operator symbol
1153 end P_Defining_Operator_Symbol;
1155 ----------------------------
1156 -- 6.1 Parameter_Profile --
1157 ----------------------------
1159 -- PARAMETER_PROFILE ::= [FORMAL_PART]
1161 -- Empty is returned if no formal part is present
1163 -- Error recovery: cannot raise Error_Resync
1165 function P_Parameter_Profile return List_Id is
1167 if Token = Tok_Left_Paren then
1168 Scan; -- part left paren
1169 return P_Formal_Part;
1173 end P_Parameter_Profile;
1175 ---------------------------------------
1176 -- 6.1 Parameter And Result Profile --
1177 ---------------------------------------
1179 -- Parsed by its parent construct, which uses P_Parameter_Profile to
1180 -- parse the parameters, and P_Subtype_Mark to parse the return type.
1182 ----------------------
1183 -- 6.1 Formal part --
1184 ----------------------
1186 -- FORMAL_PART ::= (PARAMETER_SPECIFICATION {; PARAMETER_SPECIFICATION})
1188 -- PARAMETER_SPECIFICATION ::=
1189 -- DEFINING_IDENTIFIER_LIST : MODE [NULL_EXCLUSION] SUBTYPE_MARK
1190 -- [:= DEFAULT_EXPRESSION]
1191 -- | DEFINING_IDENTIFIER_LIST : ACCESS_DEFINITION
1192 -- [:= DEFAULT_EXPRESSION]
1194 -- This scans the construct Formal_Part. The caller has already checked
1195 -- that the initial token is a left parenthesis, and skipped past it, so
1196 -- that on entry Token is the first token following the left parenthesis.
1198 -- Error recovery: cannot raise Error_Resync
1200 function P_Formal_Part return List_Id is
1201 Specification_List : List_Id;
1202 Specification_Node : Node_Id;
1203 Scan_State : Saved_Scan_State;
1206 Ident_Sloc : Source_Ptr;
1207 Not_Null_Present : Boolean := False;
1208 Not_Null_Sloc : Source_Ptr;
1210 Idents : array (Int range 1 .. 4096) of Entity_Id;
1211 -- This array holds the list of defining identifiers. The upper bound
1212 -- of 4096 is intended to be essentially infinite, and we do not even
1213 -- bother to check for it being exceeded.
1216 Specification_List := New_List;
1217 Specification_Loop : loop
1219 if Token = Tok_Pragma then
1220 Error_Msg_SC ("pragma not allowed in formal part");
1221 Discard_Junk_Node (P_Pragma (Skipping => True));
1224 Ignore (Tok_Left_Paren);
1225 Ident_Sloc := Token_Ptr;
1226 Idents (1) := P_Defining_Identifier (C_Comma_Colon);
1230 exit Ident_Loop when Token = Tok_Colon;
1232 -- The only valid tokens are colon and comma, so if we have
1233 -- neither do a bit of investigation to see which is the
1234 -- better choice for insertion.
1236 if Token /= Tok_Comma then
1238 -- Assume colon if IN or OUT keyword found
1240 exit Ident_Loop when Token = Tok_In or else Token = Tok_Out;
1242 -- Otherwise scan ahead
1244 Save_Scan_State (Scan_State);
1247 -- If we run into a semicolon, then assume that a
1248 -- colon was missing, e.g. Parms (X Y; ...). Also
1249 -- assume missing colon on EOF (a real disaster!)
1250 -- and on a right paren, e.g. Parms (X Y), and also
1251 -- on an assignment symbol, e.g. Parms (X Y := ..)
1253 if Token = Tok_Semicolon
1254 or else Token = Tok_Right_Paren
1255 or else Token = Tok_EOF
1256 or else Token = Tok_Colon_Equal
1258 Restore_Scan_State (Scan_State);
1261 -- If we run into a colon, assume that we had a missing
1262 -- comma, e.g. Parms (A B : ...). Also assume a missing
1263 -- comma if we hit another comma, e.g. Parms (A B, C ..)
1265 elsif Token = Tok_Colon
1266 or else Token = Tok_Comma
1268 Restore_Scan_State (Scan_State);
1273 end loop Look_Ahead;
1276 -- Here if a comma is present, or to be assumed
1279 Num_Idents := Num_Idents + 1;
1280 Idents (Num_Idents) := P_Defining_Identifier (C_Comma_Colon);
1281 end loop Ident_Loop;
1283 -- Fall through the loop on encountering a colon, or deciding
1284 -- that there is a missing colon.
1288 -- If there are multiple identifiers, we repeatedly scan the
1289 -- type and initialization expression information by resetting
1290 -- the scan pointer (so that we get completely separate trees
1291 -- for each occurrence).
1293 if Num_Idents > 1 then
1294 Save_Scan_State (Scan_State);
1297 -- Loop through defining identifiers in list
1301 Ident_List_Loop : loop
1302 Specification_Node :=
1303 New_Node (N_Parameter_Specification, Ident_Sloc);
1304 Set_Defining_Identifier (Specification_Node, Idents (Ident));
1306 -- Scan possible NOT NULL for Ada 2005 (AI-231, AI-447)
1308 Not_Null_Sloc := Token_Ptr;
1310 P_Null_Exclusion (Allow_Anonymous_In_95 => True);
1312 -- Case of ACCESS keyword present
1314 if Token = Tok_Access then
1315 Set_Null_Exclusion_Present
1316 (Specification_Node, Not_Null_Present);
1318 if Ada_Version = Ada_83 then
1319 Error_Msg_SC ("(Ada 83) access parameters not allowed");
1323 (Specification_Node,
1324 P_Access_Definition (Not_Null_Present));
1326 -- Case of IN or OUT present
1329 if Token = Tok_In or else Token = Tok_Out then
1330 if Not_Null_Present then
1332 ("`NOT NULL` can only be used with `ACCESS`",
1335 if Token = Tok_In then
1337 ("\`IN` not allowed together with `ACCESS`",
1341 ("\`OUT` not allowed together with `ACCESS`",
1346 P_Mode (Specification_Node);
1347 Not_Null_Present := P_Null_Exclusion; -- Ada 2005 (AI-231)
1350 Set_Null_Exclusion_Present
1351 (Specification_Node, Not_Null_Present);
1353 if Token = Tok_Procedure
1355 Token = Tok_Function
1357 Error_Msg_SC ("formal subprogram parameter not allowed");
1360 if Token = Tok_Left_Paren then
1361 Discard_Junk_List (P_Formal_Part);
1364 if Token = Tok_Return then
1366 Discard_Junk_Node (P_Subtype_Mark);
1369 Set_Parameter_Type (Specification_Node, Error);
1372 Set_Parameter_Type (Specification_Node, P_Subtype_Mark);
1377 Set_Expression (Specification_Node, Init_Expr_Opt (True));
1380 Set_Prev_Ids (Specification_Node, True);
1383 if Ident < Num_Idents then
1384 Set_More_Ids (Specification_Node, True);
1387 Append (Specification_Node, Specification_List);
1388 exit Ident_List_Loop when Ident = Num_Idents;
1390 Restore_Scan_State (Scan_State);
1391 end loop Ident_List_Loop;
1394 when Error_Resync =>
1395 Resync_Semicolon_List;
1398 if Token = Tok_Semicolon then
1399 Save_Scan_State (Scan_State);
1400 Scan; -- past semicolon
1402 -- If we have RETURN or IS after the semicolon, then assume
1403 -- that semicolon should have been a right parenthesis and exit
1405 if Token = Tok_Is or else Token = Tok_Return then
1406 Error_Msg_SP -- CODEFIX
1407 ("|"";"" should be "")""");
1408 exit Specification_Loop;
1411 -- If we have a declaration keyword after the semicolon, then
1412 -- assume we had a missing right parenthesis and terminate list
1414 if Token in Token_Class_Declk then
1415 Error_Msg_AP -- CODEFIX
1417 Restore_Scan_State (Scan_State);
1418 exit Specification_Loop;
1421 elsif Token = Tok_Right_Paren then
1422 Scan; -- past right paren
1423 exit Specification_Loop;
1425 -- Special check for common error of using comma instead of semicolon
1427 elsif Token = Tok_Comma then
1431 -- Special check for omitted separator
1433 elsif Token = Tok_Identifier then
1436 -- If nothing sensible, skip to next semicolon or right paren
1440 Resync_Semicolon_List;
1442 if Token = Tok_Semicolon then
1443 Scan; -- past semicolon
1446 exit Specification_Loop;
1449 end loop Specification_Loop;
1451 return Specification_List;
1454 ----------------------------------
1455 -- 6.1 Parameter Specification --
1456 ----------------------------------
1458 -- Parsed by P_Formal_Part (6.1)
1464 -- MODE ::= [in] | in out | out
1466 -- There is no explicit node in the tree for the Mode. Instead the
1467 -- In_Present and Out_Present flags are set in the parent node to
1468 -- record the presence of keywords specifying the mode.
1470 -- Error_Recovery: cannot raise Error_Resync
1472 procedure P_Mode (Node : Node_Id) is
1474 if Token = Tok_In then
1476 Set_In_Present (Node, True);
1478 if Style.Mode_In_Check and then Token /= Tok_Out then
1479 Error_Msg_SP -- CODEFIX
1480 ("(style) IN should be omitted");
1483 if Token = Tok_Access then
1484 Error_Msg_SP ("IN not allowed together with ACCESS");
1485 Scan; -- past ACCESS
1489 if Token = Tok_Out then
1491 Set_Out_Present (Node, True);
1494 if Token = Tok_In then
1495 Error_Msg_SC ("IN must precede OUT in parameter mode");
1497 Set_In_Present (Node, True);
1501 --------------------------
1502 -- 6.3 Subprogram Body --
1503 --------------------------
1505 -- Parsed by P_Subprogram (6.1)
1507 -----------------------------------
1508 -- 6.4 Procedure Call Statement --
1509 -----------------------------------
1511 -- Parsed by P_Sequence_Of_Statements (5.1)
1513 ------------------------
1514 -- 6.4 Function Call --
1515 ------------------------
1517 -- Parsed by P_Name (4.1)
1519 --------------------------------
1520 -- 6.4 Actual Parameter Part --
1521 --------------------------------
1523 -- Parsed by P_Name (4.1)
1525 --------------------------------
1526 -- 6.4 Parameter Association --
1527 --------------------------------
1529 -- Parsed by P_Name (4.1)
1531 ------------------------------------
1532 -- 6.4 Explicit Actual Parameter --
1533 ------------------------------------
1535 -- Parsed by P_Name (4.1)
1537 ---------------------------
1538 -- 6.5 Return Statement --
1539 ---------------------------
1541 -- SIMPLE_RETURN_STATEMENT ::= return [EXPRESSION];
1543 -- EXTENDED_RETURN_STATEMENT ::=
1544 -- return DEFINING_IDENTIFIER : [aliased] RETURN_SUBTYPE_INDICATION
1545 -- [:= EXPRESSION] [do
1546 -- HANDLED_SEQUENCE_OF_STATEMENTS
1549 -- RETURN_SUBTYPE_INDICATION ::= SUBTYPE_INDICATION | ACCESS_DEFINITION
1551 -- RETURN_STATEMENT ::= return [EXPRESSION];
1553 -- Error recovery: can raise Error_Resync
1555 procedure P_Return_Subtype_Indication (Decl_Node : Node_Id) is
1557 -- Note: We don't need to check Ada_Version here, because this is
1558 -- only called in >= Ada 2005 cases anyway.
1560 Not_Null_Present : constant Boolean := P_Null_Exclusion;
1563 Set_Null_Exclusion_Present (Decl_Node, Not_Null_Present);
1565 if Token = Tok_Access then
1566 Set_Object_Definition
1567 (Decl_Node, P_Access_Definition (Not_Null_Present));
1569 Set_Object_Definition
1570 (Decl_Node, P_Subtype_Indication (Not_Null_Present));
1572 end P_Return_Subtype_Indication;
1574 -- Error recovery: can raise Error_Resync
1576 function P_Return_Object_Declaration return Node_Id is
1577 Return_Obj : Node_Id;
1578 Decl_Node : Node_Id;
1581 Return_Obj := Token_Node;
1582 Change_Identifier_To_Defining_Identifier (Return_Obj);
1583 Decl_Node := New_Node (N_Object_Declaration, Token_Ptr);
1584 Set_Defining_Identifier (Decl_Node, Return_Obj);
1586 Scan; -- past identifier
1589 -- First an error check, if we have two identifiers in a row, a likely
1590 -- possibility is that the first of the identifiers is an incorrectly
1591 -- spelled keyword. See similar check in P_Identifier_Declarations.
1593 if Token = Tok_Identifier then
1595 SS : Saved_Scan_State;
1599 Save_Scan_State (SS);
1600 Scan; -- past initial identifier
1601 I2 := (Token = Tok_Identifier);
1602 Restore_Scan_State (SS);
1606 (Bad_Spelling_Of (Tok_Access) or else
1607 Bad_Spelling_Of (Tok_Aliased) or else
1608 Bad_Spelling_Of (Tok_Constant))
1615 -- We allow "constant" here (as in "return Result : constant
1616 -- T..."). This is not in the latest RM, but the ARG is considering an
1617 -- AI on the subject (see AI05-0015-1), which we expect to be approved.
1619 if Token = Tok_Constant then
1620 Scan; -- past CONSTANT
1621 Set_Constant_Present (Decl_Node);
1623 if Token = Tok_Aliased then
1624 Error_Msg_SC -- CODEFIX
1625 ("ALIASED should be before CONSTANT");
1626 Scan; -- past ALIASED
1627 Set_Aliased_Present (Decl_Node);
1630 elsif Token = Tok_Aliased then
1631 Scan; -- past ALIASED
1632 Set_Aliased_Present (Decl_Node);
1634 if Token = Tok_Constant then
1635 Scan; -- past CONSTANT
1636 Set_Constant_Present (Decl_Node);
1640 P_Return_Subtype_Indication (Decl_Node);
1642 if Token = Tok_Colon_Equal then
1644 Set_Expression (Decl_Node, P_Expression_No_Right_Paren);
1648 end P_Return_Object_Declaration;
1650 -- Error recovery: can raise Error_Resync
1652 function P_Return_Statement return Node_Id is
1653 -- The caller has checked that the initial token is RETURN
1655 function Is_Simple return Boolean;
1656 -- Scan state is just after RETURN (and is left that way).
1657 -- Determine whether this is a simple or extended return statement
1658 -- by looking ahead for "identifier :", which implies extended.
1664 function Is_Simple return Boolean is
1665 Scan_State : Saved_Scan_State;
1666 Result : Boolean := True;
1669 if Token = Tok_Identifier then
1670 Save_Scan_State (Scan_State); -- at identifier
1671 Scan; -- past identifier
1673 if Token = Tok_Colon then
1674 Result := False; -- It's an extended_return_statement.
1677 Restore_Scan_State (Scan_State); -- to identifier
1683 Return_Sloc : constant Source_Ptr := Token_Ptr;
1684 Return_Node : Node_Id;
1686 -- Start of processing for P_Return_Statement
1689 Scan; -- past RETURN
1691 -- Simple_return_statement, no expression, return an
1692 -- N_Simple_Return_Statement node with the expression field left Empty.
1694 if Token = Tok_Semicolon then
1696 Return_Node := New_Node (N_Simple_Return_Statement, Return_Sloc);
1701 -- Simple_return_statement with expression
1703 -- We avoid trying to scan an expression if we are at an
1704 -- expression terminator since in that case the best error
1705 -- message is probably that we have a missing semicolon.
1708 Return_Node := New_Node (N_Simple_Return_Statement, Return_Sloc);
1710 if Token not in Token_Class_Eterm then
1711 Set_Expression (Return_Node, P_Expression_No_Right_Paren);
1714 -- Extended_return_statement (Ada 2005 only -- AI-318):
1717 if Ada_Version < Ada_2005 then
1719 (" extended_return_statement is an Ada 2005 extension");
1720 Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
1723 Return_Node := New_Node (N_Extended_Return_Statement, Return_Sloc);
1724 Set_Return_Object_Declarations
1725 (Return_Node, New_List (P_Return_Object_Declaration));
1727 if Token = Tok_Do then
1729 Scope.Table (Scope.Last).Etyp := E_Return;
1730 Scope.Table (Scope.Last).Ecol := Start_Column;
1731 Scope.Table (Scope.Last).Sloc := Return_Sloc;
1734 Set_Handled_Statement_Sequence
1735 (Return_Node, P_Handled_Sequence_Of_Statements);
1738 -- Do we need to handle Error_Resync here???
1746 end P_Return_Statement;