* contrib-list.mk (LIST): Remove arm-freebsd6, arm-linux,
[official-gcc.git] / gcc / ada / par-ch13.adb
blobd3ed8515c388a0d6b4b5b89b6e98c69a2314bb77
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- P A R . C H 1 3 --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2012, 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 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. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
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 separate (Par)
31 package body Ch13 is
33 -- Local functions, used only in this chapter
35 function P_Component_Clause return Node_Id;
36 function P_Mod_Clause return Node_Id;
38 -----------------------------------
39 -- Aspect_Specifications_Present --
40 -----------------------------------
42 function Aspect_Specifications_Present
43 (Strict : Boolean := Ada_Version < Ada_2012) return Boolean
45 Scan_State : Saved_Scan_State;
46 Result : Boolean;
48 begin
49 -- Definitely must have WITH to consider aspect specs to be present
51 -- Note that this means that if we have a semicolon, we immediately
52 -- return False. There is a case in which this is not optimal, namely
53 -- something like
55 -- type R is new Integer;
56 -- with bla bla;
58 -- where the semicolon is redundant, but scanning forward for it would
59 -- be too expensive. Instead we pick up the aspect specifications later
60 -- as a bogus declaration, and diagnose the semicolon at that point.
62 if Token /= Tok_With then
63 return False;
64 end if;
66 -- Have a WITH, see if it looks like an aspect specification
68 Save_Scan_State (Scan_State);
69 Scan; -- past WITH
71 -- If no identifier, then consider that we definitely do not have an
72 -- aspect specification.
74 if Token /= Tok_Identifier then
75 Result := False;
77 -- This is where we pay attention to the Strict mode. Normally when we
78 -- are in Ada 2012 mode, Strict is False, and we consider that we have
79 -- an aspect specification if the identifier is an aspect name (even if
80 -- not followed by =>) or the identifier is not an aspect name but is
81 -- followed by =>. P_Aspect_Specifications will generate messages if the
82 -- aspect specification is ill-formed.
84 elsif not Strict then
85 if Get_Aspect_Id (Token_Name) /= No_Aspect then
86 Result := True;
87 else
88 Scan; -- past identifier
89 Result := Token = Tok_Arrow;
90 end if;
92 -- If earlier than Ada 2012, check for valid aspect identifier (possibly
93 -- completed with 'CLASS) followed by an arrow, and consider that this
94 -- is still an aspect specification so we give an appropriate message.
96 else
97 if Get_Aspect_Id (Token_Name) = No_Aspect then
98 Result := False;
100 else
101 Scan; -- past aspect name
103 Result := False;
105 if Token = Tok_Arrow then
106 Result := True;
108 elsif Token = Tok_Apostrophe then
109 Scan; -- past apostrophe
111 if Token = Tok_Identifier
112 and then Token_Name = Name_Class
113 then
114 Scan; -- past CLASS
116 if Token = Tok_Arrow then
117 Result := True;
118 end if;
119 end if;
120 end if;
122 if Result then
123 Restore_Scan_State (Scan_State);
124 Error_Msg_SC ("|aspect specification is an Ada 2012 feature");
125 Error_Msg_SC ("\|unit must be compiled with -gnat2012 switch");
126 return True;
127 end if;
128 end if;
129 end if;
131 Restore_Scan_State (Scan_State);
132 return Result;
133 end Aspect_Specifications_Present;
135 -------------------------------
136 -- Get_Aspect_Specifications --
137 -------------------------------
139 function Get_Aspect_Specifications
140 (Semicolon : Boolean := True) return List_Id
142 Aspects : List_Id;
143 Aspect : Node_Id;
144 A_Id : Aspect_Id;
145 OK : Boolean;
147 begin
148 Aspects := Empty_List;
150 -- Check if aspect specification present
152 if not Aspect_Specifications_Present then
153 if Semicolon then
154 TF_Semicolon;
155 end if;
157 return Aspects;
158 end if;
160 Scan; -- past WITH
161 Aspects := Empty_List;
163 loop
164 OK := True;
166 if Token /= Tok_Identifier then
167 Error_Msg_SC ("aspect identifier expected");
169 if Semicolon then
170 Resync_Past_Semicolon;
171 end if;
173 return Aspects;
174 end if;
176 -- We have an identifier (which should be an aspect identifier)
178 A_Id := Get_Aspect_Id (Token_Name);
179 Aspect :=
180 Make_Aspect_Specification (Token_Ptr,
181 Identifier => Token_Node);
183 -- No valid aspect identifier present
185 if A_Id = No_Aspect then
186 Error_Msg_SC ("aspect identifier expected");
188 -- Check bad spelling
190 for J in Aspect_Id_Exclude_No_Aspect loop
191 if Is_Bad_Spelling_Of (Token_Name, Aspect_Names (J)) then
192 Error_Msg_Name_1 := Aspect_Names (J);
193 Error_Msg_SC -- CODEFIX
194 ("\possible misspelling of%");
195 exit;
196 end if;
197 end loop;
199 Scan; -- past incorrect identifier
201 if Token = Tok_Apostrophe then
202 Scan; -- past '
203 Scan; -- past presumably CLASS
204 end if;
206 if Token = Tok_Arrow then
207 Scan; -- Past arrow
208 Set_Expression (Aspect, P_Expression);
209 OK := False;
211 elsif Token = Tok_Comma then
212 OK := False;
214 else
215 if Semicolon then
216 Resync_Past_Semicolon;
217 end if;
219 return Aspects;
220 end if;
222 -- OK aspect scanned
224 else
225 Scan; -- past identifier
227 -- Check for 'Class present
229 if Token = Tok_Apostrophe then
230 if not Class_Aspect_OK (A_Id) then
231 Error_Msg_Node_1 := Identifier (Aspect);
232 Error_Msg_SC ("aspect& does not permit attribute here");
233 Scan; -- past apostrophe
234 Scan; -- past presumed CLASS
235 OK := False;
237 else
238 Scan; -- past apostrophe
240 if Token /= Tok_Identifier
241 or else Token_Name /= Name_Class
242 then
243 Error_Msg_SC ("Class attribute expected here");
244 OK := False;
246 if Token = Tok_Identifier then
247 Scan; -- past identifier not CLASS
248 end if;
250 else
251 Scan; -- past CLASS
252 Set_Class_Present (Aspect);
253 end if;
254 end if;
255 end if;
257 -- Test case of missing aspect definition
259 if Token = Tok_Comma
260 or else Token = Tok_Semicolon
261 then
262 if Aspect_Argument (A_Id) /= Optional then
263 Error_Msg_Node_1 := Identifier (Aspect);
264 Error_Msg_AP ("aspect& requires an aspect definition");
265 OK := False;
266 end if;
268 elsif not Semicolon and then Token /= Tok_Arrow then
269 if Aspect_Argument (A_Id) /= Optional then
271 -- The name or expression may be there, but the arrow is
272 -- missing. Skip to the end of the declaration.
274 T_Arrow;
275 Resync_To_Semicolon;
276 end if;
278 -- Here we have an aspect definition
280 else
281 if Token = Tok_Arrow then
282 Scan; -- past arrow
283 else
284 T_Arrow;
285 OK := False;
286 end if;
288 if Aspect_Argument (A_Id) = Name then
289 Set_Expression (Aspect, P_Name);
290 else
291 Set_Expression (Aspect, P_Expression);
292 end if;
293 end if;
295 -- If OK clause scanned, add it to the list
297 if OK then
298 Append (Aspect, Aspects);
299 end if;
301 if Token = Tok_Comma then
302 Scan; -- past comma
303 goto Continue;
305 -- Recognize the case where a comma is missing between two
306 -- aspects, issue an error and proceed with next aspect.
308 elsif Token = Tok_Identifier
309 and then Get_Aspect_Id (Token_Name) /= No_Aspect
310 then
311 declare
312 Scan_State : Saved_Scan_State;
314 begin
315 Save_Scan_State (Scan_State);
316 Scan; -- past identifier
318 if Token = Tok_Arrow then
319 Restore_Scan_State (Scan_State);
320 Error_Msg_AP -- CODEFIX
321 ("|missing "",""");
322 goto Continue;
324 else
325 Restore_Scan_State (Scan_State);
326 end if;
327 end;
329 -- Recognize the case where a semicolon was mistyped for a comma
330 -- between two aspects, issue an error and proceed with next
331 -- aspect.
333 elsif Token = Tok_Semicolon then
334 declare
335 Scan_State : Saved_Scan_State;
337 begin
338 Save_Scan_State (Scan_State);
339 Scan; -- past semicolon
341 if Token = Tok_Identifier
342 and then Get_Aspect_Id (Token_Name) /= No_Aspect
343 then
344 Scan; -- past identifier
346 if Token = Tok_Arrow then
347 Restore_Scan_State (Scan_State);
348 Error_Msg_SC -- CODEFIX
349 ("|"";"" should be "",""");
350 Scan; -- past semicolon
351 goto Continue;
353 else
354 Restore_Scan_State (Scan_State);
355 end if;
357 else
358 Restore_Scan_State (Scan_State);
359 end if;
360 end;
361 end if;
363 -- Must be terminator character
365 if Semicolon then
366 T_Semicolon;
367 end if;
369 exit;
371 <<Continue>>
372 null;
373 end if;
374 end loop;
376 return Aspects;
378 end Get_Aspect_Specifications;
380 --------------------------------------------
381 -- 13.1 Representation Clause (also I.7) --
382 --------------------------------------------
384 -- REPRESENTATION_CLAUSE ::=
385 -- ATTRIBUTE_DEFINITION_CLAUSE
386 -- | ENUMERATION_REPRESENTATION_CLAUSE
387 -- | RECORD_REPRESENTATION_CLAUSE
388 -- | AT_CLAUSE
390 -- ATTRIBUTE_DEFINITION_CLAUSE ::=
391 -- for LOCAL_NAME'ATTRIBUTE_DESIGNATOR use EXPRESSION;
392 -- | for LOCAL_NAME'ATTRIBUTE_DESIGNATOR use NAME;
394 -- Note: in Ada 83, the expression must be a simple expression
396 -- AT_CLAUSE ::= for DIRECT_NAME use at EXPRESSION;
398 -- Note: in Ada 83, the expression must be a simple expression
400 -- ENUMERATION_REPRESENTATION_CLAUSE ::=
401 -- for first_subtype_LOCAL_NAME use ENUMERATION_AGGREGATE;
403 -- ENUMERATION_AGGREGATE ::= ARRAY_AGGREGATE
405 -- RECORD_REPRESENTATION_CLAUSE ::=
406 -- for first_subtype_LOCAL_NAME use
407 -- record [MOD_CLAUSE]
408 -- {COMPONENT_CLAUSE}
409 -- end record;
411 -- Note: for now we allow only a direct name as the local name in the
412 -- above constructs. This probably needs changing later on ???
414 -- The caller has checked that the initial token is FOR
416 -- Error recovery: cannot raise Error_Resync, if an error occurs,
417 -- the scan is repositioned past the next semicolon.
419 function P_Representation_Clause return Node_Id is
420 For_Loc : Source_Ptr;
421 Name_Node : Node_Id;
422 Prefix_Node : Node_Id;
423 Attr_Name : Name_Id;
424 Identifier_Node : Node_Id;
425 Rep_Clause_Node : Node_Id;
426 Expr_Node : Node_Id;
427 Record_Items : List_Id;
429 begin
430 For_Loc := Token_Ptr;
431 Scan; -- past FOR
433 -- Note that the name in a representation clause is always a simple
434 -- name, even in the attribute case, see AI-300 which made this so!
436 Identifier_Node := P_Identifier (C_Use);
438 -- Check case of qualified name to give good error message
440 if Token = Tok_Dot then
441 Error_Msg_SC
442 ("representation clause requires simple name!");
444 loop
445 exit when Token /= Tok_Dot;
446 Scan; -- past dot
447 Discard_Junk_Node (P_Identifier);
448 end loop;
449 end if;
451 -- Attribute Definition Clause
453 if Token = Tok_Apostrophe then
455 -- Allow local names of the form a'b'.... This enables
456 -- us to parse class-wide streams attributes correctly.
458 Name_Node := Identifier_Node;
459 while Token = Tok_Apostrophe loop
461 Scan; -- past apostrophe
463 Identifier_Node := Token_Node;
464 Attr_Name := No_Name;
466 if Token = Tok_Identifier then
467 Attr_Name := Token_Name;
469 -- Note that the parser must complain in case of an internal
470 -- attribute name that comes from source since internal names
471 -- are meant to be used only by the compiler.
473 if not Is_Attribute_Name (Attr_Name)
474 and then (not Is_Internal_Attribute_Name (Attr_Name)
475 or else Comes_From_Source (Token_Node))
476 then
477 Signal_Bad_Attribute;
478 end if;
480 if Style_Check then
481 Style.Check_Attribute_Name (False);
482 end if;
484 -- Here for case of attribute designator is not an identifier
486 else
487 if Token = Tok_Delta then
488 Attr_Name := Name_Delta;
490 elsif Token = Tok_Digits then
491 Attr_Name := Name_Digits;
493 elsif Token = Tok_Access then
494 Attr_Name := Name_Access;
496 else
497 Error_Msg_AP ("attribute designator expected");
498 raise Error_Resync;
499 end if;
501 if Style_Check then
502 Style.Check_Attribute_Name (True);
503 end if;
504 end if;
506 -- We come here with an OK attribute scanned, and the
507 -- corresponding Attribute identifier node stored in Ident_Node.
509 Prefix_Node := Name_Node;
510 Name_Node := New_Node (N_Attribute_Reference, Prev_Token_Ptr);
511 Set_Prefix (Name_Node, Prefix_Node);
512 Set_Attribute_Name (Name_Node, Attr_Name);
513 Scan;
514 end loop;
516 Rep_Clause_Node := New_Node (N_Attribute_Definition_Clause, For_Loc);
517 Set_Name (Rep_Clause_Node, Prefix_Node);
518 Set_Chars (Rep_Clause_Node, Attr_Name);
519 T_Use;
521 Expr_Node := P_Expression_No_Right_Paren;
522 Check_Simple_Expression_In_Ada_83 (Expr_Node);
523 Set_Expression (Rep_Clause_Node, Expr_Node);
525 else
526 TF_Use;
527 Rep_Clause_Node := Empty;
529 -- AT follows USE (At Clause)
531 if Token = Tok_At then
532 Scan; -- past AT
533 Rep_Clause_Node := New_Node (N_At_Clause, For_Loc);
534 Set_Identifier (Rep_Clause_Node, Identifier_Node);
535 Expr_Node := P_Expression_No_Right_Paren;
536 Check_Simple_Expression_In_Ada_83 (Expr_Node);
537 Set_Expression (Rep_Clause_Node, Expr_Node);
539 -- RECORD follows USE (Record Representation Clause)
541 elsif Token = Tok_Record then
542 Record_Items := P_Pragmas_Opt;
543 Rep_Clause_Node :=
544 New_Node (N_Record_Representation_Clause, For_Loc);
545 Set_Identifier (Rep_Clause_Node, Identifier_Node);
547 Push_Scope_Stack;
548 Scope.Table (Scope.Last).Etyp := E_Record;
549 Scope.Table (Scope.Last).Ecol := Start_Column;
550 Scope.Table (Scope.Last).Sloc := Token_Ptr;
551 Scan; -- past RECORD
552 Record_Items := P_Pragmas_Opt;
554 -- Possible Mod Clause
556 if Token = Tok_At then
557 Set_Mod_Clause (Rep_Clause_Node, P_Mod_Clause);
558 Set_Pragmas_Before (Mod_Clause (Rep_Clause_Node), Record_Items);
559 Record_Items := P_Pragmas_Opt;
560 end if;
562 if No (Record_Items) then
563 Record_Items := New_List;
564 end if;
566 Set_Component_Clauses (Rep_Clause_Node, Record_Items);
568 -- Loop through component clauses
570 loop
571 if Token not in Token_Class_Name then
572 exit when Check_End;
573 end if;
575 Append (P_Component_Clause, Record_Items);
576 P_Pragmas_Opt (Record_Items);
577 end loop;
579 -- Left paren follows USE (Enumeration Representation Clause)
581 elsif Token = Tok_Left_Paren then
582 Rep_Clause_Node :=
583 New_Node (N_Enumeration_Representation_Clause, For_Loc);
584 Set_Identifier (Rep_Clause_Node, Identifier_Node);
585 Set_Array_Aggregate (Rep_Clause_Node, P_Aggregate);
587 -- Some other token follows FOR (invalid representation clause)
589 else
590 Error_Msg_SC ("invalid representation clause");
591 raise Error_Resync;
592 end if;
593 end if;
595 TF_Semicolon;
596 return Rep_Clause_Node;
598 exception
599 when Error_Resync =>
600 Resync_Past_Semicolon;
601 return Error;
603 end P_Representation_Clause;
605 ----------------------
606 -- 13.1 Local Name --
607 ----------------------
609 -- Local name is always parsed by its parent. In the case of its use in
610 -- pragmas, the check for a local name is handled in Par.Prag and allows
611 -- all the possible forms of local name. For the uses in chapter 13, we
612 -- currently only allow a direct name, but this should probably change???
614 ---------------------------
615 -- 13.1 At Clause (I.7) --
616 ---------------------------
618 -- Parsed by P_Representation_Clause (13.1)
620 ---------------------------------------
621 -- 13.3 Attribute Definition Clause --
622 ---------------------------------------
624 -- Parsed by P_Representation_Clause (13.1)
626 --------------------------------
627 -- 13.1 Aspect Specification --
628 --------------------------------
630 -- ASPECT_SPECIFICATION ::=
631 -- with ASPECT_MARK [=> ASPECT_DEFINITION] {,
632 -- ASPECT_MARK [=> ASPECT_DEFINITION] }
634 -- ASPECT_MARK ::= aspect_IDENTIFIER['Class]
636 -- ASPECT_DEFINITION ::= NAME | EXPRESSION
638 -- Error recovery: cannot raise Error_Resync
640 procedure P_Aspect_Specifications
641 (Decl : Node_Id;
642 Semicolon : Boolean := True)
644 Aspects : List_Id;
645 Ptr : Source_Ptr;
647 begin
648 -- Aspect Specification is present
650 Ptr := Token_Ptr;
652 -- Here we have an aspect specification to scan, note that we don't
653 -- set the flag till later, because it may turn out that we have no
654 -- valid aspects in the list.
656 Aspects := Get_Aspect_Specifications (Semicolon);
658 -- Here if aspects present
660 if Is_Non_Empty_List (Aspects) then
662 -- If Decl is Empty, we just ignore the aspects (the caller in this
663 -- case has always issued an appropriate error message).
665 if Decl = Empty then
666 null;
668 -- If Decl is Error, we ignore the aspects, and issue a message
670 elsif Decl = Error then
671 Error_Msg ("aspect specifications not allowed here", Ptr);
673 -- Here aspects are allowed, and we store them
675 else
676 Set_Parent (Aspects, Decl);
677 Set_Aspect_Specifications (Decl, Aspects);
678 end if;
679 end if;
680 end P_Aspect_Specifications;
682 ---------------------------------------------
683 -- 13.4 Enumeration Representation Clause --
684 ---------------------------------------------
686 -- Parsed by P_Representation_Clause (13.1)
688 ---------------------------------
689 -- 13.4 Enumeration Aggregate --
690 ---------------------------------
692 -- Parsed by P_Representation_Clause (13.1)
694 ------------------------------------------
695 -- 13.5.1 Record Representation Clause --
696 ------------------------------------------
698 -- Parsed by P_Representation_Clause (13.1)
700 ------------------------------
701 -- 13.5.1 Mod Clause (I.8) --
702 ------------------------------
704 -- MOD_CLAUSE ::= at mod static_EXPRESSION;
706 -- Note: in Ada 83, the expression must be a simple expression
708 -- The caller has checked that the initial Token is AT
710 -- Error recovery: cannot raise Error_Resync
712 -- Note: the caller is responsible for setting the Pragmas_Before field
714 function P_Mod_Clause return Node_Id is
715 Mod_Node : Node_Id;
716 Expr_Node : Node_Id;
718 begin
719 Mod_Node := New_Node (N_Mod_Clause, Token_Ptr);
720 Scan; -- past AT
721 T_Mod;
722 Expr_Node := P_Expression_No_Right_Paren;
723 Check_Simple_Expression_In_Ada_83 (Expr_Node);
724 Set_Expression (Mod_Node, Expr_Node);
725 TF_Semicolon;
726 return Mod_Node;
727 end P_Mod_Clause;
729 ------------------------------
730 -- 13.5.1 Component Clause --
731 ------------------------------
733 -- COMPONENT_CLAUSE ::=
734 -- COMPONENT_CLAUSE_COMPONENT_NAME at POSITION
735 -- range FIRST_BIT .. LAST_BIT;
737 -- COMPONENT_CLAUSE_COMPONENT_NAME ::=
738 -- component_DIRECT_NAME
739 -- | component_DIRECT_NAME'ATTRIBUTE_DESIGNATOR
740 -- | FIRST_SUBTYPE_DIRECT_NAME'ATTRIBUTE_DESIGNATOR
742 -- POSITION ::= static_EXPRESSION
744 -- Note: in Ada 83, the expression must be a simple expression
746 -- FIRST_BIT ::= static_SIMPLE_EXPRESSION
747 -- LAST_BIT ::= static_SIMPLE_EXPRESSION
749 -- Note: the AARM V2.0 grammar has an error at this point, it uses
750 -- EXPRESSION instead of SIMPLE_EXPRESSION for FIRST_BIT and LAST_BIT
752 -- Error recovery: cannot raise Error_Resync
754 function P_Component_Clause return Node_Id is
755 Component_Node : Node_Id;
756 Comp_Name : Node_Id;
757 Expr_Node : Node_Id;
759 begin
760 Component_Node := New_Node (N_Component_Clause, Token_Ptr);
761 Comp_Name := P_Name;
763 if Nkind (Comp_Name) = N_Identifier
764 or else Nkind (Comp_Name) = N_Attribute_Reference
765 then
766 Set_Component_Name (Component_Node, Comp_Name);
767 else
768 Error_Msg_N
769 ("component name must be direct name or attribute", Comp_Name);
770 Set_Component_Name (Component_Node, Error);
771 end if;
773 Set_Sloc (Component_Node, Token_Ptr);
774 T_At;
775 Expr_Node := P_Expression_No_Right_Paren;
776 Check_Simple_Expression_In_Ada_83 (Expr_Node);
777 Set_Position (Component_Node, Expr_Node);
778 T_Range;
779 Expr_Node := P_Expression_No_Right_Paren;
780 Check_Simple_Expression_In_Ada_83 (Expr_Node);
781 Set_First_Bit (Component_Node, Expr_Node);
782 T_Dot_Dot;
783 Expr_Node := P_Expression_No_Right_Paren;
784 Check_Simple_Expression_In_Ada_83 (Expr_Node);
785 Set_Last_Bit (Component_Node, Expr_Node);
786 TF_Semicolon;
787 return Component_Node;
788 end P_Component_Clause;
790 ----------------------
791 -- 13.5.1 Position --
792 ----------------------
794 -- Parsed by P_Component_Clause (13.5.1)
796 -----------------------
797 -- 13.5.1 First Bit --
798 -----------------------
800 -- Parsed by P_Component_Clause (13.5.1)
802 ----------------------
803 -- 13.5.1 Last Bit --
804 ----------------------
806 -- Parsed by P_Component_Clause (13.5.1)
808 --------------------------
809 -- 13.8 Code Statement --
810 --------------------------
812 -- CODE_STATEMENT ::= QUALIFIED_EXPRESSION
814 -- On entry the caller has scanned the SUBTYPE_MARK (passed in as the
815 -- single argument, and the scan points to the apostrophe.
817 -- Error recovery: can raise Error_Resync
819 function P_Code_Statement (Subtype_Mark : Node_Id) return Node_Id is
820 Node1 : Node_Id;
822 begin
823 Scan; -- past apostrophe
825 -- If left paren, then we have a possible code statement
827 if Token = Tok_Left_Paren then
828 Node1 := New_Node (N_Code_Statement, Sloc (Subtype_Mark));
829 Set_Expression (Node1, P_Qualified_Expression (Subtype_Mark));
830 TF_Semicolon;
831 return Node1;
833 -- Otherwise we have an illegal range attribute. Note that P_Name
834 -- ensures that Token = Tok_Range is the only possibility left here.
836 else
837 Error_Msg_SC ("RANGE attribute illegal here!");
838 raise Error_Resync;
839 end if;
840 end P_Code_Statement;
842 end Ch13;