1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2020, 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 with Rident
; use Rident
;
27 with Restrict
; use Restrict
;
28 pragma Style_Checks
(All_Checks
);
29 -- Turn off subprogram body ordering check. Subprograms are in order
30 -- by RM section rather than alphabetical
35 -- Local functions, used only in this chapter
37 function P_Component_Clause
return Node_Id
;
38 function P_Mod_Clause
return Node_Id
;
40 -----------------------------------
41 -- Aspect_Specifications_Present --
42 -----------------------------------
44 function Aspect_Specifications_Present
45 (Strict
: Boolean := Ada_Version
< Ada_2012
) return Boolean
47 Scan_State
: Saved_Scan_State
;
50 function Possible_Misspelled_Aspect
return Boolean;
51 -- Returns True, if Token_Name is a misspelling of some aspect name
53 function With_Present
return Boolean;
54 -- Returns True if WITH is present, indicating presence of aspect
55 -- specifications. Also allows incorrect use of WHEN in place of WITH.
57 --------------------------------
58 -- Possible_Misspelled_Aspect --
59 --------------------------------
61 function Possible_Misspelled_Aspect
return Boolean is
63 for J
in Aspect_Id_Exclude_No_Aspect
loop
64 if Is_Bad_Spelling_Of
(Token_Name
, Aspect_Names
(J
)) then
70 end Possible_Misspelled_Aspect
;
76 function With_Present
return Boolean is
78 if Token
= Tok_With
then
81 -- Check for WHEN used in place of WITH
83 elsif Token
= Tok_When
then
85 Scan_State
: Saved_Scan_State
;
88 Save_Scan_State
(Scan_State
);
91 if Token
= Tok_Identifier
92 and then Get_Aspect_Id
(Token_Name
) /= No_Aspect
94 Error_Msg_SC
("WHEN should be WITH");
95 Restore_Scan_State
(Scan_State
);
99 Restore_Scan_State
(Scan_State
);
109 -- Start of processing for Aspect_Specifications_Present
112 -- Definitely must have WITH to consider aspect specs to be present
114 -- Note that this means that if we have a semicolon, we immediately
115 -- return False. There is a case in which this is not optimal, namely
118 -- type R is new Integer;
121 -- where the semicolon is redundant, but scanning forward for it would
122 -- be too expensive. Instead we pick up the aspect specifications later
123 -- as a bogus declaration, and diagnose the semicolon at that point.
125 if not With_Present
then
129 -- Have a WITH or some token that we accept as a legitimate bad attempt
130 -- at writing WITH. See if it looks like an aspect specification
132 Save_Scan_State
(Scan_State
);
133 Scan
; -- past WITH (or WHEN or other bad keyword)
135 -- If no identifier, then consider that we definitely do not have an
136 -- aspect specification.
138 if Token
/= Tok_Identifier
then
141 -- This is where we pay attention to the Strict mode. Normally when
142 -- we are in Ada 2012 mode, Strict is False, and we consider that we
143 -- have an aspect specification if the identifier is an aspect name
144 -- or a likely misspelling of one (even if not followed by =>) or
145 -- the identifier is not an aspect name but is followed by =>, by
146 -- a comma, or by a semicolon. The last two cases correspond to
147 -- (misspelled) Boolean aspects with a defaulted value of True.
148 -- P_Aspect_Specifications will generate messages if the aspect
149 -- specification is ill-formed.
151 elsif not Strict
then
152 if Get_Aspect_Id
(Token_Name
) /= No_Aspect
153 or else Possible_Misspelled_Aspect
157 Scan
; -- past identifier
159 Tok_Arrow | Tok_Comma | Tok_Is | Tok_Semicolon | Tok_Right_Paren
;
162 -- If earlier than Ada 2012, check for valid aspect identifier (possibly
163 -- completed with 'CLASS) followed by an arrow, and consider that this
164 -- is still an aspect specification so we give an appropriate message.
167 if Get_Aspect_Id
(Token_Name
) = No_Aspect
then
171 Scan
; -- past aspect name
175 if Token
= Tok_Arrow
then
178 -- The identifier may be the name of a boolean aspect with a
179 -- defaulted True value. Further checks when analyzing aspect
180 -- specification, which may include further aspects.
182 elsif Token
in Tok_Comma | Tok_Semicolon
then
185 elsif Token
= Tok_Apostrophe
then
186 Scan
; -- past apostrophe
188 if Token
= Tok_Identifier
189 and then Token_Name
= Name_Class
193 if Token
= Tok_Arrow
then
200 Restore_Scan_State
(Scan_State
);
201 Error_Msg_Ada_2012_Feature
("|aspect specification", Token_Ptr
);
207 Restore_Scan_State
(Scan_State
);
209 end Aspect_Specifications_Present
;
211 -------------------------------
212 -- Get_Aspect_Specifications --
213 -------------------------------
215 function Get_Aspect_Specifications
216 (Semicolon
: Boolean := True) return List_Id
224 -- True if current aspect takes an optional argument
227 Aspects
:= Empty_List
;
229 -- Check if aspect specification present
231 if not Aspect_Specifications_Present
then
239 Scan
; -- past WITH (or possible WHEN after error)
240 Aspects
:= Empty_List
;
242 -- Loop to scan aspects
247 -- The aspect mark is not an identifier
249 if Token
/= Tok_Identifier
then
250 Error_Msg_SC
("aspect identifier expected");
252 -- Skip the whole aspect specification list
255 Resync_Past_Semicolon
;
261 A_Id
:= Get_Aspect_Id
(Token_Name
);
263 Make_Aspect_Specification
(Token_Ptr
,
264 Identifier
=> Token_Node
);
266 -- The aspect mark is not recognized
268 if A_Id
= No_Aspect
then
270 Msg_Issued
: Boolean := False;
272 Check_Restriction
(Msg_Issued
, No_Unrecognized_Aspects
, Aspect
);
273 if not Msg_Issued
then
274 Error_Msg_Warn
:= not Debug_Flag_2
;
276 ("<<& is not a valid aspect identifier", Token_Node
);
279 -- Check bad spelling
281 for J
in Aspect_Id_Exclude_No_Aspect
loop
282 if Is_Bad_Spelling_Of
(Token_Name
, Aspect_Names
(J
)) then
283 Error_Msg_Name_1
:= Aspect_Names
(J
);
284 Error_Msg_N
-- CODEFIX
285 ("\<<possible misspelling of%", Token_Node
);
292 Scan
; -- past incorrect identifier
294 if Token
= Tok_Apostrophe
then
295 Scan
; -- past apostrophe
296 Scan
; -- past presumably CLASS
299 -- Attempt to parse the aspect definition by assuming it is an
302 if Token
= Tok_Arrow
then
304 Set_Expression
(Aspect
, P_Expression
);
306 -- If we have a correct terminator (comma or semicolon, or a
307 -- reasonable likely missing comma), then just proceed.
309 elsif Token
= Tok_Comma
or else
310 Token
= Tok_Semicolon
or else
311 Token
= Tok_Identifier
315 -- Otherwise the aspect contains a junk definition
319 Resync_Past_Semicolon
;
328 Scan
; -- past identifier
329 Opt
:= Aspect_Argument
(A_Id
) = Optional_Expression
331 Aspect_Argument
(A_Id
) = Optional_Name
;
333 -- Check for 'Class present
335 if Token
= Tok_Apostrophe
then
336 if Class_Aspect_OK
(A_Id
) then
337 Scan
; -- past apostrophe
339 if Token
= Tok_Identifier
340 and then Token_Name
= Name_Class
343 Set_Class_Present
(Aspect
);
345 Error_Msg_SC
("Class attribute expected here");
348 if Token
= Tok_Identifier
then
349 Scan
; -- past identifier not CLASS
353 -- The aspect does not allow 'Class
356 Error_Msg_Node_1
:= Identifier
(Aspect
);
357 Error_Msg_SC
("aspect& does not permit attribute here");
360 Scan
; -- past apostrophe
361 Scan
; -- past presumably CLASS
365 -- Check for a missing aspect definition. Aspects with optional
366 -- definitions are not considered.
368 if Token
= Tok_Comma
or else Token
= Tok_Semicolon
then
370 Error_Msg_Node_1
:= Identifier
(Aspect
);
371 Error_Msg_AP
("aspect& requires an aspect definition");
375 -- Here we do not have a comma or a semicolon, we are done if we
376 -- do not have an arrow and the aspect does not need an argument
378 elsif Opt
and then Token
/= Tok_Arrow
then
381 -- Here we have either an arrow, or an aspect that definitely
382 -- needs an aspect definition, and we will look for one even if
383 -- no arrow is preseant.
385 -- Otherwise we have an aspect definition
388 if Token
= Tok_Arrow
then
395 -- Detect a common error where the non-null definition of
396 -- aspect Depends, Global, Refined_Depends, Refined_Global
397 -- or Refined_State lacks enclosing parentheses.
399 if Token
/= Tok_Left_Paren
and then Token
/= Tok_Null
then
403 if A_Id
= Aspect_Depends
405 A_Id
= Aspect_Refined_Depends
407 Error_Msg_SC
-- CODEFIX
409 Resync_Past_Malformed_Aspect
;
411 -- Return when the current aspect is the last in the list
412 -- of specifications and the list applies to a body.
414 if Token
= Tok_Is
then
420 elsif A_Id
= Aspect_Global
422 A_Id
= Aspect_Refined_Global
425 Scan_State
: Saved_Scan_State
;
428 Save_Scan_State
(Scan_State
);
429 Scan
; -- past item or mode_selector
431 -- Emit an error when the aspect has a mode_selector
432 -- as the moded_global_list must be parenthesized:
433 -- with Global => Output => Item
435 if Token
= Tok_Arrow
then
436 Restore_Scan_State
(Scan_State
);
437 Error_Msg_SC
-- CODEFIX
439 Resync_Past_Malformed_Aspect
;
441 -- Return when the current aspect is the last in
442 -- the list of specifications and the list applies
445 if Token
= Tok_Is
then
449 elsif Token
= Tok_Comma
then
452 -- An item followed by a comma does not need to
453 -- be parenthesized if the next token is a valid
455 -- with Global => Item,
458 if Token
= Tok_Identifier
459 and then Get_Aspect_Id
(Token_Name
) /= No_Aspect
461 Restore_Scan_State
(Scan_State
);
463 -- Otherwise this is a list of items in which case
464 -- the list must be parenthesized.
467 Restore_Scan_State
(Scan_State
);
468 Error_Msg_SC
-- CODEFIX
470 Resync_Past_Malformed_Aspect
;
472 -- Return when the current aspect is the last
473 -- in the list of specifications and the list
474 -- applies to a body.
476 if Token
= Tok_Is
then
481 -- The definition of [Refined_]Global does not need to
485 Restore_Scan_State
(Scan_State
);
491 elsif A_Id
= Aspect_Refined_State
then
492 if Token
= Tok_Identifier
then
494 Scan_State
: Saved_Scan_State
;
497 Save_Scan_State
(Scan_State
);
500 -- The refinement contains a constituent, the whole
501 -- argument of Refined_State must be parenthesized.
503 -- with Refined_State => State => Constit
505 if Token
= Tok_Arrow
then
506 Restore_Scan_State
(Scan_State
);
507 Error_Msg_SC
-- CODEFIX
509 Resync_Past_Malformed_Aspect
;
511 -- Return when the current aspect is the last
512 -- in the list of specifications and the list
513 -- applies to a body.
515 if Token
= Tok_Is
then
519 -- The refinement lacks constituents. Do not flag
520 -- this case as the error would be misleading. The
521 -- diagnostic is left to the analysis.
523 -- with Refined_State => State
526 Restore_Scan_State
(Scan_State
);
533 -- Note if inside Depends or Refined_Depends aspect
535 if A_Id
= Aspect_Depends
536 or else A_Id
= Aspect_Refined_Depends
538 Inside_Depends
:= True;
541 -- Note that we have seen an Import aspect specification.
542 -- This matters only while parsing a subprogram.
544 if A_Id
= Aspect_Import
then
545 SIS_Aspect_Import_Seen
:= True;
546 -- Should do it only for subprograms
549 -- Parse the aspect definition depending on the expected
552 if Aspect_Argument
(A_Id
) = Name
553 or else Aspect_Argument
(A_Id
) = Optional_Name
555 Set_Expression
(Aspect
, P_Name
);
559 (Aspect_Argument
(A_Id
) = Expression
561 Aspect_Argument
(A_Id
) = Optional_Expression
);
562 Set_Expression
(Aspect
, P_Expression
);
565 -- Unconditionally reset flag for Inside_Depends
567 Inside_Depends
:= False;
570 -- Add the aspect to the resulting list only when it was properly
574 Append
(Aspect
, Aspects
);
578 -- Merge here after good or bad aspect (we should be at a comma
579 -- or a semicolon, but there might be other possible errors).
581 -- The aspect specification list contains more than one aspect
583 if Token
= Tok_Comma
then
587 -- Check for a missing comma between two aspects. Emit an error
588 -- and proceed to the next aspect.
590 elsif Token
= Tok_Identifier
591 and then Get_Aspect_Id
(Token_Name
) /= No_Aspect
594 Scan_State
: Saved_Scan_State
;
597 Save_Scan_State
(Scan_State
);
598 Scan
; -- past identifier
600 -- Attempt to detect ' or => following a potential aspect
603 if Token
= Tok_Apostrophe
or else Token
= Tok_Arrow
then
604 Restore_Scan_State
(Scan_State
);
605 Error_Msg_AP
-- CODEFIX
609 -- The construct following the current aspect is not an
613 Restore_Scan_State
(Scan_State
);
617 -- Check for a mistyped semicolon in place of a comma between two
618 -- aspects. Emit an error and proceed to the next aspect.
620 elsif Token
= Tok_Semicolon
then
622 Scan_State
: Saved_Scan_State
;
625 Save_Scan_State
(Scan_State
);
626 Scan
; -- past semicolon
628 if Token
= Tok_Identifier
629 and then Get_Aspect_Id
(Token_Name
) /= No_Aspect
631 Scan
; -- past identifier
633 -- Attempt to detect ' or => following potential aspect mark
635 if Token
= Tok_Apostrophe
or else Token
= Tok_Arrow
then
636 Restore_Scan_State
(Scan_State
);
637 Error_Msg_SC
-- CODEFIX
638 ("|"";"" should be "",""");
639 Scan
; -- past semicolon
644 -- Construct following the current aspect is not an aspect
646 Restore_Scan_State
(Scan_State
);
650 -- Require semicolon if caller expects to scan this out
663 end Get_Aspect_Specifications
;
665 --------------------------------------------
666 -- 13.1 Representation Clause (also I.7) --
667 --------------------------------------------
669 -- REPRESENTATION_CLAUSE ::=
670 -- ATTRIBUTE_DEFINITION_CLAUSE
671 -- | ENUMERATION_REPRESENTATION_CLAUSE
672 -- | RECORD_REPRESENTATION_CLAUSE
675 -- ATTRIBUTE_DEFINITION_CLAUSE ::=
676 -- for LOCAL_NAME'ATTRIBUTE_DESIGNATOR use EXPRESSION;
677 -- | for LOCAL_NAME'ATTRIBUTE_DESIGNATOR use NAME;
679 -- Note: in Ada 83, the expression must be a simple expression
681 -- AT_CLAUSE ::= for DIRECT_NAME use at EXPRESSION;
683 -- Note: in Ada 83, the expression must be a simple expression
685 -- ENUMERATION_REPRESENTATION_CLAUSE ::=
686 -- for first_subtype_LOCAL_NAME use ENUMERATION_AGGREGATE;
688 -- ENUMERATION_AGGREGATE ::= ARRAY_AGGREGATE
690 -- RECORD_REPRESENTATION_CLAUSE ::=
691 -- for first_subtype_LOCAL_NAME use
692 -- record [MOD_CLAUSE]
693 -- {COMPONENT_CLAUSE}
696 -- Note: for now we allow only a direct name as the local name in the
697 -- above constructs. This probably needs changing later on ???
699 -- The caller has checked that the initial token is FOR
701 -- Error recovery: cannot raise Error_Resync, if an error occurs,
702 -- the scan is repositioned past the next semicolon.
704 function P_Representation_Clause
return Node_Id
is
705 For_Loc
: Source_Ptr
;
707 Prefix_Node
: Node_Id
;
709 Identifier_Node
: Node_Id
;
710 Rep_Clause_Node
: Node_Id
;
712 Record_Items
: List_Id
;
715 For_Loc
:= Token_Ptr
;
718 -- Note that the name in a representation clause is always a simple
719 -- name, even in the attribute case, see AI-300 which made this so.
721 Identifier_Node
:= P_Identifier
(C_Use
);
723 -- Check case of qualified name to give good error message
725 if Token
= Tok_Dot
then
727 ("representation clause requires simple name!");
730 exit when Token
/= Tok_Dot
;
732 Discard_Junk_Node
(P_Identifier
);
736 -- Attribute Definition Clause
738 if Token
= Tok_Apostrophe
then
740 -- Allow local names of the form a'b'.... This enables
741 -- us to parse class-wide streams attributes correctly.
743 Name_Node
:= Identifier_Node
;
744 while Token
= Tok_Apostrophe
loop
746 Scan
; -- past apostrophe
748 Identifier_Node
:= Token_Node
;
749 Attr_Name
:= No_Name
;
751 if Token
= Tok_Identifier
then
752 Attr_Name
:= Token_Name
;
754 -- Note that the parser must complain in case of an internal
755 -- attribute name that comes from source since internal names
756 -- are meant to be used only by the compiler.
758 if not Is_Attribute_Name
(Attr_Name
)
759 and then (not Is_Internal_Attribute_Name
(Attr_Name
)
760 or else Comes_From_Source
(Token_Node
))
762 Signal_Bad_Attribute
;
766 Style
.Check_Attribute_Name
(False);
769 -- Here for case of attribute designator is not an identifier
772 if Token
= Tok_Delta
then
773 Attr_Name
:= Name_Delta
;
775 elsif Token
= Tok_Digits
then
776 Attr_Name
:= Name_Digits
;
778 elsif Token
= Tok_Access
then
779 Attr_Name
:= Name_Access
;
782 Error_Msg_AP
("attribute designator expected");
787 Style
.Check_Attribute_Name
(True);
791 -- Here we have an OK attribute scanned, and the corresponding
792 -- Attribute identifier node is stored in Ident_Node.
794 Prefix_Node
:= Name_Node
;
795 Name_Node
:= New_Node
(N_Attribute_Reference
, Prev_Token_Ptr
);
796 Set_Prefix
(Name_Node
, Prefix_Node
);
797 Set_Attribute_Name
(Name_Node
, Attr_Name
);
800 -- Check for Address clause which needs to be marked for use in
801 -- optimizing performance of Exp_Util.Following_Address_Clause.
803 if Attr_Name
= Name_Address
804 and then Nkind
(Prefix_Node
) = N_Identifier
806 Set_Name_Table_Boolean1
(Chars
(Prefix_Node
), True);
810 Rep_Clause_Node
:= New_Node
(N_Attribute_Definition_Clause
, For_Loc
);
811 Set_Name
(Rep_Clause_Node
, Prefix_Node
);
812 Set_Chars
(Rep_Clause_Node
, Attr_Name
);
815 Expr_Node
:= P_Expression_No_Right_Paren
;
816 Check_Simple_Expression_In_Ada_83
(Expr_Node
);
817 Set_Expression
(Rep_Clause_Node
, Expr_Node
);
821 Rep_Clause_Node
:= Empty
;
823 -- AT follows USE (At Clause)
825 if Token
= Tok_At
then
827 Rep_Clause_Node
:= New_Node
(N_At_Clause
, For_Loc
);
828 Set_Identifier
(Rep_Clause_Node
, Identifier_Node
);
829 Expr_Node
:= P_Expression_No_Right_Paren
;
830 Check_Simple_Expression_In_Ada_83
(Expr_Node
);
831 Set_Expression
(Rep_Clause_Node
, Expr_Node
);
833 -- Mark occurrence of address clause (used to optimize performance
834 -- of Exp_Util.Following_Address_Clause).
836 Set_Name_Table_Boolean1
(Chars
(Identifier_Node
), True);
838 -- RECORD follows USE (Record Representation Clause)
840 elsif Token
= Tok_Record
then
841 Record_Items
:= P_Pragmas_Opt
;
843 New_Node
(N_Record_Representation_Clause
, For_Loc
);
844 Set_Identifier
(Rep_Clause_Node
, Identifier_Node
);
847 Scopes
(Scope
.Last
).Etyp
:= E_Record
;
848 Scopes
(Scope
.Last
).Ecol
:= Start_Column
;
849 Scopes
(Scope
.Last
).Sloc
:= Token_Ptr
;
851 Record_Items
:= P_Pragmas_Opt
;
853 -- Possible Mod Clause
855 if Token
= Tok_At
then
856 Set_Mod_Clause
(Rep_Clause_Node
, P_Mod_Clause
);
857 Set_Pragmas_Before
(Mod_Clause
(Rep_Clause_Node
), Record_Items
);
858 Record_Items
:= P_Pragmas_Opt
;
861 if No
(Record_Items
) then
862 Record_Items
:= New_List
;
865 Set_Component_Clauses
(Rep_Clause_Node
, Record_Items
);
867 -- Loop through component clauses
870 if Token
not in Token_Class_Name
then
874 Append
(P_Component_Clause
, Record_Items
);
875 P_Pragmas_Opt
(Record_Items
);
878 -- Left paren follows USE (Enumeration Representation Clause)
880 elsif Token
= Tok_Left_Paren
then
882 New_Node
(N_Enumeration_Representation_Clause
, For_Loc
);
883 Set_Identifier
(Rep_Clause_Node
, Identifier_Node
);
884 Set_Array_Aggregate
(Rep_Clause_Node
, P_Aggregate
);
886 -- Some other token follows FOR (invalid representation clause)
889 Error_Msg_SC
("invalid representation clause");
895 return Rep_Clause_Node
;
899 Resync_Past_Semicolon
;
902 end P_Representation_Clause
;
904 ----------------------
905 -- 13.1 Local Name --
906 ----------------------
908 -- Local name is always parsed by its parent. In the case of its use in
909 -- pragmas, the check for a local name is handled in Par.Prag and allows
910 -- all the possible forms of local name. For the uses in chapter 13, we
911 -- currently only allow a direct name, but this should probably change???
913 ---------------------------
914 -- 13.1 At Clause (I.7) --
915 ---------------------------
917 -- Parsed by P_Representation_Clause (13.1)
919 ---------------------------------------
920 -- 13.3 Attribute Definition Clause --
921 ---------------------------------------
923 -- Parsed by P_Representation_Clause (13.1)
925 --------------------------------
926 -- 13.1 Aspect Specification --
927 --------------------------------
929 -- ASPECT_SPECIFICATION ::=
930 -- with ASPECT_MARK [=> ASPECT_DEFINITION] {,
931 -- ASPECT_MARK [=> ASPECT_DEFINITION] }
933 -- ASPECT_MARK ::= aspect_IDENTIFIER['Class]
935 -- ASPECT_DEFINITION ::= NAME | EXPRESSION
937 -- Error recovery: cannot raise Error_Resync
939 procedure P_Aspect_Specifications
941 Semicolon
: Boolean := True)
947 -- Aspect Specification is present
951 -- Here we have an aspect specification to scan, note that we don't
952 -- set the flag till later, because it may turn out that we have no
953 -- valid aspects in the list.
955 Aspects
:= Get_Aspect_Specifications
(Semicolon
);
957 -- Here if aspects present
959 if Is_Non_Empty_List
(Aspects
) then
961 -- If Decl is Empty, we just ignore the aspects (the caller in this
962 -- case has always issued an appropriate error message).
967 -- If Decl is Error, we ignore the aspects, and issue a message
970 or else not Permits_Aspect_Specifications
(Decl
)
972 Error_Msg
("aspect specifications not allowed here", Ptr
);
974 -- Here aspects are allowed, and we store them
977 Set_Parent
(Aspects
, Decl
);
978 Set_Aspect_Specifications
(Decl
, Aspects
);
981 end P_Aspect_Specifications
;
983 ---------------------------------------------
984 -- 13.4 Enumeration Representation Clause --
985 ---------------------------------------------
987 -- Parsed by P_Representation_Clause (13.1)
989 ---------------------------------
990 -- 13.4 Enumeration Aggregate --
991 ---------------------------------
993 -- Parsed by P_Representation_Clause (13.1)
995 ------------------------------------------
996 -- 13.5.1 Record Representation Clause --
997 ------------------------------------------
999 -- Parsed by P_Representation_Clause (13.1)
1001 ------------------------------
1002 -- 13.5.1 Mod Clause (I.8) --
1003 ------------------------------
1005 -- MOD_CLAUSE ::= at mod static_EXPRESSION;
1007 -- Note: in Ada 83, the expression must be a simple expression
1009 -- The caller has checked that the initial Token is AT
1011 -- Error recovery: cannot raise Error_Resync
1013 -- Note: the caller is responsible for setting the Pragmas_Before field
1015 function P_Mod_Clause
return Node_Id
is
1017 Expr_Node
: Node_Id
;
1020 Mod_Node
:= New_Node
(N_Mod_Clause
, Token_Ptr
);
1023 Expr_Node
:= P_Expression_No_Right_Paren
;
1024 Check_Simple_Expression_In_Ada_83
(Expr_Node
);
1025 Set_Expression
(Mod_Node
, Expr_Node
);
1030 ------------------------------
1031 -- 13.5.1 Component Clause --
1032 ------------------------------
1034 -- COMPONENT_CLAUSE ::=
1035 -- COMPONENT_CLAUSE_COMPONENT_NAME at POSITION
1036 -- range FIRST_BIT .. LAST_BIT;
1038 -- COMPONENT_CLAUSE_COMPONENT_NAME ::=
1039 -- component_DIRECT_NAME
1040 -- | component_DIRECT_NAME'ATTRIBUTE_DESIGNATOR
1041 -- | FIRST_SUBTYPE_DIRECT_NAME'ATTRIBUTE_DESIGNATOR
1043 -- POSITION ::= static_EXPRESSION
1045 -- Note: in Ada 83, the expression must be a simple expression
1047 -- FIRST_BIT ::= static_SIMPLE_EXPRESSION
1048 -- LAST_BIT ::= static_SIMPLE_EXPRESSION
1050 -- Note: the AARM V2.0 grammar has an error at this point, it uses
1051 -- EXPRESSION instead of SIMPLE_EXPRESSION for FIRST_BIT and LAST_BIT
1053 -- Error recovery: cannot raise Error_Resync
1055 function P_Component_Clause
return Node_Id
is
1056 Component_Node
: Node_Id
;
1057 Comp_Name
: Node_Id
;
1058 Expr_Node
: Node_Id
;
1061 Component_Node
:= New_Node
(N_Component_Clause
, Token_Ptr
);
1062 Comp_Name
:= P_Name
;
1064 if Nkind
(Comp_Name
) = N_Identifier
1065 or else Nkind
(Comp_Name
) = N_Attribute_Reference
1067 Set_Component_Name
(Component_Node
, Comp_Name
);
1070 ("component name must be direct name or attribute", Comp_Name
);
1071 Set_Component_Name
(Component_Node
, Error
);
1074 Set_Sloc
(Component_Node
, Token_Ptr
);
1076 Expr_Node
:= P_Expression_No_Right_Paren
;
1077 Check_Simple_Expression_In_Ada_83
(Expr_Node
);
1078 Set_Position
(Component_Node
, Expr_Node
);
1080 Expr_Node
:= P_Expression_No_Right_Paren
;
1081 Check_Simple_Expression_In_Ada_83
(Expr_Node
);
1082 Set_First_Bit
(Component_Node
, Expr_Node
);
1084 Expr_Node
:= P_Expression_No_Right_Paren
;
1085 Check_Simple_Expression_In_Ada_83
(Expr_Node
);
1086 Set_Last_Bit
(Component_Node
, Expr_Node
);
1088 return Component_Node
;
1089 end P_Component_Clause
;
1091 ----------------------
1092 -- 13.5.1 Position --
1093 ----------------------
1095 -- Parsed by P_Component_Clause (13.5.1)
1097 -----------------------
1098 -- 13.5.1 First Bit --
1099 -----------------------
1101 -- Parsed by P_Component_Clause (13.5.1)
1103 ----------------------
1104 -- 13.5.1 Last Bit --
1105 ----------------------
1107 -- Parsed by P_Component_Clause (13.5.1)
1109 --------------------------
1110 -- 13.8 Code Statement --
1111 --------------------------
1113 -- CODE_STATEMENT ::= QUALIFIED_EXPRESSION
1115 -- On entry the caller has scanned the SUBTYPE_MARK (passed in as the
1116 -- single argument, and the scan points to the apostrophe.
1118 -- Error recovery: can raise Error_Resync
1120 function P_Code_Statement
(Subtype_Mark
: Node_Id
) return Node_Id
is
1124 Scan
; -- past apostrophe
1126 -- If left paren, then we have a possible code statement
1128 if Token
= Tok_Left_Paren
then
1129 Node1
:= New_Node
(N_Code_Statement
, Sloc
(Subtype_Mark
));
1130 Set_Expression
(Node1
, P_Qualified_Expression
(Subtype_Mark
));
1134 -- Otherwise we have an illegal range attribute. Note that P_Name
1135 -- ensures that Token = Tok_Range is the only possibility left here.
1138 Error_Msg_SC
("RANGE attribute illegal here!");
1141 end P_Code_Statement
;