1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2013, 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
33 -----------------------
34 -- Local Subprograms --
35 -----------------------
37 function P_Use_Package_Clause
return Node_Id
;
38 function P_Use_Type_Clause
return Node_Id
;
44 -- USE_CLAUSE ::= USE_PACKAGE_CLAUSE | USE_TYPE_CLAUSE
46 -- The caller has checked that the initial token is USE
48 -- Error recovery: cannot raise Error_Resync
50 function P_Use_Clause
return Node_Id
is
54 if Token
= Tok_Type
or else Token
= Tok_All
then
55 return P_Use_Type_Clause
;
57 return P_Use_Package_Clause
;
61 -----------------------------
62 -- 8.4 Use Package Clause --
63 -----------------------------
65 -- USE_PACKAGE_CLAUSE ::= use package_NAME {, package_NAME};
67 -- The caller has scanned out the USE keyword
69 -- Error recovery: cannot raise Error_Resync
71 function P_Use_Package_Clause
return Node_Id
is
75 Use_Node
:= New_Node
(N_Use_Package_Clause
, Prev_Token_Ptr
);
76 Set_Names
(Use_Node
, New_List
);
78 if Token
= Tok_Package
then
79 Error_Msg_SC
("PACKAGE should not appear here");
84 Append
(P_Qualified_Simple_Name
, Names
(Use_Node
));
85 exit when Token
/= Tok_Comma
;
91 end P_Use_Package_Clause
;
93 --------------------------
94 -- 8.4 Use Type Clause --
95 --------------------------
97 -- USE_TYPE_CLAUSE ::= use [ALL] type SUBTYPE_MARK {, SUBTYPE_MARK};
99 -- The caller has checked that the initial token is USE, scanned it out
100 -- and that the current token is either ALL or TYPE.
102 -- Note: Use of ALL is an Ada 2012 feature
104 -- Error recovery: cannot raise Error_Resync
106 function P_Use_Type_Clause
return Node_Id
is
108 All_Present
: Boolean;
109 Use_Sloc
: constant Source_Ptr
:= Prev_Token_Ptr
;
112 if Token
= Tok_All
then
113 Error_Msg_Ada_2012_Feature
("|`USE ALL TYPE`", Token_Ptr
);
117 if Token
/= Tok_Type
then
118 Error_Msg_SC
("TYPE expected");
121 else pragma Assert
(Token
= Tok_Type
);
122 All_Present
:= False;
125 Use_Node
:= New_Node
(N_Use_Type_Clause
, Use_Sloc
);
126 Set_All_Present
(Use_Node
, All_Present
);
127 Set_Subtype_Marks
(Use_Node
, New_List
);
128 Set_Used_Operations
(Use_Node
, No_Elist
);
130 if Ada_Version
= Ada_83
then
131 Error_Msg_SC
("(Ada 83) use type not allowed!");
137 Append
(P_Subtype_Mark
, Subtype_Marks
(Use_Node
));
139 exit when Token
/= Tok_Comma
;
145 end P_Use_Type_Clause
;
147 -------------------------------
148 -- 8.5 Renaming Declaration --
149 -------------------------------
151 -- Object renaming declarations and exception renaming declarations
152 -- are parsed by P_Identifier_Declaration (3.3.1)
154 -- Subprogram renaming declarations are parsed by P_Subprogram (6.1)
156 -- Package renaming declarations are parsed by P_Package (7.1)
158 -- Generic renaming declarations are parsed by P_Generic (12.1)
160 ----------------------------------------
161 -- 8.5.1 Object Renaming Declaration --
162 ----------------------------------------
164 -- Parsed by P_Identifier_Declarations (3.3.1)
166 ----------------------------------------
167 -- 8.5.2 Exception Renaming Declaration --
168 ----------------------------------------
170 -- Parsed by P_Identifier_Declarations (3.3.1)
172 -----------------------------------------
173 -- 8.5.3 Package Renaming Declaration --
174 -----------------------------------------
176 -- Parsed by P_Package (7.1)
178 --------------------------------------------
179 -- 8.5.4 Subprogram Renaming Declaration --
180 --------------------------------------------
182 -- Parsed by P_Subprogram (6.1)
184 -----------------------------------------
185 -- 8.5.2 Generic Renaming Declaration --
186 -----------------------------------------
188 -- Parsed by P_Generic (12.1)