[multiple changes]
[gcc.git] / gcc / ada / sem_prag.ads
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S E M _ P R A G --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2013, 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 ------------------------------------------------------------------------------
25
26 -- Pragma handling is isolated in a separate package
27 -- (logically this processing belongs in chapter 4)
28
29 with Namet; use Namet;
30 with Types; use Types;
31
32 package Sem_Prag is
33
34 -----------------
35 -- Subprograms --
36 -----------------
37
38 procedure Analyze_Pragma (N : Node_Id);
39 -- Analyze procedure for pragma reference node N
40
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...").
48
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...").
56
57 function Check_Kind (Nam : Name_Id) return Name_Id;
58 -- This function is used in connection with pragmas Assert, Check,
59 -- and assertion aspects and pragmas, to determine if Check pragmas
60 -- (or corresponding assertion aspects or pragmas) are currently active
61 -- as determined by the presence of -gnata on the command line (which
62 -- sets the default), and the appearance of pragmas Check_Policy and
63 -- Assertion_Policy as configuration pragmas either in a configuration
64 -- pragma file, or at the start of the current unit, or locally given
65 -- Check_Policy and Assertion_Policy pragmas that are currently active.
66 --
67 -- The value returned is one of the names Check, Ignore, Disable (On
68 -- returns Check, and Off returns Ignore).
69 --
70 -- Note: for assertion kinds Pre'Class, Post'Class, Invariant'Class,
71 -- and Type_Invariant'Class, the name passed is Name_uPre, Name_uPost,
72 -- Name_uInvariant, or Name_uType_Invariant, which corresponds to _Pre,
73 -- _Post, _Invariant, or _Type_Invariant, which are special names used
74 -- in identifiers to represent these attribute references.
75
76 procedure Check_Applicable_Policy (N : Node_Id);
77 -- N is either an N_Aspect or an N_Pragma node. There are two cases. If
78 -- the name of the aspect or pragma is not one of those recognized as
79 -- an assertion kind by an Assertion_Policy pragma, then the call has
80 -- no effect. Note that in the case of a pragma derived from an aspect,
81 -- the name we use for the purpose of this procedure is the aspect name,
82 -- which may be different from the pragma name (e.g. Precondition for
83 -- Pre aspect). In addition, 'Class aspects are recognized (and the
84 -- corresponding special names used in the processing).
85 --
86 -- If the name is a valid assertion kind name, then the Check_Policy pragma
87 -- chain is checked for a matching entry (or for an Assertion entry which
88 -- matches all possibilities). If a matching entry is found then the policy
89 -- is checked. If it is Off, Ignore, or Disable, then the Is_Ignored flag
90 -- is set in the aspect or pragma node. Additionally for policy Disable,
91 -- the Is_Disabled flag is set.
92 --
93 -- If no matching Check_Policy pragma is found then the effect depends on
94 -- whether -gnata was used, if so, then the call has no effect, otherwise
95 -- Is_Ignored (but not Is_Disabled) is set True.
96
97 function Delay_Config_Pragma_Analyze (N : Node_Id) return Boolean;
98 -- N is a pragma appearing in a configuration pragma file. Most such
99 -- pragmas are analyzed when the file is read, before parsing and analyzing
100 -- the main unit. However, the analysis of certain pragmas results in
101 -- adding information to the compiled main unit, and this cannot be done
102 -- till the main unit is processed. Such pragmas return True from this
103 -- function and in Frontend pragmas where Delay_Config_Pragma_Analyze is
104 -- True have their analysis delayed until after the main program is parsed
105 -- and analyzed.
106
107 procedure Initialize;
108 -- Initializes data structures used for pragma processing. Must be called
109 -- before analyzing each new main source program.
110
111 function Is_Non_Significant_Pragma_Reference (N : Node_Id) return Boolean;
112 -- The node N is a node for an entity and the issue is whether the
113 -- occurrence is a reference for the purposes of giving warnings about
114 -- unreferenced variables. This function returns True if the reference is
115 -- not a reference from this point of view (e.g. the occurrence in a pragma
116 -- Pack) and False if it is a real reference (e.g. the occurrence in a
117 -- pragma Export);
118
119 function Is_Pragma_String_Literal (Par : Node_Id) return Boolean;
120 -- Given an N_Pragma_Argument_Association node, Par, which has the form of
121 -- an operator symbol, determines whether or not it should be treated as an
122 -- string literal. This is called by Sem_Ch6.Analyze_Operator_Symbol. If
123 -- True is returned, the argument is converted to a string literal. If
124 -- False is returned, then the argument is treated as an entity reference
125 -- to the operator.
126
127 function Is_Config_Static_String (Arg : Node_Id) return Boolean;
128 -- This is called for a configuration pragma that requires either string
129 -- literal or a concatenation of string literals. We cannot use normal
130 -- static string processing because it is too early in the case of the
131 -- pragma appearing in a configuration pragmas file. If Arg is of an
132 -- appropriate form, then this call obtains the string (doing any necessary
133 -- concatenations) and places it in Name_Buffer, setting Name_Len to its
134 -- length, and then returns True. If it is not of the correct form, then an
135 -- appropriate error message is posted, and False is returned.
136
137 procedure Make_Aspect_For_PPC_In_Gen_Sub_Decl (Decl : Node_Id);
138 -- This routine makes aspects from precondition or postcondition pragmas
139 -- that appear within a generic subprogram declaration. Decl is the generic
140 -- subprogram declaration node. Note that the aspects are attached to the
141 -- generic copy and also to the orginal tree.
142
143 procedure Process_Compilation_Unit_Pragmas (N : Node_Id);
144 -- Called at the start of processing compilation unit N to deal with any
145 -- special issues regarding pragmas. In particular, we have to deal with
146 -- Suppress_All at this stage, since it can appear after the unit instead
147 -- of before (actually we allow it to appear anywhere).
148
149 procedure Set_Encoded_Interface_Name (E : Entity_Id; S : Node_Id);
150 -- This routine is used to set an encoded interface name. The node S is an
151 -- N_String_Literal node for the external name to be set, and E is an
152 -- entity whose Interface_Name field is to be set. In the normal case where
153 -- S contains a name that is a valid C identifier, then S is simply set as
154 -- the value of the Interface_Name. Otherwise it is encoded. See the body
155 -- for details of the encoding. This encoding is only done on VMS systems,
156 -- since it seems pretty silly, but is needed to pass some dubious tests in
157 -- the test suite.
158
159 end Sem_Prag;