1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2012, 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 handling is isolated in a separate package
27 -- (logically this processing belongs in chapter 4)
29 with Namet
; use Namet
;
30 with Types
; use Types
;
38 procedure Analyze_Pragma
(N
: Node_Id
);
39 -- Analyze procedure for pragma reference node N
41 procedure Analyze_CTC_In_Decl_Part
(N
: Node_Id
; S
: Entity_Id
);
42 -- Special analyze routine for contract-case and test-case pragmas that
43 -- appears within a declarative part where the pragma is associated with
44 -- a subprogram specification. N is the pragma node, and S is the entity
45 -- for the related subprogram. This procedure does a preanalysis of the
46 -- expressions in the pragma as "spec expressions" (see section in Sem
47 -- "Handling of Default and Per-Object Expressions...").
49 procedure Analyze_PPC_In_Decl_Part
(N
: Node_Id
; S
: Entity_Id
);
50 -- Special analyze routine for precondition/postcondition pragma that
51 -- appears within a declarative part where the pragma is associated
52 -- with a subprogram specification. N is the pragma node, and S is the
53 -- entity for the related subprogram. This procedure does a preanalysis
54 -- of the expressions in the pragma as "spec expressions" (see section
55 -- in Sem "Handling of Default and Per-Object Expressions...").
57 function Check_Disabled
(Nam
: Name_Id
) return Boolean;
58 -- This function is used in connection with pragmas Assertion, Check,
59 -- Precondition, and Postcondition, to determine if Check pragmas (or
60 -- corresponding Assert, Precondition, or Postcondition pragmas) are
61 -- currently disabled (as set by a Policy pragma with the Disabled
63 function Check_Enabled
(Nam
: Name_Id
) return Boolean;
64 -- This function is used in connection with pragmas Assertion, Check,
65 -- Precondition, and Postcondition, to determine if Check pragmas (or
66 -- corresponding Assert, Precondition, or Postcondition pragmas) are
67 -- currently active, as determined by the presence of -gnata on the
68 -- command line (which sets the default), and the appearance of pragmas
69 -- Check_Policy and Assertion_Policy as configuration pragmas either in
70 -- a configuration pragma file, or at the start of the current unit.
71 -- True is returned if the specified check is enabled.
73 function Delay_Config_Pragma_Analyze
(N
: Node_Id
) return Boolean;
74 -- N is a pragma appearing in a configuration pragma file. Most such
75 -- pragmas are analyzed when the file is read, before parsing and analyzing
76 -- the main unit. However, the analysis of certain pragmas results in
77 -- adding information to the compiled main unit, and this cannot be done
78 -- till the main unit is processed. Such pragmas return True from this
79 -- function and in Frontend pragmas where Delay_Config_Pragma_Analyze is
80 -- True have their analysis delayed until after the main program is parsed
84 -- Initializes data structures used for pragma processing. Must be called
85 -- before analyzing each new main source program.
87 function Is_Non_Significant_Pragma_Reference
(N
: Node_Id
) return Boolean;
88 -- The node N is a node for an entity and the issue is whether the
89 -- occurrence is a reference for the purposes of giving warnings about
90 -- unreferenced variables. This function returns True if the reference is
91 -- not a reference from this point of view (e.g. the occurrence in a pragma
92 -- Pack) and False if it is a real reference (e.g. the occurrence in a
95 function Is_Pragma_String_Literal
(Par
: Node_Id
) return Boolean;
96 -- Given an N_Pragma_Argument_Association node, Par, which has the form of
97 -- an operator symbol, determines whether or not it should be treated as an
98 -- string literal. This is called by Sem_Ch6.Analyze_Operator_Symbol. If
99 -- True is returned, the argument is converted to a string literal. If
100 -- False is returned, then the argument is treated as an entity reference
103 function Is_Config_Static_String
(Arg
: Node_Id
) return Boolean;
104 -- This is called for a configuration pragma that requires either string
105 -- literal or a concatenation of string literals. We cannot use normal
106 -- static string processing because it is too early in the case of the
107 -- pragma appearing in a configuration pragmas file. If Arg is of an
108 -- appropriate form, then this call obtains the string (doing any necessary
109 -- concatenations) and places it in Name_Buffer, setting Name_Len to its
110 -- length, and then returns True. If it is not of the correct form, then an
111 -- appropriate error message is posted, and False is returned.
113 procedure Make_Aspect_For_PPC_In_Gen_Sub_Decl
(Decl
: Node_Id
);
114 -- This routine makes aspects from precondition or postcondition pragmas
115 -- that appear within a generic subprogram declaration. Decl is the generic
116 -- subprogram declaration node. Note that the aspects are attached to the
117 -- generic copy and also to the orginal tree.
119 procedure Process_Compilation_Unit_Pragmas
(N
: Node_Id
);
120 -- Called at the start of processing compilation unit N to deal with any
121 -- special issues regarding pragmas. In particular, we have to deal with
122 -- Suppress_All at this stage, since it can appear after the unit instead
123 -- of before (actually we allow it to appear anywhere).
125 procedure Set_Encoded_Interface_Name
(E
: Entity_Id
; S
: Node_Id
);
126 -- This routine is used to set an encoded interface name. The node S is an
127 -- N_String_Literal node for the external name to be set, and E is an
128 -- entity whose Interface_Name field is to be set. In the normal case where
129 -- S contains a name that is a valid C identifier, then S is simply set as
130 -- the value of the Interface_Name. Otherwise it is encoded. See the body
131 -- for details of the encoding. This encoding is only done on VMS systems,
132 -- since it seems pretty silly, but is needed to pass some dubious tests in