* c-common.c (get_priority): Add check for
[official-gcc.git] / gcc / ada / par-ch6.adb
blobd8f7fdab998900cd9bee41baff8fa220187c0df3
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- P A R . C H 6 --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
10 -- --
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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 pragma Style_Checks (All_Checks);
28 -- Turn off subprogram body ordering check. Subprograms are in order
29 -- by RM section rather than alphabetical
31 with Sinfo.CN; use Sinfo.CN;
33 separate (Par)
34 package body Ch6 is
36 -- Local subprograms, used only in this chapter
38 function P_Defining_Designator return Node_Id;
39 function P_Defining_Operator_Symbol return Node_Id;
40 function P_Return_Object_Declaration return Node_Id;
42 procedure P_Return_Subtype_Indication (Decl_Node : Node_Id);
43 -- Decl_Node is a N_Object_Declaration.
44 -- Set the Null_Exclusion_Present and Object_Definition fields of
45 -- Decl_Node.
47 procedure Check_Junk_Semicolon_Before_Return;
49 -- Check for common error of junk semicolon before RETURN keyword of
50 -- function specification. If present, skip over it with appropriate
51 -- error message, leaving Scan_Ptr pointing to the RETURN after. This
52 -- routine also deals with a possibly misspelled version of Return.
54 ----------------------------------------
55 -- Check_Junk_Semicolon_Before_Return --
56 ----------------------------------------
58 procedure Check_Junk_Semicolon_Before_Return is
59 Scan_State : Saved_Scan_State;
61 begin
62 if Token = Tok_Semicolon then
63 Save_Scan_State (Scan_State);
64 Scan; -- past the semicolon
66 if Token = Tok_Return then
67 Restore_Scan_State (Scan_State);
68 Error_Msg_SC ("unexpected semicolon ignored");
69 Scan; -- rescan past junk semicolon
71 else
72 Restore_Scan_State (Scan_State);
73 end if;
75 elsif Bad_Spelling_Of (Tok_Return) then
76 null;
77 end if;
78 end Check_Junk_Semicolon_Before_Return;
80 -----------------------------------------------------
81 -- 6.1 Subprogram (Also 6.3, 8.5.4, 10.1.3, 12.3) --
82 -----------------------------------------------------
84 -- This routine scans out a subprogram declaration, subprogram body,
85 -- subprogram renaming declaration or subprogram generic instantiation.
87 -- SUBPROGRAM_DECLARATION ::= SUBPROGRAM_SPECIFICATION;
89 -- ABSTRACT_SUBPROGRAM_DECLARATION ::=
90 -- SUBPROGRAM_SPECIFICATION is abstract;
92 -- SUBPROGRAM_SPECIFICATION ::=
93 -- procedure DEFINING_PROGRAM_UNIT_NAME PARAMETER_PROFILE
94 -- | function DEFINING_DESIGNATOR PARAMETER_AND_RESULT_PROFILE
96 -- PARAMETER_PROFILE ::= [FORMAL_PART]
98 -- PARAMETER_AND_RESULT_PROFILE ::= [FORMAL_PART] return SUBTYPE_MARK
100 -- SUBPROGRAM_BODY ::=
101 -- SUBPROGRAM_SPECIFICATION is
102 -- DECLARATIVE_PART
103 -- begin
104 -- HANDLED_SEQUENCE_OF_STATEMENTS
105 -- end [DESIGNATOR];
107 -- SUBPROGRAM_RENAMING_DECLARATION ::=
108 -- SUBPROGRAM_SPECIFICATION renames callable_entity_NAME;
110 -- SUBPROGRAM_BODY_STUB ::=
111 -- SUBPROGRAM_SPECIFICATION is separate;
113 -- GENERIC_INSTANTIATION ::=
114 -- procedure DEFINING_PROGRAM_UNIT_NAME is
115 -- new generic_procedure_NAME [GENERIC_ACTUAL_PART];
116 -- | function DEFINING_DESIGNATOR is
117 -- new generic_function_NAME [GENERIC_ACTUAL_PART];
119 -- NULL_PROCEDURE_DECLARATION ::=
120 -- SUBPROGRAM_SPECIFICATION is null;
122 -- Null procedures are an Ada 2005 feature. A null procedure declaration
123 -- is classified as a basic declarative item, but it is parsed here, with
124 -- other subprogram constructs.
126 -- The value in Pf_Flags indicates which of these possible declarations
127 -- is acceptable to the caller:
129 -- Pf_Flags.Decl Set if declaration OK
130 -- Pf_Flags.Gins Set if generic instantiation OK
131 -- Pf_Flags.Pbod Set if proper body OK
132 -- Pf_Flags.Rnam Set if renaming declaration OK
133 -- Pf_Flags.Stub Set if body stub OK
135 -- If an inappropriate form is encountered, it is scanned out but an
136 -- error message indicating that it is appearing in an inappropriate
137 -- context is issued. The only possible values for Pf_Flags are those
138 -- defined as constants in the Par package.
140 -- The caller has checked that the initial token is FUNCTION, PROCEDURE,
141 -- NOT or OVERRIDING.
143 -- Error recovery: cannot raise Error_Resync
145 function P_Subprogram (Pf_Flags : Pf_Rec) return Node_Id is
146 Specification_Node : Node_Id;
147 Name_Node : Node_Id;
148 Fpart_List : List_Id;
149 Fpart_Sloc : Source_Ptr;
150 Result_Not_Null : Boolean := False;
151 Result_Node : Node_Id;
152 Inst_Node : Node_Id;
153 Body_Node : Node_Id;
154 Decl_Node : Node_Id;
155 Rename_Node : Node_Id;
156 Absdec_Node : Node_Id;
157 Stub_Node : Node_Id;
158 Fproc_Sloc : Source_Ptr;
159 Func : Boolean;
160 Scan_State : Saved_Scan_State;
162 -- Flags for optional overriding indication. Two flags are needed,
163 -- to distinguish positive and negative overriding indicators from
164 -- the absence of any indicator.
166 Is_Overriding : Boolean := False;
167 Not_Overriding : Boolean := False;
169 begin
170 -- Set up scope stack entry. Note that the Labl field will be set later
172 SIS_Entry_Active := False;
173 SIS_Missing_Semicolon_Message := No_Error_Msg;
174 Push_Scope_Stack;
175 Scope.Table (Scope.Last).Sloc := Token_Ptr;
176 Scope.Table (Scope.Last).Etyp := E_Name;
177 Scope.Table (Scope.Last).Ecol := Start_Column;
178 Scope.Table (Scope.Last).Lreq := False;
180 -- Ada2005: scan leading overriding indicator
182 if Token = Tok_Not then
183 Scan; -- past NOT
185 if Token = Tok_Overriding then
186 Scan; -- past OVERRIDING
187 Not_Overriding := True;
188 else
189 Error_Msg_SC ("OVERRIDING expected!");
190 end if;
192 elsif Token = Tok_Overriding then
193 Scan; -- past OVERRIDING
194 Is_Overriding := True;
195 end if;
197 if (Is_Overriding or else Not_Overriding) then
198 if Ada_Version < Ada_05 then
199 Error_Msg_SP (" overriding indicator is an Ada 2005 extension");
200 Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
202 -- An overriding indicator is allowed for subprogram declarations,
203 -- bodies, renamings, stubs, and instantiations.
205 elsif Pf_Flags /= Pf_Decl_Gins_Pbod_Rnam_Stub then
206 Error_Msg_SC ("overriding indicator not allowed here!");
208 elsif Token /= Tok_Function
209 and then Token /= Tok_Procedure
210 then
211 Error_Msg_SC ("FUNCTION or PROCEDURE expected!");
212 end if;
213 end if;
215 Func := (Token = Tok_Function);
216 Fproc_Sloc := Token_Ptr;
217 Scan; -- past FUNCTION or PROCEDURE
218 Ignore (Tok_Type);
219 Ignore (Tok_Body);
221 if Func then
222 Name_Node := P_Defining_Designator;
224 if Nkind (Name_Node) = N_Defining_Operator_Symbol
225 and then Scope.Last = 1
226 then
227 Error_Msg_SP ("operator symbol not allowed at library level");
228 Name_Node := New_Entity (N_Defining_Identifier, Sloc (Name_Node));
230 -- Set name from file name, we need some junk name, and that's
231 -- as good as anything. This is only approximate, since we do
232 -- not do anything with non-standard name translations.
234 Get_Name_String (File_Name (Current_Source_File));
236 for J in 1 .. Name_Len loop
237 if Name_Buffer (J) = '.' then
238 Name_Len := J - 1;
239 exit;
240 end if;
241 end loop;
243 Set_Chars (Name_Node, Name_Find);
244 Set_Error_Posted (Name_Node);
245 end if;
247 else
248 Name_Node := P_Defining_Program_Unit_Name;
249 end if;
251 Scope.Table (Scope.Last).Labl := Name_Node;
253 if Token = Tok_Colon then
254 Error_Msg_SC ("redundant colon ignored");
255 Scan; -- past colon
256 end if;
258 -- Deal with generic instantiation, the one case in which we do not
259 -- have a subprogram specification as part of whatever we are parsing
261 if Token = Tok_Is then
262 Save_Scan_State (Scan_State); -- at the IS
263 T_Is; -- checks for redundant IS
265 if Token = Tok_New then
266 if not Pf_Flags.Gins then
267 Error_Msg_SC ("generic instantation not allowed here!");
268 end if;
270 Scan; -- past NEW
272 if Func then
273 Inst_Node := New_Node (N_Function_Instantiation, Fproc_Sloc);
274 Set_Name (Inst_Node, P_Function_Name);
275 else
276 Inst_Node := New_Node (N_Procedure_Instantiation, Fproc_Sloc);
277 Set_Name (Inst_Node, P_Qualified_Simple_Name);
278 end if;
280 Set_Defining_Unit_Name (Inst_Node, Name_Node);
281 Set_Generic_Associations (Inst_Node, P_Generic_Actual_Part_Opt);
282 TF_Semicolon;
283 Pop_Scope_Stack; -- Don't need scope stack entry in this case
285 if Is_Overriding then
286 Set_Must_Override (Inst_Node);
288 elsif Not_Overriding then
289 Set_Must_Not_Override (Inst_Node);
290 end if;
292 return Inst_Node;
294 else
295 Restore_Scan_State (Scan_State); -- to the IS
296 end if;
297 end if;
299 -- If not a generic instantiation, then we definitely have a subprogram
300 -- specification (all possibilities at this stage include one here)
302 Fpart_Sloc := Token_Ptr;
304 Check_Misspelling_Of (Tok_Return);
306 -- Scan formal part. First a special error check. If we have an
307 -- identifier here, then we have a definite error. If this identifier
308 -- is on the same line as the designator, then we assume it is the
309 -- first formal after a missing left parenthesis
311 if Token = Tok_Identifier
312 and then not Token_Is_At_Start_Of_Line
313 then
314 T_Left_Paren; -- to generate message
315 Fpart_List := P_Formal_Part;
317 -- Otherwise scan out an optional formal part in the usual manner
319 else
320 Fpart_List := P_Parameter_Profile;
321 end if;
323 -- We treat what we have as a function specification if FUNCTION was
324 -- used, or if a RETURN is present. This gives better error recovery
325 -- since later RETURN statements will be valid in either case.
327 Check_Junk_Semicolon_Before_Return;
328 Result_Node := Error;
330 if Token = Tok_Return then
331 if not Func then
332 Error_Msg ("PROCEDURE should be FUNCTION", Fproc_Sloc);
333 Func := True;
334 end if;
336 Scan; -- past RETURN
338 Result_Not_Null := P_Null_Exclusion; -- Ada 2005 (AI-231)
340 -- Ada 2005 (AI-318-02)
342 if Token = Tok_Access then
343 if Ada_Version < Ada_05 then
344 Error_Msg_SC
345 ("anonymous access result type is an Ada 2005 extension");
346 Error_Msg_SC ("\unit must be compiled with -gnat05 switch");
347 end if;
349 Result_Node := P_Access_Definition (Result_Not_Null);
351 else
352 Result_Node := P_Subtype_Mark;
353 No_Constraint;
354 end if;
356 else
357 if Func then
358 Ignore (Tok_Right_Paren);
359 TF_Return;
360 end if;
361 end if;
363 if Func then
364 Specification_Node :=
365 New_Node (N_Function_Specification, Fproc_Sloc);
367 Set_Null_Exclusion_Present (Specification_Node, Result_Not_Null);
368 Set_Result_Definition (Specification_Node, Result_Node);
370 else
371 Specification_Node :=
372 New_Node (N_Procedure_Specification, Fproc_Sloc);
373 end if;
375 Set_Defining_Unit_Name (Specification_Node, Name_Node);
376 Set_Parameter_Specifications (Specification_Node, Fpart_List);
378 if Is_Overriding then
379 Set_Must_Override (Specification_Node);
381 elsif Not_Overriding then
382 Set_Must_Not_Override (Specification_Node);
383 end if;
385 -- Error check: barriers not allowed on protected functions/procedures
387 if Token = Tok_When then
388 if Func then
389 Error_Msg_SC ("barrier not allowed on function, only on entry");
390 else
391 Error_Msg_SC ("barrier not allowed on procedure, only on entry");
392 end if;
394 Scan; -- past WHEN
395 Discard_Junk_Node (P_Expression);
396 end if;
398 -- Deal with case of semicolon ending a subprogram declaration
400 if Token = Tok_Semicolon then
401 if not Pf_Flags.Decl then
402 T_Is;
403 end if;
405 Scan; -- past semicolon
407 -- If semicolon is immediately followed by IS, then ignore the
408 -- semicolon, and go process the body.
410 if Token = Tok_Is then
411 Error_Msg_SP ("unexpected semicolon ignored");
412 T_Is; -- ignroe redundant IS's
413 goto Subprogram_Body;
415 -- If BEGIN follows in an appropriate column, we immediately
416 -- commence the error action of assuming that the previous
417 -- subprogram declaration should have been a subprogram body,
418 -- i.e. that the terminating semicolon should have been IS.
420 elsif Token = Tok_Begin
421 and then Start_Column >= Scope.Table (Scope.Last).Ecol
422 then
423 Error_Msg_SP (""";"" should be IS!");
424 goto Subprogram_Body;
426 else
427 goto Subprogram_Declaration;
428 end if;
430 -- Case of not followed by semicolon
432 else
433 -- Subprogram renaming declaration case
435 Check_Misspelling_Of (Tok_Renames);
437 if Token = Tok_Renames then
438 if not Pf_Flags.Rnam then
439 Error_Msg_SC ("renaming declaration not allowed here!");
440 end if;
442 Rename_Node :=
443 New_Node (N_Subprogram_Renaming_Declaration, Token_Ptr);
444 Scan; -- past RENAMES
445 Set_Name (Rename_Node, P_Name);
446 Set_Specification (Rename_Node, Specification_Node);
447 TF_Semicolon;
448 Pop_Scope_Stack;
449 return Rename_Node;
451 -- Case of IS following subprogram specification
453 elsif Token = Tok_Is then
454 T_Is; -- ignore redundant Is's
456 if Token_Name = Name_Abstract then
457 Check_95_Keyword (Tok_Abstract, Tok_Semicolon);
458 end if;
460 -- Deal nicely with (now obsolete) use of <> in place of abstract
462 if Token = Tok_Box then
463 Error_Msg_SC ("ABSTRACT expected");
464 Token := Tok_Abstract;
465 end if;
467 -- Abstract subprogram declaration case
469 if Token = Tok_Abstract then
470 Absdec_Node :=
471 New_Node (N_Abstract_Subprogram_Declaration, Token_Ptr);
472 Set_Specification (Absdec_Node, Specification_Node);
473 Pop_Scope_Stack; -- discard unneeded entry
474 Scan; -- past ABSTRACT
475 TF_Semicolon;
476 return Absdec_Node;
478 -- Ada 2005 (AI-248): Parse a null procedure declaration
480 elsif Token = Tok_Null then
481 if Ada_Version < Ada_05 then
482 Error_Msg_SP ("null procedures are an Ada 2005 extension");
483 Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
484 end if;
486 Scan; -- past NULL
488 if Func then
489 Error_Msg_SP ("only procedures can be null");
490 else
491 Set_Null_Present (Specification_Node);
492 end if;
494 TF_Semicolon;
495 goto Subprogram_Declaration;
497 -- Check for IS NEW with Formal_Part present and handle nicely
499 elsif Token = Tok_New then
500 Error_Msg
501 ("formal part not allowed in instantiation", Fpart_Sloc);
502 Scan; -- past NEW
504 if Func then
505 Inst_Node := New_Node (N_Function_Instantiation, Fproc_Sloc);
506 else
507 Inst_Node :=
508 New_Node (N_Procedure_Instantiation, Fproc_Sloc);
509 end if;
511 Set_Defining_Unit_Name (Inst_Node, Name_Node);
512 Set_Name (Inst_Node, P_Name);
513 Set_Generic_Associations (Inst_Node, P_Generic_Actual_Part_Opt);
514 TF_Semicolon;
515 Pop_Scope_Stack; -- Don't need scope stack entry in this case
516 return Inst_Node;
518 else
519 goto Subprogram_Body;
520 end if;
522 -- Here we have a missing IS or missing semicolon, we always guess
523 -- a missing semicolon, since we are pretty good at fixing up a
524 -- semicolon which should really be an IS
526 else
527 Error_Msg_AP ("missing "";""");
528 SIS_Missing_Semicolon_Message := Get_Msg_Id;
529 goto Subprogram_Declaration;
530 end if;
531 end if;
533 -- Processing for subprogram body
535 <<Subprogram_Body>>
536 if not Pf_Flags.Pbod then
537 Error_Msg_SP ("subprogram body not allowed here!");
538 end if;
540 -- Subprogram body stub case
542 if Separate_Present then
543 if not Pf_Flags.Stub then
544 Error_Msg_SC ("body stub not allowed here!");
545 end if;
547 if Nkind (Name_Node) = N_Defining_Operator_Symbol then
548 Error_Msg
549 ("operator symbol cannot be used as subunit name",
550 Sloc (Name_Node));
551 end if;
553 Stub_Node :=
554 New_Node (N_Subprogram_Body_Stub, Sloc (Specification_Node));
555 Set_Specification (Stub_Node, Specification_Node);
556 Scan; -- past SEPARATE
557 Pop_Scope_Stack;
558 TF_Semicolon;
559 return Stub_Node;
561 -- Subprogram body case
563 else
564 -- Here is the test for a suspicious IS (i.e. one that looks
565 -- like it might more properly be a semicolon). See separate
566 -- section discussing use of IS instead of semicolon in
567 -- package Parse.
569 if (Token in Token_Class_Declk
570 or else
571 Token = Tok_Identifier)
572 and then Start_Column <= Scope.Table (Scope.Last).Ecol
573 and then Scope.Last /= 1
574 then
575 Scope.Table (Scope.Last).Etyp := E_Suspicious_Is;
576 Scope.Table (Scope.Last).S_Is := Prev_Token_Ptr;
577 end if;
579 Body_Node :=
580 New_Node (N_Subprogram_Body, Sloc (Specification_Node));
581 Set_Specification (Body_Node, Specification_Node);
582 Parse_Decls_Begin_End (Body_Node);
583 return Body_Node;
584 end if;
586 -- Processing for subprogram declaration
588 <<Subprogram_Declaration>>
589 Decl_Node :=
590 New_Node (N_Subprogram_Declaration, Sloc (Specification_Node));
591 Set_Specification (Decl_Node, Specification_Node);
593 -- If this is a context in which a subprogram body is permitted,
594 -- set active SIS entry in case (see section titled "Handling
595 -- Semicolon Used in Place of IS" in body of Parser package)
596 -- Note that SIS_Missing_Semicolon_Message is already set properly.
598 if Pf_Flags.Pbod then
599 SIS_Labl := Scope.Table (Scope.Last).Labl;
600 SIS_Sloc := Scope.Table (Scope.Last).Sloc;
601 SIS_Ecol := Scope.Table (Scope.Last).Ecol;
602 SIS_Declaration_Node := Decl_Node;
603 SIS_Semicolon_Sloc := Prev_Token_Ptr;
604 SIS_Entry_Active := True;
605 end if;
607 Pop_Scope_Stack;
608 return Decl_Node;
610 end P_Subprogram;
612 ---------------------------------
613 -- 6.1 Subprogram Declaration --
614 ---------------------------------
616 -- Parsed by P_Subprogram (6.1)
618 ------------------------------------------
619 -- 6.1 Abstract Subprogram Declaration --
620 ------------------------------------------
622 -- Parsed by P_Subprogram (6.1)
624 -----------------------------------
625 -- 6.1 Subprogram Specification --
626 -----------------------------------
628 -- SUBPROGRAM_SPECIFICATION ::=
629 -- procedure DEFINING_PROGRAM_UNIT_NAME PARAMETER_PROFILE
630 -- | function DEFINING_DESIGNATOR PARAMETER_AND_RESULT_PROFILE
632 -- PARAMETER_PROFILE ::= [FORMAL_PART]
634 -- PARAMETER_AND_RESULT_PROFILE ::= [FORMAL_PART] return SUBTYPE_MARK
636 -- Subprogram specifications that appear in subprogram declarations
637 -- are parsed by P_Subprogram (6.1). This routine is used in other
638 -- contexts where subprogram specifications occur.
640 -- Note: this routine does not affect the scope stack in any way
642 -- Error recovery: can raise Error_Resync
644 function P_Subprogram_Specification return Node_Id is
645 Specification_Node : Node_Id;
646 Result_Not_Null : Boolean;
647 Result_Node : Node_Id;
649 begin
650 if Token = Tok_Function then
651 Specification_Node := New_Node (N_Function_Specification, Token_Ptr);
652 Scan; -- past FUNCTION
653 Ignore (Tok_Body);
654 Set_Defining_Unit_Name (Specification_Node, P_Defining_Designator);
655 Set_Parameter_Specifications
656 (Specification_Node, P_Parameter_Profile);
657 Check_Junk_Semicolon_Before_Return;
658 TF_Return;
660 Result_Not_Null := P_Null_Exclusion; -- Ada 2005 (AI-231)
662 -- Ada 2005 (AI-318-02)
664 if Token = Tok_Access then
665 if Ada_Version < Ada_05 then
666 Error_Msg_SC
667 ("anonymous access result type is an Ada 2005 extension");
668 Error_Msg_SC ("\unit must be compiled with -gnat05 switch");
669 end if;
671 Result_Node := P_Access_Definition (Result_Not_Null);
673 else
674 Result_Node := P_Subtype_Mark;
675 No_Constraint;
676 end if;
678 Set_Null_Exclusion_Present (Specification_Node, Result_Not_Null);
679 Set_Result_Definition (Specification_Node, Result_Node);
680 return Specification_Node;
682 elsif Token = Tok_Procedure then
683 Specification_Node := New_Node (N_Procedure_Specification, Token_Ptr);
684 Scan; -- past PROCEDURE
685 Ignore (Tok_Body);
686 Set_Defining_Unit_Name
687 (Specification_Node, P_Defining_Program_Unit_Name);
688 Set_Parameter_Specifications
689 (Specification_Node, P_Parameter_Profile);
690 return Specification_Node;
692 else
693 Error_Msg_SC ("subprogram specification expected");
694 raise Error_Resync;
695 end if;
696 end P_Subprogram_Specification;
698 ---------------------
699 -- 6.1 Designator --
700 ---------------------
702 -- DESIGNATOR ::=
703 -- [PARENT_UNIT_NAME .] IDENTIFIER | OPERATOR_SYMBOL
705 -- The caller has checked that the initial token is an identifier,
706 -- operator symbol, or string literal. Note that we don't bother to
707 -- do much error diagnosis in this routine, since it is only used for
708 -- the label on END lines, and the routines in package Par.Endh will
709 -- check that the label is appropriate.
711 -- Error recovery: cannot raise Error_Resync
713 function P_Designator return Node_Id is
714 Ident_Node : Node_Id;
715 Name_Node : Node_Id;
716 Prefix_Node : Node_Id;
718 function Real_Dot return Boolean;
719 -- Tests if a current token is an interesting period, i.e. is followed
720 -- by an identifier or operator symbol or string literal. If not, it is
721 -- probably just incorrect punctuation to be caught by our caller. Note
722 -- that the case of an operator symbol or string literal is also an
723 -- error, but that is an error that we catch here. If the result is
724 -- True, a real dot has been scanned and we are positioned past it,
725 -- if the result is False, the scan position is unchanged.
727 --------------
728 -- Real_Dot --
729 --------------
731 function Real_Dot return Boolean is
732 Scan_State : Saved_Scan_State;
734 begin
735 if Token /= Tok_Dot then
736 return False;
738 else
739 Save_Scan_State (Scan_State);
740 Scan; -- past dot
742 if Token = Tok_Identifier
743 or else Token = Tok_Operator_Symbol
744 or else Token = Tok_String_Literal
745 then
746 return True;
748 else
749 Restore_Scan_State (Scan_State);
750 return False;
751 end if;
752 end if;
753 end Real_Dot;
755 -- Start of processing for P_Designator
757 begin
758 Ident_Node := Token_Node;
759 Scan; -- past initial token
761 if Prev_Token = Tok_Operator_Symbol
762 or else Prev_Token = Tok_String_Literal
763 or else not Real_Dot
764 then
765 return Ident_Node;
767 -- Child name case
769 else
770 Prefix_Node := Ident_Node;
772 -- Loop through child names, on entry to this loop, Prefix contains
773 -- the name scanned so far, and Ident_Node is the last identifier.
775 loop
776 Name_Node := New_Node (N_Selected_Component, Prev_Token_Ptr);
777 Set_Prefix (Name_Node, Prefix_Node);
778 Ident_Node := P_Identifier;
779 Set_Selector_Name (Name_Node, Ident_Node);
780 Prefix_Node := Name_Node;
781 exit when not Real_Dot;
782 end loop;
784 -- On exit from the loop, Ident_Node is the last identifier scanned,
785 -- i.e. the defining identifier, and Prefix_Node is a node for the
786 -- entire name, structured (incorrectly!) as a selected component.
788 Name_Node := Prefix (Prefix_Node);
789 Change_Node (Prefix_Node, N_Designator);
790 Set_Name (Prefix_Node, Name_Node);
791 Set_Identifier (Prefix_Node, Ident_Node);
792 return Prefix_Node;
793 end if;
795 exception
796 when Error_Resync =>
797 while Token = Tok_Dot or else Token = Tok_Identifier loop
798 Scan;
799 end loop;
801 return Error;
802 end P_Designator;
804 ------------------------------
805 -- 6.1 Defining Designator --
806 ------------------------------
808 -- DEFINING_DESIGNATOR ::=
809 -- DEFINING_PROGRAM_UNIT_NAME | DEFINING_OPERATOR_SYMBOL
811 -- Error recovery: cannot raise Error_Resync
813 function P_Defining_Designator return Node_Id is
814 begin
815 if Token = Tok_Operator_Symbol then
816 return P_Defining_Operator_Symbol;
818 elsif Token = Tok_String_Literal then
819 Error_Msg_SC ("invalid operator name");
820 Scan; -- past junk string
821 return Error;
823 else
824 return P_Defining_Program_Unit_Name;
825 end if;
826 end P_Defining_Designator;
828 -------------------------------------
829 -- 6.1 Defining Program Unit Name --
830 -------------------------------------
832 -- DEFINING_PROGRAM_UNIT_NAME ::=
833 -- [PARENT_UNIT_NAME .] DEFINING_IDENTIFIER
835 -- Note: PARENT_UNIT_NAME may be present only in 95 mode at the outer level
837 -- Error recovery: cannot raise Error_Resync
839 function P_Defining_Program_Unit_Name return Node_Id is
840 Ident_Node : Node_Id;
841 Name_Node : Node_Id;
842 Prefix_Node : Node_Id;
844 begin
845 -- Set identifier casing if not already set and scan initial identifier
847 if Token = Tok_Identifier
848 and then Identifier_Casing (Current_Source_File) = Unknown
849 then
850 Set_Identifier_Casing (Current_Source_File, Determine_Token_Casing);
851 end if;
853 Ident_Node := P_Identifier (C_Dot);
854 Merge_Identifier (Ident_Node, Tok_Return);
856 -- Normal case (not child library unit name)
858 if Token /= Tok_Dot then
859 Change_Identifier_To_Defining_Identifier (Ident_Node);
860 return Ident_Node;
862 -- Child library unit name case
864 else
865 if Scope.Last > 1 then
866 Error_Msg_SP ("child unit allowed only at library level");
867 raise Error_Resync;
869 elsif Ada_Version = Ada_83 then
870 Error_Msg_SP ("(Ada 83) child unit not allowed!");
872 end if;
874 Prefix_Node := Ident_Node;
876 -- Loop through child names, on entry to this loop, Prefix contains
877 -- the name scanned so far, and Ident_Node is the last identifier.
879 loop
880 exit when Token /= Tok_Dot;
881 Name_Node := New_Node (N_Selected_Component, Token_Ptr);
882 Scan; -- past period
883 Set_Prefix (Name_Node, Prefix_Node);
884 Ident_Node := P_Identifier (C_Dot);
885 Set_Selector_Name (Name_Node, Ident_Node);
886 Prefix_Node := Name_Node;
887 end loop;
889 -- On exit from the loop, Ident_Node is the last identifier scanned,
890 -- i.e. the defining identifier, and Prefix_Node is a node for the
891 -- entire name, structured (incorrectly!) as a selected component.
893 Name_Node := Prefix (Prefix_Node);
894 Change_Node (Prefix_Node, N_Defining_Program_Unit_Name);
895 Set_Name (Prefix_Node, Name_Node);
896 Change_Identifier_To_Defining_Identifier (Ident_Node);
897 Set_Defining_Identifier (Prefix_Node, Ident_Node);
899 -- All set with unit name parsed
901 return Prefix_Node;
902 end if;
904 exception
905 when Error_Resync =>
906 while Token = Tok_Dot or else Token = Tok_Identifier loop
907 Scan;
908 end loop;
910 return Error;
911 end P_Defining_Program_Unit_Name;
913 --------------------------
914 -- 6.1 Operator Symbol --
915 --------------------------
917 -- OPERATOR_SYMBOL ::= STRING_LITERAL
919 -- Operator symbol is returned by the scanner as Tok_Operator_Symbol
921 -----------------------------------
922 -- 6.1 Defining Operator Symbol --
923 -----------------------------------
925 -- DEFINING_OPERATOR_SYMBOL ::= OPERATOR_SYMBOL
927 -- The caller has checked that the initial symbol is an operator symbol
929 function P_Defining_Operator_Symbol return Node_Id is
930 Op_Node : Node_Id;
932 begin
933 Op_Node := Token_Node;
934 Change_Operator_Symbol_To_Defining_Operator_Symbol (Op_Node);
935 Scan; -- past operator symbol
936 return Op_Node;
937 end P_Defining_Operator_Symbol;
939 ----------------------------
940 -- 6.1 Parameter_Profile --
941 ----------------------------
943 -- PARAMETER_PROFILE ::= [FORMAL_PART]
945 -- Empty is returned if no formal part is present
947 -- Error recovery: cannot raise Error_Resync
949 function P_Parameter_Profile return List_Id is
950 begin
951 if Token = Tok_Left_Paren then
952 Scan; -- part left paren
953 return P_Formal_Part;
954 else
955 return No_List;
956 end if;
957 end P_Parameter_Profile;
959 ---------------------------------------
960 -- 6.1 Parameter And Result Profile --
961 ---------------------------------------
963 -- Parsed by its parent construct, which uses P_Parameter_Profile to
964 -- parse the parameters, and P_Subtype_Mark to parse the return type.
966 ----------------------
967 -- 6.1 Formal part --
968 ----------------------
970 -- FORMAL_PART ::= (PARAMETER_SPECIFICATION {; PARAMETER_SPECIFICATION})
972 -- PARAMETER_SPECIFICATION ::=
973 -- DEFINING_IDENTIFIER_LIST : MODE [NULL_EXCLUSION] SUBTYPE_MARK
974 -- [:= DEFAULT_EXPRESSION]
975 -- | DEFINING_IDENTIFIER_LIST : ACCESS_DEFINITION
976 -- [:= DEFAULT_EXPRESSION]
978 -- This scans the construct Formal_Part. The caller has already checked
979 -- that the initial token is a left parenthesis, and skipped past it, so
980 -- that on entry Token is the first token following the left parenthesis.
982 -- Error recovery: cannot raise Error_Resync
984 function P_Formal_Part return List_Id is
985 Specification_List : List_Id;
986 Specification_Node : Node_Id;
987 Scan_State : Saved_Scan_State;
988 Num_Idents : Nat;
989 Ident : Nat;
990 Ident_Sloc : Source_Ptr;
991 Not_Null_Present : Boolean := False;
993 Idents : array (Int range 1 .. 4096) of Entity_Id;
994 -- This array holds the list of defining identifiers. The upper bound
995 -- of 4096 is intended to be essentially infinite, and we do not even
996 -- bother to check for it being exceeded.
998 begin
999 Specification_List := New_List;
1000 Specification_Loop : loop
1001 begin
1002 if Token = Tok_Pragma then
1003 P_Pragmas_Misplaced;
1004 end if;
1006 Ignore (Tok_Left_Paren);
1007 Ident_Sloc := Token_Ptr;
1008 Idents (1) := P_Defining_Identifier (C_Comma_Colon);
1009 Num_Idents := 1;
1011 Ident_Loop : loop
1012 exit Ident_Loop when Token = Tok_Colon;
1014 -- The only valid tokens are colon and comma, so if we have
1015 -- neither do a bit of investigation to see which is the
1016 -- better choice for insertion.
1018 if Token /= Tok_Comma then
1020 -- Assume colon if IN or OUT keyword found
1022 exit Ident_Loop when Token = Tok_In or else Token = Tok_Out;
1024 -- Otherwise scan ahead
1026 Save_Scan_State (Scan_State);
1027 Look_Ahead : loop
1029 -- If we run into a semicolon, then assume that a
1030 -- colon was missing, e.g. Parms (X Y; ...). Also
1031 -- assume missing colon on EOF (a real disaster!)
1032 -- and on a right paren, e.g. Parms (X Y), and also
1033 -- on an assignment symbol, e.g. Parms (X Y := ..)
1035 if Token = Tok_Semicolon
1036 or else Token = Tok_Right_Paren
1037 or else Token = Tok_EOF
1038 or else Token = Tok_Colon_Equal
1039 then
1040 Restore_Scan_State (Scan_State);
1041 exit Ident_Loop;
1043 -- If we run into a colon, assume that we had a missing
1044 -- comma, e.g. Parms (A B : ...). Also assume a missing
1045 -- comma if we hit another comma, e.g. Parms (A B, C ..)
1047 elsif Token = Tok_Colon
1048 or else Token = Tok_Comma
1049 then
1050 Restore_Scan_State (Scan_State);
1051 exit Look_Ahead;
1052 end if;
1054 Scan;
1055 end loop Look_Ahead;
1056 end if;
1058 -- Here if a comma is present, or to be assumed
1060 T_Comma;
1061 Num_Idents := Num_Idents + 1;
1062 Idents (Num_Idents) := P_Defining_Identifier (C_Comma_Colon);
1063 end loop Ident_Loop;
1065 -- Fall through the loop on encountering a colon, or deciding
1066 -- that there is a missing colon.
1068 T_Colon;
1070 -- If there are multiple identifiers, we repeatedly scan the
1071 -- type and initialization expression information by resetting
1072 -- the scan pointer (so that we get completely separate trees
1073 -- for each occurrence).
1075 if Num_Idents > 1 then
1076 Save_Scan_State (Scan_State);
1077 end if;
1079 -- Loop through defining identifiers in list
1081 Ident := 1;
1083 Ident_List_Loop : loop
1084 Specification_Node :=
1085 New_Node (N_Parameter_Specification, Ident_Sloc);
1086 Set_Defining_Identifier (Specification_Node, Idents (Ident));
1087 Not_Null_Present := P_Null_Exclusion; -- Ada 2005 (AI-231)
1089 if Token = Tok_Access then
1090 Set_Null_Exclusion_Present
1091 (Specification_Node, Not_Null_Present);
1093 if Ada_Version = Ada_83 then
1094 Error_Msg_SC ("(Ada 83) access parameters not allowed");
1095 end if;
1097 Set_Parameter_Type (Specification_Node,
1098 P_Access_Definition (Not_Null_Present));
1100 else
1101 if Token = Tok_In or else Token = Tok_Out then
1102 if Not_Null_Present then
1103 Error_Msg_SC
1104 ("ACCESS must be placed after the parameter mode");
1105 end if;
1107 P_Mode (Specification_Node);
1108 Not_Null_Present := P_Null_Exclusion; -- Ada 2005 (AI-231)
1109 end if;
1111 Set_Null_Exclusion_Present
1112 (Specification_Node, Not_Null_Present);
1114 if Token = Tok_Procedure
1115 or else
1116 Token = Tok_Function
1117 then
1118 Error_Msg_SC ("formal subprogram parameter not allowed");
1119 Scan;
1121 if Token = Tok_Left_Paren then
1122 Discard_Junk_List (P_Formal_Part);
1123 end if;
1125 if Token = Tok_Return then
1126 Scan;
1127 Discard_Junk_Node (P_Subtype_Mark);
1128 end if;
1130 Set_Parameter_Type (Specification_Node, Error);
1132 else
1133 Set_Parameter_Type (Specification_Node, P_Subtype_Mark);
1134 No_Constraint;
1135 end if;
1136 end if;
1138 Set_Expression (Specification_Node, Init_Expr_Opt (True));
1140 if Ident > 1 then
1141 Set_Prev_Ids (Specification_Node, True);
1142 end if;
1144 if Ident < Num_Idents then
1145 Set_More_Ids (Specification_Node, True);
1146 end if;
1148 Append (Specification_Node, Specification_List);
1149 exit Ident_List_Loop when Ident = Num_Idents;
1150 Ident := Ident + 1;
1151 Restore_Scan_State (Scan_State);
1152 end loop Ident_List_Loop;
1154 exception
1155 when Error_Resync =>
1156 Resync_Semicolon_List;
1157 end;
1159 if Token = Tok_Semicolon then
1160 Save_Scan_State (Scan_State);
1161 Scan; -- past semicolon
1163 -- If we have RETURN or IS after the semicolon, then assume
1164 -- that semicolon should have been a right parenthesis and exit
1166 if Token = Tok_Is or else Token = Tok_Return then
1167 Error_Msg_SP ("expected "")"" in place of "";""");
1168 exit Specification_Loop;
1169 end if;
1171 -- If we have a declaration keyword after the semicolon, then
1172 -- assume we had a missing right parenthesis and terminate list
1174 if Token in Token_Class_Declk then
1175 Error_Msg_AP ("missing "")""");
1176 Restore_Scan_State (Scan_State);
1177 exit Specification_Loop;
1178 end if;
1180 elsif Token = Tok_Right_Paren then
1181 Scan; -- past right paren
1182 exit Specification_Loop;
1184 -- Special check for common error of using comma instead of semicolon
1186 elsif Token = Tok_Comma then
1187 T_Semicolon;
1188 Scan; -- past comma
1190 -- Special check for omitted separator
1192 elsif Token = Tok_Identifier then
1193 T_Semicolon;
1195 -- If nothing sensible, skip to next semicolon or right paren
1197 else
1198 T_Semicolon;
1199 Resync_Semicolon_List;
1201 if Token = Tok_Semicolon then
1202 Scan; -- past semicolon
1203 else
1204 T_Right_Paren;
1205 exit Specification_Loop;
1206 end if;
1207 end if;
1208 end loop Specification_Loop;
1210 return Specification_List;
1211 end P_Formal_Part;
1213 ----------------------------------
1214 -- 6.1 Parameter Specification --
1215 ----------------------------------
1217 -- Parsed by P_Formal_Part (6.1)
1219 ---------------
1220 -- 6.1 Mode --
1221 ---------------
1223 -- MODE ::= [in] | in out | out
1225 -- There is no explicit node in the tree for the Mode. Instead the
1226 -- In_Present and Out_Present flags are set in the parent node to
1227 -- record the presence of keywords specifying the mode.
1229 -- Error_Recovery: cannot raise Error_Resync
1231 procedure P_Mode (Node : Node_Id) is
1232 begin
1233 if Token = Tok_In then
1234 Scan; -- past IN
1235 Set_In_Present (Node, True);
1237 if Style.Mode_In_Check and then Token /= Tok_Out then
1238 Error_Msg_SP ("(style) IN should be omitted");
1239 end if;
1240 end if;
1242 if Token = Tok_Out then
1243 Scan; -- past OUT
1244 Set_Out_Present (Node, True);
1245 end if;
1247 if Token = Tok_In then
1248 Error_Msg_SC ("IN must preceed OUT in parameter mode");
1249 Scan; -- past IN
1250 Set_In_Present (Node, True);
1251 end if;
1252 end P_Mode;
1254 --------------------------
1255 -- 6.3 Subprogram Body --
1256 --------------------------
1258 -- Parsed by P_Subprogram (6.1)
1260 -----------------------------------
1261 -- 6.4 Procedure Call Statement --
1262 -----------------------------------
1264 -- Parsed by P_Sequence_Of_Statements (5.1)
1266 ------------------------
1267 -- 6.4 Function Call --
1268 ------------------------
1270 -- Parsed by P_Call_Or_Name (4.1)
1272 --------------------------------
1273 -- 6.4 Actual Parameter Part --
1274 --------------------------------
1276 -- Parsed by P_Call_Or_Name (4.1)
1278 --------------------------------
1279 -- 6.4 Parameter Association --
1280 --------------------------------
1282 -- Parsed by P_Call_Or_Name (4.1)
1284 ------------------------------------
1285 -- 6.4 Explicit Actual Parameter --
1286 ------------------------------------
1288 -- Parsed by P_Call_Or_Name (4.1)
1290 ---------------------------
1291 -- 6.5 Return Statement --
1292 ---------------------------
1294 -- SIMPLE_RETURN_STATEMENT ::= return [EXPRESSION];
1296 -- EXTENDED_RETURN_STATEMENT ::=
1297 -- return DEFINING_IDENTIFIER : [aliased] RETURN_SUBTYPE_INDICATION
1298 -- [:= EXPRESSION] [do
1299 -- HANDLED_SEQUENCE_OF_STATEMENTS
1300 -- end return];
1302 -- RETURN_SUBTYPE_INDICATION ::= SUBTYPE_INDICATION | ACCESS_DEFINITION
1304 -- RETURN_STATEMENT ::= return [EXPRESSION];
1306 -- Error recovery: can raise Error_Resync
1308 procedure P_Return_Subtype_Indication (Decl_Node : Node_Id) is
1310 -- Note: We don't need to check Ada_Version here, because this is
1311 -- only called in >= Ada 2005 cases anyway.
1313 Not_Null_Present : constant Boolean := P_Null_Exclusion;
1315 begin
1316 Set_Null_Exclusion_Present (Decl_Node, Not_Null_Present);
1318 if Token = Tok_Access then
1319 Set_Object_Definition
1320 (Decl_Node, P_Access_Definition (Not_Null_Present));
1321 else
1322 Set_Object_Definition
1323 (Decl_Node, P_Subtype_Indication (Not_Null_Present));
1324 end if;
1325 end P_Return_Subtype_Indication;
1327 -- Error recovery: can raise Error_Resync
1329 function P_Return_Object_Declaration return Node_Id is
1330 Return_Obj : Node_Id;
1331 Decl_Node : Node_Id;
1333 begin
1334 Return_Obj := Token_Node;
1335 Change_Identifier_To_Defining_Identifier (Return_Obj);
1336 Decl_Node := New_Node (N_Object_Declaration, Token_Ptr);
1337 Set_Defining_Identifier (Decl_Node, Return_Obj);
1339 Scan; -- past identifier
1340 Scan; -- past :
1342 -- First an error check, if we have two identifiers in a row, a likely
1343 -- possibility is that the first of the identifiers is an incorrectly
1344 -- spelled keyword. See similar check in P_Identifier_Declarations.
1346 if Token = Tok_Identifier then
1347 declare
1348 SS : Saved_Scan_State;
1349 I2 : Boolean;
1351 begin
1352 Save_Scan_State (SS);
1353 Scan; -- past initial identifier
1354 I2 := (Token = Tok_Identifier);
1355 Restore_Scan_State (SS);
1357 if I2
1358 and then
1359 (Bad_Spelling_Of (Tok_Access) or else
1360 Bad_Spelling_Of (Tok_Aliased) or else
1361 Bad_Spelling_Of (Tok_Constant))
1362 then
1363 null;
1364 end if;
1365 end;
1366 end if;
1368 -- We allow "constant" here (as in "return Result : constant
1369 -- T..."). This is not in the latest RM, but the ARG is considering an
1370 -- AI on the subject (see AI05-0015-1), which we expect to be approved.
1372 if Token = Tok_Constant then
1373 Scan; -- past CONSTANT
1374 Set_Constant_Present (Decl_Node);
1376 if Token = Tok_Aliased then
1377 Error_Msg_SC ("ALIASED should be before CONSTANT");
1378 Scan; -- past ALIASED
1379 Set_Aliased_Present (Decl_Node);
1380 end if;
1382 elsif Token = Tok_Aliased then
1383 Scan; -- past ALIASED
1384 Set_Aliased_Present (Decl_Node);
1386 if Token = Tok_Constant then
1387 Scan; -- past CONSTANT
1388 Set_Constant_Present (Decl_Node);
1389 end if;
1390 end if;
1392 P_Return_Subtype_Indication (Decl_Node);
1394 if Token = Tok_Colon_Equal then
1395 Scan; -- past :=
1396 Set_Expression (Decl_Node, P_Expression_No_Right_Paren);
1397 end if;
1399 return Decl_Node;
1400 end P_Return_Object_Declaration;
1402 -- Error recovery: can raise Error_Resync
1404 function P_Return_Statement return Node_Id is
1405 -- The caller has checked that the initial token is RETURN
1407 function Is_Simple return Boolean;
1408 -- Scan state is just after RETURN (and is left that way).
1409 -- Determine whether this is a simple or extended return statement
1410 -- by looking ahead for "identifier :", which implies extended.
1412 ---------------
1413 -- Is_Simple --
1414 ---------------
1416 function Is_Simple return Boolean is
1417 Scan_State : Saved_Scan_State;
1418 Result : Boolean := True;
1420 begin
1421 if Token = Tok_Identifier then
1422 Save_Scan_State (Scan_State); -- at identifier
1423 Scan; -- past identifier
1425 if Token = Tok_Colon then
1426 Result := False; -- It's an extended_return_statement.
1427 end if;
1429 Restore_Scan_State (Scan_State); -- to identifier
1430 end if;
1432 return Result;
1433 end Is_Simple;
1435 Return_Sloc : constant Source_Ptr := Token_Ptr;
1436 Return_Node : Node_Id;
1438 -- Start of processing for P_Return_Statement
1440 begin
1441 Scan; -- past RETURN
1443 -- Simple_return_statement, no expression, return an N_Return_Statement
1444 -- node with the expression field left Empty.
1446 if Token = Tok_Semicolon then
1447 Scan; -- past ;
1448 Return_Node := New_Node (N_Return_Statement, Return_Sloc);
1450 -- Non-simple case
1452 else
1453 -- Simple_return_statement with expression
1455 -- We avoid trying to scan an expression if we are at an
1456 -- expression terminator since in that case the best error
1457 -- message is probably that we have a missing semicolon.
1459 if Is_Simple then
1460 Return_Node := New_Node (N_Return_Statement, Return_Sloc);
1462 if Token not in Token_Class_Eterm then
1463 Set_Expression (Return_Node, P_Expression_No_Right_Paren);
1464 end if;
1466 -- Extended_return_statement (Ada 2005 only -- AI-318):
1468 else
1469 if Ada_Version < Ada_05 then
1470 Error_Msg_SP
1471 (" extended_return_statement is an Ada 2005 extension");
1472 Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
1473 end if;
1475 Return_Node := New_Node (N_Extended_Return_Statement, Return_Sloc);
1476 Set_Return_Object_Declarations
1477 (Return_Node, New_List (P_Return_Object_Declaration));
1479 if Token = Tok_Do then
1480 Push_Scope_Stack;
1481 Scope.Table (Scope.Last).Etyp := E_Return;
1482 Scope.Table (Scope.Last).Ecol := Start_Column;
1483 Scope.Table (Scope.Last).Sloc := Return_Sloc;
1485 Scan; -- past DO
1486 Set_Handled_Statement_Sequence
1487 (Return_Node, P_Handled_Sequence_Of_Statements);
1488 End_Statements;
1490 -- Do we need to handle Error_Resync here???
1491 end if;
1492 end if;
1494 TF_Semicolon;
1495 end if;
1497 return Return_Node;
1498 end P_Return_Statement;
1500 end Ch6;