1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Pragmas</TITLE>
<META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
<META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
<STYLE type="text/css">
DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
TT {font-family: "Courier New", monospace}
DT {display: compact}
DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Index {font-family: "Times New Roman", Times, serif}
DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left: 10.0em; margin-bottom: 0.6em}
DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 15.0em; margin-bottom: 0.6em}
UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
DD.Hanging {margin-left: 6.0em}
DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.IndentedHanging {margin-left: 2.0em}
DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.HangingInBulleted {margin-left: 4.0em}
DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallHanging {margin-left: 7.5em}
DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallIndentedHanging {margin-left: 2.0em}
DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallHangingInBulleted {margin-left: 5.0em}
DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.Enumerated {margin-left: 2.0em}
DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallEnumerated {margin-left: 2.5em}
DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-2-7.html">Previous</A> <A HREF="AA-2-9.html">Next</A></P>
<HR>
<H1> 2.8 Pragmas</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1266"></A>A pragma is a compiler directive.
There are language-defined pragmas that give instructions for optimization,
listing control, etc. An implementation may support additional (implementation-defined)
pragmas. </DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">pragma<A NAME="I1267"></A>
::= </FONT><BR>
<B>pragma</B> <A NAME="I1268"></A><FONT FACE="Arial, Helvetica">identifier</FONT> [(<A NAME="I1269"></A><FONT FACE="Arial, Helvetica">pragma_argument_association</FONT> {, <A NAME="I1270"></A><FONT FACE="Arial, Helvetica">pragma_argument_association</FONT>})];</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">pragma_argument_association<A NAME="I1271"></A>
::= </FONT><BR>
[<I>pragma_argument_</I><A NAME="I1272"></A><FONT FACE="Arial, Helvetica">identifier</FONT> =>] <A NAME="I1273"></A><FONT FACE="Arial, Helvetica">name</FONT><BR>
| [<I>pragma_argument_</I><A NAME="I1274"></A><FONT FACE="Arial, Helvetica">identifier</FONT> =>] <A NAME="I1275"></A><FONT FACE="Arial, Helvetica">expression</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="SyntaxIndented">In a <FONT FACE="Arial, Helvetica">pragma</FONT>,
any <FONT FACE="Arial, Helvetica">pragma_argument_association</FONT>s
without a <I>pragma_argument_</I><FONT FACE="Arial, Helvetica">identifier</FONT>
shall precede any associations with a <I>pragma_argument_</I><FONT FACE="Arial, Helvetica">identifier</FONT>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="SyntaxIndented" Style="margin-bottom: 0.2em"><FONT FACE="Arial, Helvetica">Pragma</FONT>s
are only allowed at the following places in a program: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<UL Class="SyntaxIndentedBulleted"><LI TYPE=DISC>After a semicolon delimiter, but not within a <FONT FACE="Arial, Helvetica">formal_part</FONT>
or <FONT FACE="Arial, Helvetica">discriminant_part</FONT>.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<UL Class="SyntaxIndentedBulleted"><LI TYPE=DISC>At any place where the syntax rules allow a construct defined
by a syntactic category whose name ends with "<FONT FACE="Arial, Helvetica">declaration</FONT>",
"<FONT FACE="Arial, Helvetica">statement</FONT>", "<FONT FACE="Arial, Helvetica">clause</FONT>",
or "<FONT FACE="Arial, Helvetica">alternative</FONT>", or one
of the syntactic categories <FONT FACE="Arial, Helvetica">variant</FONT>
or <FONT FACE="Arial, Helvetica">exception_handler</FONT>; but not in
place of such a construct. Also at any place where a <FONT FACE="Arial, Helvetica">compilation_unit</FONT>
would be allowed. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="SyntaxIndented">Additional syntax rules and placement restrictions
exist for specific pragmas. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>The above rule
is written in text, rather than in BNF; the syntactic category <FONT FACE="Arial, Helvetica">pragma</FONT>
is not used in any BNF syntax rule. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>A <FONT FACE="Arial, Helvetica">pragma</FONT>
is allowed where a <FONT FACE="Arial, Helvetica">generic_formal_parameter_declaration</FONT>
is allowed. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1276"></A><A NAME="I1277"></A>The <I>name</I>
of a <FONT FACE="Arial, Helvetica">pragma</FONT> is the identifier following
the reserved word <B>pragma</B>. <A NAME="I1278"></A><A NAME="I1279"></A>The
<FONT FACE="Arial, Helvetica">name</FONT> or <FONT FACE="Arial, Helvetica">expression</FONT>
of a <FONT FACE="Arial, Helvetica">pragma_argument_association</FONT>
is a <I>pragma argument</I>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1280"></A><A NAME="I1281"></A>An <I>identifier
specific to a pragma</I> is an identifier that is used in a pragma argument
with special meaning for that pragma. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>To be honest: </B>Whenever
the syntax rules for a given pragma allow "<FONT FACE="Arial, Helvetica">identifier</FONT>"
as an argument of the <FONT FACE="Arial, Helvetica">pragma</FONT>, that
<FONT FACE="Arial, Helvetica">identifier</FONT> is an identifier specific
to that pragma. </FONT></DIV>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Normal"> If an implementation does not recognize the name
of a <FONT FACE="Arial, Helvetica">pragma</FONT>, then it has no effect
on the semantics of the program. Inside such a <FONT FACE="Arial, Helvetica">pragma</FONT>,
the only rules that apply are the Syntax Rules. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>To be honest: </B>This rule
takes precedence over any other rules that imply otherwise. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Note well:
this rule applies only to <FONT FACE="Arial, Helvetica">pragma</FONT>s
whose name is not recognized. If anything else is wrong with a <FONT FACE="Arial, Helvetica">pragma</FONT>
(at compile time), the <FONT FACE="Arial, Helvetica">pragma</FONT> is
illegal. This is true whether the <FONT FACE="Arial, Helvetica">pragma</FONT>
is language defined or implementation defined.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>For example, an expression in
an unrecognized <FONT FACE="Arial, Helvetica">pragma</FONT> does not
cause freezing, even though the rules in <A HREF="AA-13-14.html">13.14</A>,
``<A HREF="AA-13-14.html">Freezing Rules</A>'' say it does; the above
rule overrules those other rules. On the other hand, an expression in
a recognized <FONT FACE="Arial, Helvetica">pragma</FONT> causes freezing,
even if this makes something illegal.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>For another example, an expression
that would be ambiguous is not illegal if it is inside an unrecognized
<FONT FACE="Arial, Helvetica">pragma</FONT>.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.e</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Note, however, that implementations
have to recognize <B>pragma</B> Inline(Foo) and freeze things accordingly,
even if they choose to never do inlining.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.f</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Obviously, the contradiction needs
to be resolved one way or the other. The reasons for resolving it this
way are: The implementation is simple -- the compiler can just ignore
the <FONT FACE="Arial, Helvetica">pragma</FONT> altogether. The interpretation
of constructs appearing inside implementation-defined <FONT FACE="Arial, Helvetica">pragma</FONT>s
is implementation defined. For example: ``<B>pragma</B> Mumble(X);''.
If the current implementation has never heard of Mumble, then it doesn't
know whether X is a name, an expression, or an identifier specific to
the pragma Mumble. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.g</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>To be honest: </B>The syntax
of individual pragmas overrides the general syntax for <FONT FACE="Arial, Helvetica">pragma</FONT>.
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.h</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Thus, an
identifier specific to a pragma is not a <FONT FACE="Arial, Helvetica">name</FONT>,
syntactically; if it were, the visibility rules would be invoked, which
is not what we want.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.i</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>This also implies that named associations
do not allow one to give the arguments in an arbitrary order -- the order
given in the syntax rule for each individual pragma must be obeyed. However,
it is generally possible to leave out earlier arguments when later ones
are given; for example, this is allowed by the syntax rule for pragma
Import (see <A HREF="AA-B-1.html">B.1</A>, ``<A HREF="AA-B-1.html">Interfacing
Pragmas</A>''). As for subprogram calls, positional notation precedes
named notation.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.j</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Note that Ada 83 had no pragmas
for which the order of named associations mattered, since there was never
more than one argument that allowed named associations. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11.k</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>To be honest: </B>The interpretation
of the arguments of implementation-defined pragmas is implementation
defined. However, the syntax rules have to be obeyed. </FONT></DIV>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Normal"> <A NAME="I1282"></A><A NAME="I1283"></A>Any <FONT FACE="Arial, Helvetica">pragma</FONT>
that appears at the place of an executable construct is executed. Unless
otherwise specified for a particular pragma, this execution consists
of the evaluation of each evaluable pragma argument in an arbitrary order.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>For a <FONT FACE="Arial, Helvetica">pragma</FONT>
that appears at the place of an elaborable construct, execution is elaboration.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>An identifier specific to a pragma
is neither a <FONT FACE="Arial, Helvetica">name</FONT> nor an <FONT FACE="Arial, Helvetica">expression</FONT>
-- such identifiers are not evaluated (unless an implementation defines
them to be evaluated in the case of an implementation-defined <FONT FACE="Arial, Helvetica">pragma</FONT>).</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The ``unless otherwise specified''
part allows us (and implementations) to make exceptions, so a <FONT FACE="Arial, Helvetica">pragma</FONT>
can contain an expression that is not evaluated. Note that <FONT FACE="Arial, Helvetica">pragma</FONT>s
in <FONT FACE="Arial, Helvetica">type_definition</FONT>s may contain
expressions that depend on discriminants.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>When we wish to define a pragma
with some run-time effect, we usually make sure that it appears in an
executable context; otherwise, special rules are needed to define the
run-time effect and when it happens. </FONT></DIV>
<H4 ALIGN=CENTER>Implementation Requirements</H4>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Normal"> The implementation shall give a warning message
for an unrecognized pragma name. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>An implementation
is also allowed to have modes in which a warning message is suppressed,
or in which the presence of an unrecognized <FONT FACE="Arial, Helvetica">pragma</FONT>
is a compile-time error. </FONT></DIV>
<H4 ALIGN=CENTER>Implementation Permissions</H4>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Normal"> An implementation may provide implementation-defined
pragmas; the name of an implementation-defined pragma shall differ from
those of the language-defined pragmas. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>Implementation-defined
pragmas.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>The semantics
of implementation-defined pragmas, and any associated rules (such as
restrictions on their placement or arguments), are, of course, implementation
defined. Implementation-defined pragmas may have run-time effects. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Normal"> An implementation may ignore an unrecognized
pragma even if it violates some of the Syntax Rules, if detecting the
syntax error is too complex. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>Many compilers
use extra post-parsing checks to enforce the syntax rules, since the
Ada syntax rules are not LR(k) (for any k). (The grammar is ambiguous,
in fact.) This paragraph allows them to ignore an unrecognized pragma,
without having to perform such post-parsing checks. </FONT></DIV>
<H4 ALIGN=CENTER>Implementation Advice</H4>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Normal"> Normally, implementation-defined pragmas should
have no semantic effect for error-free programs; that is, if the implementation-defined
pragmas are removed from a working program, the program should still
be legal, and should still have the same semantics. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Note that
``semantics'' is not the same as ``effect;'' as explained in <A HREF="AA-1-1-3.html">1.1.3</A>,
the semantics defines a set of possible effects.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Note that adding a <FONT FACE="Arial, Helvetica">pragma</FONT>
to a program might cause an error (either at compile time or at run time).
On the other hand, if the language-specified semantics for a feature
are in part implementation defined, it makes sense to support pragmas
that control the feature, and that have real semantics; thus, this paragraph
is merely a recommendation. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> Normally, an implementation
should not define pragmas that can make an illegal program legal, except
as follows: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>A <FONT FACE="Arial, Helvetica">pragma</FONT> used to complete
a declaration, such as a <FONT FACE="Arial, Helvetica">pragma</FONT>
Import;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>A <FONT FACE="Arial, Helvetica">pragma</FONT> used to configure
the environment by adding, removing, or replacing <FONT FACE="Arial, Helvetica">library_item</FONT>s.
</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>19.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>For example,
it is OK to support Interface, System_Name, Storage_Unit, and Memory_Size
<FONT FACE="Arial, Helvetica">pragma</FONT>s for upward compatibility
reasons, even though all of these <FONT FACE="Arial, Helvetica">pragma</FONT>s
can make an illegal program legal. (The latter three can affect legality
in a rather subtle way: They affect the value of named numbers in System,
and can therefore affect the legality in cases where static expressions
are required.)</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>On the other hand, adding implementation-defined
pragmas to a legal program can make it illegal. For example, a common
kind of implementation-defined pragma is one that promises some property
that allows more efficient code to be generated. If the promise is a
lie, it is best if the user gets an error message. </FONT></DIV>
<H4 ALIGN=CENTER>Incompatibilities With Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>19.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I1284"></A>In Ada 83,
``bad'' <FONT FACE="Arial, Helvetica">pragma</FONT>s are ignored. In
Ada 95, they are illegal, except in the case where the name of the <FONT FACE="Arial, Helvetica">pragma</FONT>
itself is not recognized by the implementation. </FONT></DIV>
<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>19.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I1285"></A>Implementation-defined
<FONT FACE="Arial, Helvetica">pragma</FONT>s may affect the legality
of a program. </FONT></DIV>
<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>19.e</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Implementation-defined <FONT FACE="Arial, Helvetica">pragma</FONT>s
may affect the run-time semantics of the program. This was always true
in Ada 83 (since it was not explicitly forbidden by RM83), but it was
not clear, because there was no definition of ``executing'' or ``elaborating''
a <FONT FACE="Arial, Helvetica">pragma</FONT>. </FONT></DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="SyntaxIndented" Style="margin-bottom: 0.2em">The forms of
List, Page, and Optimize <FONT FACE="Arial, Helvetica">pragma</FONT>s
are as follows:</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="SyntaxIndented"> <B>pragma</B> <A NAME="I1286"></A>List(<A NAME="I1287"></A><FONT FACE="Arial, Helvetica">identifier</FONT>);</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DIV Class="SyntaxIndented"> <B>pragma</B> <A NAME="I1288"></A>Page;</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="SyntaxIndented"> <B>pragma</B> <A NAME="I1289"></A>Optimize(<A NAME="I1290"></A><FONT FACE="Arial, Helvetica">identifier</FONT>);</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="SyntaxIndented">[Other pragmas are defined throughout this
International Standard, and are summarized in <A HREF="AA-L.html">Annex
L</A>.] </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>The language-defined
pragmas are supported by every implementation, although ``supporting''
some of them (for example, Inline) requires nothing more than checking
the arguments, since they act only as advice to the implementation. </FONT></DIV>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<DIV Class="Normal"> A <FONT FACE="Arial, Helvetica">pragma</FONT>
List takes one of the <FONT FACE="Arial, Helvetica">identifier</FONT>s
On or Off as the single argument. This pragma is allowed anywhere a <FONT FACE="Arial, Helvetica">pragma</FONT>
is allowed. It specifies that listing of the compilation is to be continued
or suspended until a List <FONT FACE="Arial, Helvetica">pragma</FONT>
with the opposite argument is given within the same compilation. The
<FONT FACE="Arial, Helvetica">pragma</FONT> itself is always listed if
the compiler is producing a listing.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="Normal"> A <FONT FACE="Arial, Helvetica">pragma</FONT>
Page is allowed anywhere a <FONT FACE="Arial, Helvetica">pragma</FONT>
is allowed. It specifies that the program text which follows the <FONT FACE="Arial, Helvetica">pragma</FONT>
should start on a new page (if the compiler is currently producing a
listing).</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Normal"> A <FONT FACE="Arial, Helvetica">pragma</FONT>
Optimize takes one of the <FONT FACE="Arial, Helvetica">identifier</FONT>s
Time, Space, or Off as the single argument. This <FONT FACE="Arial, Helvetica">pragma</FONT>
is allowed anywhere a <FONT FACE="Arial, Helvetica">pragma</FONT> is
allowed, and it applies until the end of the immediately enclosing declarative
region, or for a <FONT FACE="Arial, Helvetica">pragma</FONT> at the place
of a <FONT FACE="Arial, Helvetica">compilation_unit</FONT>, to the end
of the <FONT FACE="Arial, Helvetica">compilation</FONT>. It gives advice
to the implementation as to whether time or space is the primary optimization
criterion, or that optional optimizations should be turned off. [It is
implementation defined how this advice is followed.] </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>Effect
of pragma Optimize.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>For example,
a compiler might use Time vs. Space to control whether generic instantiations
are implemented with a macro-expansion model, versus a shared-generic-body
model.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We don't define what constitutes
an ``optimization'' -- in fact, it cannot be formally defined in the
context of Ada. One compiler might call something an optional optimization,
whereas another compiler might consider that same thing to be a normal
part of code generation. Thus, the programmer cannot rely on this pragma
having any particular portable effect on the generated code. Some compilers
might even ignore the pragma altogether. </FONT></DIV>
<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <I>Examples of
pragmas:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Examples"><TT><B>pragma</B> List(Off); --<I> turn off listing generation</I><BR>
<B>pragma</B> Optimize(Off); --<I> turn off optional optimizations</I><BR>
<B>pragma</B> Inline(Set_Mask); --<I> generate code for Set_Mask inline</I><BR>
<B>pragma</B> Suppress(Range_Check, On => Index); --<I> turn off range checking on Index</I></TT></DIV>
<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>29.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I1291"></A>The Optimize
<FONT FACE="Arial, Helvetica">pragma</FONT> now allows the identifier
Off to request that normal optimization be turned off.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>An Optimize <FONT FACE="Arial, Helvetica">pragma</FONT>
may appear anywhere pragmas are allowed. </FONT></DIV>
<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>29.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We now describe the pragmas Page,
List, and Optimize here, to act as examples, and to remove the normative
material from <A HREF="AA-L.html">Annex L</A>, ``<A HREF="AA-L.html">Language-Defined
Pragmas</A>'', so it can be entirely an informative annex. </FONT></DIV>
<P><BR><BR></P>
<HR>
<P><BR></P>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-2-7.html">Previous</A> <A HREF="AA-2-9.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|