Index: debug.adb =================================================================== --- debug.adb (revision 118179) +++ debug.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2005, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -104,8 +104,8 @@ package body Debug is -- d.i -- d.j -- d.k - -- d.l - -- d.m + -- d.l Use Ada 95 semantics for limited function returns + -- d.m For -gnatl, print full source only for main unit -- d.n -- d.o -- d.p @@ -115,11 +115,38 @@ package body Debug is -- d.t -- d.u -- d.v - -- d.w + -- d.w Do not check for infinite while loops -- d.x No exception handlers -- d.y -- d.z + -- d.A + -- d.B + -- d.C + -- d.D + -- d.E + -- d.F + -- d.G + -- d.H + -- d.I + -- d.J + -- d.K + -- d.L + -- d.M + -- d.N + -- d.O + -- d.P + -- d.Q + -- d.R + -- d.S + -- d.T + -- d.U + -- d.V + -- d.W + -- d.X + -- d.Y + -- d.Z + -- d1 Error msgs have node numbers where possible -- d2 Eliminate error flags in verbose form error messages -- d3 Dump bad node in Comperr on an abort @@ -133,7 +160,7 @@ package body Debug is -- Debug flags for binder (GNATBIND) -- da All links (including internal units) listed if there is a cycle - -- db + -- db Output information from Better_Choice -- dc List units as they are chosen -- dd -- de Elaboration dependencies including system units @@ -146,7 +173,7 @@ package body Debug is -- dl -- dm -- dn List details of manipulation of Num_Pred values - -- do + -- do Use old preference for elaboration order -- dp -- dq -- dr @@ -403,6 +430,8 @@ package body Debug is -- in preelaborable packages, but this restriction is a huge pain, -- especially in the predefined library units. + -- dQ needs full documentation ??? + -- dR Bypass the check for a proper version of s-rpc being present -- to use the -gnatz? switch. This allows debugging of the use -- of stubs generation without needing to have GLADE (or some @@ -445,6 +474,19 @@ package body Debug is -- in seriously non-conforming behavior, but is useful sometimes -- when tracking down handling of complex expressions. + -- d.l Use Ada 95 semantics for limited function returns. This may be + -- used to work around the incompatibility introduced by AI-318-2. + -- It is useful only in -gnat05 mode. + + -- d.m When -gnatl is used, the normal output includes full listings of + -- all files in the extended main source (body/spec/subunits). If this + -- debug switch is used, then the full listing is given only for the + -- main source (this corresponds to a previous behavior of -gnatl and + -- is used for running the ACATS tests). + + -- d.w This flag turns off the scanning of while loops to detect possible + -- infinite loops. + -- d.x No exception handlers in generated code. This causes exception -- handlers to be eliminated from the generated code. They are still -- fully compiled and analyzed, they just get eliminated from the @@ -519,6 +561,12 @@ package body Debug is -- the algorithm used to determine a correct order of elaboration. This -- is useful in diagnosing any problems in its behavior. + -- do Use old elaboration order preference. The new preference rules + -- prefer specs with no bodies to specs with bodies, and between two + -- specs with bodies, prefers the one whose body is closer to being + -- able to be elaborated. This is a clear improvement, but we provide + -- this debug flag in case of regressions. + -- du List unit name and file name for each unit as it is read in -- dx Force the binder to read (and then ignore) the xref information Index: gnat_ugn.texi =================================================================== --- gnat_ugn.texi (revision 118179) +++ gnat_ugn.texi (working copy) @@ -324,8 +324,8 @@ The GNAT Make Program gnatmake Improving Performance * Performance Considerations:: -* Reducing the Size of Ada Executables with gnatelim:: -* Reducing the Size of Executables with unused subprogram/data elimination:: +* Reducing Size of Ada Executables with gnatelim:: +* Reducing Size of Executables with unused subprogram/data elimination:: Performance Considerations * Controlling Run-Time Checks:: @@ -339,14 +339,14 @@ Performance Considerations * Coverage Analysis:: @end ifset -Reducing the Size of Ada Executables with gnatelim +Reducing Size of Ada Executables with gnatelim * About gnatelim:: * Running gnatelim:: * Correcting the List of Eliminate Pragmas:: * Making Your Executables Smaller:: * Summary of the gnatelim Usage Cycle:: -Reducing the Size of Executables with unused subprogram/data elimination +Reducing Size of Executables with unused subprogram/data elimination * About unused subprogram/data elimination:: * Compilation options:: @@ -630,7 +630,7 @@ Compatibility and Porting Guide * Compatibility with Other Ada 95 Systems:: * Representation Clauses:: @ifset vms -* Transitioning from Alpha to I64 OpenVMS:: +* Transitioning to 64-Bit GNAT for OpenVMS:: @end ifset @ifset unw @@ -3902,6 +3902,10 @@ For details of the possible selections f see @ref{Character Set Control}. @end ifset +@item -gnatjnn +@cindex @option{-gnatjnn} (@command{gcc}) +Reformat error messages to fit on nn character lines + @item -gnatk=@var{n} @cindex @option{-gnatk} (@command{gcc}) Limit file names to @var{n} (1-999) characters ^(@code{k} = krunch)^^. @@ -3910,6 +3914,12 @@ Limit file names to @var{n} (1-999) char @cindex @option{-gnatl} (@command{gcc}) Output full source listing with embedded error messages. +@item -gnatL +@cindex @option{-gnatL} (@command{gcc}) +Used in conjunction with -gnatG or -gnatD to intersperse original +source lines (as comment lines with line numbers) in the expanded +source output. + @item -gnatm=@var{n} @cindex @option{-gnatm} (@command{gcc}) Limit number of detected error or warning messages to @var{n} @@ -4298,24 +4308,47 @@ used the only source lines output are th The @code{l} stands for list. @end ifclear This switch causes a full listing of -the file to be generated. The output might look as follows: +the file to be generated. In the case where a body is +compiled, the corresponding spec is also listed, along +with any subunits. Typical output from compiling a package +body @file{p.adb} might look like: -@smallexample +@smallexample @c ada @cartouche - 1. procedure E is - 2. V : Integer; - 3. funcion X (Q : Integer) - | - >>> Incorrect spelling of keyword "function" - 4. return Integer; - | - >>> ";" should be "is" - 5. begin - 6. return Q + Q; - 7. end; - 8. begin - 9. V := X + X; -10.end E; + Compiling: p.adb + + 1. package body p is + 2. procedure a; + 3. procedure a is separate; + 4. begin + 5. null + | + >>> missing ";" + + 6. end; + +Compiling: p.ads + + 1. package p is + 2. pragma Elaborate_Body + | + >>> missing ";" + + 3. end p; + +Compiling: p-a.adb + + 1. separate p + | + >>> missing "(" + + 2. procedure a is + 3. begin + 4. null + | + >>> missing ";" + + 5. end; @end cartouche @end smallexample @@ -4326,6 +4359,16 @@ standard output is redirected, a brief s @file{stderr} (standard error) giving the number of error messages and warning messages generated. +@item -^gnatl^OUTPUT_FILE^=file +@cindex @option{^-gnatl^OUTPUT_FILE^=fname} (@command{gcc}) +This has the same effect as @code{-gnatl} except that the output is +written to a file instead of to standard output. If the given name +@file{fname} does not start with a period, then it is the full name +of the file to be written. If @file{fname} is an extension, it is +appended to the name of the file being compiled. For example, if +file @file{xyz.adb} is compiled with @option{^-gnatl^OUTPUT_FILE^=.lst}, +then the output is written to file ^xyz.adb.lst^xyz.adb_lst^. + @item -gnatU @cindex @option{-gnatU} (@command{gcc}) This switch forces all error messages to be preceded by the unique @@ -4408,6 +4451,19 @@ List possible interpretations for ambigu Additional details on incorrect parameters @end itemize +@item -gnatjnn +@cindex @option{-gnatjnn} (@command{gcc}) +In normal operation mode (or if @option{-gnatj0} is used, then error messages +with continuation lines are treated as though the continuation lines were +separate messages (and so a warning with two continuation lines counts as +three warnings, and is listed as three separate messages). + +If the @option{-gnatjnn} switch is used with a positive value for nn, then +messages are output in a different manner. A message and all its continuation +lines are treated as a unit, and count as only one warning or message in the +statistics totals. Furthermore, the message is reformatted so that no line +is longer than nn characters. + @item -gnatq @cindex @option{-gnatq} (@command{gcc}) @ifclear vms @@ -4496,6 +4552,10 @@ Possible order of elaboration problems Unreachable code @item +Address clauses with possibly unaligned values, or where an attempt is +made to overlay a smaller variable with a larger one. + +@item Fixed-point type declarations with a null range @item @@ -4612,8 +4672,11 @@ A range in a @code{for} loop that is kno @end itemize @noindent -The following switches are available to control the handling of -warning messages: +The following section lists compiler switches that are available +to control the handling of warning messages. It is also possible +to excercise much finer control over what warnings are issued and +suppressed using the GNAT pragma Warnings, which is documented +in the GNAT Reference manual. @table @option @c !sort! @@ -4626,7 +4689,8 @@ individually controlled. The warnings t switch are @option{-gnatwd} (implicit dereferencing), @option{-gnatwh} (hiding), -and @option{-gnatwl} (elaboration warnings). +@option{-gnatwl} (elaboration warnings), +and @option{-gnatwt} (tracking of deleted conditional code). All other optional warnings are turned on. @item -gnatwA @@ -4667,7 +4731,7 @@ Note that this warning does not get issued for the use of boolean variables or constants whose values are known at compile time, since this is a standard technique for conditional compilation in Ada, and this would generate too many -``false positive'' warnings. +false positive warnings. This warning option also activates a special test for comparisons using the operators ``>='' and`` <=''. @@ -4719,7 +4783,8 @@ as errors, and prevent the generation of @cindex Formals, unreferenced This switch causes a warning to be generated if a formal parameter is not referenced in the body of the subprogram. This warning can -also be turned on using @option{-gnatwa} or @option{-gnatwu}. +also be turned on using @option{-gnatwa} or @option{-gnatwu}. The +default is that these warnings are not generated. @item -gnatwF @emph{Suppress warnings on unreferenced formals.} @@ -4794,7 +4859,8 @@ case of Annex J, not all features are fl of the renamed packages (like @code{Text_IO}) and use of package @code{ASCII} are not flagged, since these are very common and would generate many annoying positive warnings. The default is that -such warnings are not generated. +such warnings are not generated. This warning is also turned on by +the use of @option{-gnatwa}. In addition to the above cases, warnings are also generated for GNAT features that have been provided in past versions but which @@ -4816,7 +4882,9 @@ This switch disables warnings on use of @emph{Activate warnings on variables that could be constants.} @cindex @option{-gnatwk} (@command{gcc}) This switch activates warnings for variables that are initialized but -never modified, and then could be declared constants. +never modified, and then could be declared constants. The default is that +such warnings are not given. +This warning can also be turned on using @option{-gnatwa}. @item -gnatwK @emph{Suppress warnings on variables that could be constants.} @@ -4852,6 +4920,7 @@ whose value is never read. The warning i variables and also for variables that are renamings of other variables or for which an address clause is given. This warning can also be turned on using @option{-gnatwa}. +The default is that these warnings are not given. @item -gnatwM @emph{Disable warnings on modified but unreferenced variables.} @@ -4893,7 +4962,8 @@ another. This switch activates warnings for failure of front end inlining (activated by @option{-gnatN}) to inline a particular call. There are many reasons for not being able to inline a call, including most -commonly that the call is too complex to inline. +commonly that the call is too complex to inline. The default is +that such warnings are not given. This warning can also be turned on using @option{-gnatwa}. @item -gnatwP @@ -4903,12 +4973,31 @@ This switch suppresses warnings on ineff inlining mechanism cannot inline a call, it will simply ignore the request silently. +@item -gnatwq +@emph{Activate warnings on questionable missing parentheses.} +@cindex @option{-gnatwq} (@command{gcc}) +@cindex Parentheses, warnings +This switch activates warnings for cases where parentheses are not used and +the result is potential ambiguity from a readers point of view. For example +(not a > b) when a and b are modular means (not (a) > b) and very likely the +programmer intended (not (a > b)). Similarly (-x mod 5) means (-(x mod 5)) and +quite likely ((-x) mod 5) was intended. In such situations it seems best to +follow the rule of always parenthesizing to make the association clear, and +this warning switch warns if such parentheses are not present. The default +is that these warnings are not given. +This warning can also be turned on using @option{-gnatwa}. + +@item -gnatwQ +@emph{Suppress warnings on questionable missing parentheses.} +@cindex @option{-gnatwQ} (@command{gcc}) +This switch suppresses warnings for cases where the association is not +clear and the use of parentheses is preferred. + @item -gnatwr @emph{Activate warnings on redundant constructs.} @cindex @option{-gnatwr} (@command{gcc}) This switch activates warnings for redundant constructs. The following is the current list of constructs regarded as redundant: -This warning can also be turned on using @option{-gnatwa}. @itemize @bullet @item @@ -4931,6 +5020,9 @@ to be non-negative Comparison of boolean expressions to an explicit True value. @end itemize +This warning can also be turned on using @option{-gnatwa}. +The default is that warnings for redundant constructs are not given. + @item -gnatwR @emph{Suppress warnings on redundant constructs.} @cindex @option{-gnatwR} (@command{gcc}) @@ -4945,6 +5037,22 @@ Note that it does not suppress warnings To suppress these back end warnings as well, use the switch @option{-w} in addition to @option{-gnatws}. +@item -gnatwt +@emph{Activate warnings for tracking of deleted conditional code.} +@cindex @option{-gnatwt} (@command{gcc}) +@cindex Deactivated code, warnings +@cindex Deleted code, warnings +This switch activates warnings for tracking of code in conditionals (IF and +CASE statements) that is detected to be dead code which cannot be executed, and +which is removed by the front end. This warning is off by default, and is not +turned on by @option{-gnatwa}, it has to be turned on explicitly. This may be +useful for detecting deactivated code in certified applications. + +@item -gnatwT +@emph{Suppress warnings for tracking of deleted conditional code.} +@cindex @option{-gnatwT} (@command{gcc}) +This switch suppresses warnings for tracking of deleted conditional code. + @item -gnatwu @emph{Activate warnings on unused entities.} @cindex @option{-gnatwu} (@command{gcc}) @@ -4981,6 +5089,7 @@ the effect of @option{-gnatwF}). This switch activates warnings for access to variables which may not be properly initialized. The default is that such warnings are generated. +This warning can also be turned on using @option{-gnatwa}. @item -gnatwV @emph{Suppress warnings on unassigned variables.} @@ -4988,24 +5097,29 @@ such warnings are generated. This switch suppresses warnings for access to variables which may not be properly initialized. -@item -gnatwy -@emph{Activate warnings for Ada 2005 compatibility issues.} -@cindex @option{-gnatwy} (@command{gcc}) -@cindex Ada 2005 compatibility issues warnings -For the most part Ada 2005 is upwards compatible with Ada 95, -but there are some exceptions (for example the fact that -@code{interface} is now a reserved word in Ada 2005). This -switch activates several warnings to help in identifying -and correcting such incompatibilities. The default is that -these warnings are generated. Note that at one point Ada 2005 -was called Ada 0Y, hence the choice of character. +@item -gnatww +@emph{Activate warnings on wrong low bound assumption.} +@cindex @option{-gnatww} (@command{gcc}) +@cindex String indexing warnings +This switch activates warnings for indexing an unconstrained string parameter +with a literal or S'Length. This is a case where the code is assuming that the +low bound is one, which is in general not true (for example when a slice is +passed). The default is that such warnings are generated. +This warning can also be turned on using @option{-gnatwa}. +F -@item -gnatwY -@emph{Disable warnings for Ada 2005 compatibility issues.} -@cindex @option{-gnatwY} (@command{gcc}) -@cindex Ada 2005 compatibility issues warnings -This switch suppresses several warnings intended to help in identifying -incompatibilities between Ada 95 and Ada 2005. +@item -gnatwW +@emph{Suppress warnings on wrong low bound assumption.} +@cindex @option{-gnatwW} (@command{gcc}) +This switch activates warnings for indexing an unconstrained string parameter +with a literal or S'Length. This warning can also be suppressed by providing +an Assert pragma that checks the low bound, for example: + +@smallexample @c ada + procedure K (S : String) is + pragma Assert (S'First = 1); + ... +@end smallexample @item -gnatwx @emph{Activate warnings on Export/Import pragmas.} @@ -5018,6 +5132,7 @@ default parameters in a convention C pro because the C compiler cannot supply the proper default, so a warning is issued. The default is that such warnings are generated. +This warning can also be turned on using @option{-gnatwa}. @item -gnatwX @emph{Suppress warnings on Export/Import pragmas.} @@ -5027,6 +5142,26 @@ The sense of this is that you are tellin you know what you are doing in writing the pragma, and it should not complain at you. +@item -gnatwy +@emph{Activate warnings for Ada 2005 compatibility issues.} +@cindex @option{-gnatwy} (@command{gcc}) +@cindex Ada 2005 compatibility issues warnings +For the most part Ada 2005 is upwards compatible with Ada 95, +but there are some exceptions (for example the fact that +@code{interface} is now a reserved word in Ada 2005). This +switch activates several warnings to help in identifying +and correcting such incompatibilities. The default is that +these warnings are generated. Note that at one point Ada 2005 +was called Ada 0Y, hence the choice of character. +This warning can also be turned on using @option{-gnatwa}. + +@item -gnatwY +@emph{Disable warnings for Ada 2005 compatibility issues.} +@cindex @option{-gnatwY} (@command{gcc}) +@cindex Ada 2005 compatibility issues warnings +This switch suppresses several warnings intended to help in identifying +incompatibilities between Ada 95 and Ada 2005. + @item -gnatwz @emph{Activate warnings on unchecked conversions.} @cindex @option{-gnatwz} (@command{gcc}) @@ -5035,6 +5170,7 @@ This switch activates warnings for unche where the types are known at compile time to have different sizes. The default is that such warnings are generated. +This warning can also be turned on using @option{-gnatwa}. @item -gnatwZ @emph{Suppress warnings on unchecked conversions.} @@ -5227,6 +5363,18 @@ expressions have valid values. If you us are present, then the program is erroneous, and wild jumps or memory overwriting may occur. +@item -gnatVe +@emph{Validity checks for elementary components.} +@cindex @option{-gnatVe} (@command{gcc}) +In the absence of this switch, assignments to record or array components are +not validity checked, even if validity checks for assignments generally +(@option{-gnatVc}) are turned on. In Ada, assignment of composite values do not +require valid data, but assignment of individual components does. So for +example, there is a difference between copying the elements of an array with a +slice assignment, compared to assigning element by element in a loop. This +switch allows you to turn off validity checking for components, even when they +are assigned component by component. + @item -gnatVf @emph{Validity checks for floating-point values.} @cindex @option{-gnatVf} (@command{gcc}) @@ -5276,7 +5424,8 @@ This includes all operators in package @ the shift operators defined as intrinsic in package @code{Interfaces} and operands for attributes such as @code{Pos}. Checks are also made on individual component values for composite comparisons, and on the -expressions in type conversions and qualified expressions. +expressions in type conversions and qualified expressions. Checks are +also made on explicit ranges using .. (e.g. slices, loops etc). @item -gnatVp @emph{Validity checks for parameters.} @@ -6040,14 +6189,13 @@ this default Ada95 mode without problems use of @option{-gnat83} to run in Ada 83 mode). In Ada 95 mode, the use of Ada 2005 features will in general cause error -messages or warnings. Some specialized releases of GNAT (notably the GAP -academic version) operate in Ada 2005 mode by default (see section below +messages or warnings. Some specialized releases of GNAT (notably the GPL +edition) operate in Ada 2005 mode by default (see section below describing the use of @option{-gnat05} to run in Ada 2005 mode). For such versions the @option{-gnat95} switch may be used to enforce Ada 95 mode. This option also can be used to cancel the effect of a previous @option{-gnat83} or @option{-gnat05} switch earlier in the command line. - @item -gnat05 (Ada 2005 mode) @cindex @option{-gnat05} (@command{gcc}) @@ -6066,8 +6214,8 @@ generated, reflecting the fact that thes unauthorized extensions to Ada 95. The use of the @option{-gnat05} switch (or an equivalent pragma) causes these messages to be suppressed. -Note that some specialized releases of GNAT (notably the GAP academic -version) have Ada 2005 mode on by default, and in such environments, +Note that some specialized releases of GNAT (notably the GPL edition) +have Ada 2005 mode on by default, and in such environments, the Ada 2005 features can be used freely without the use of switches. @end table @@ -6303,6 +6451,11 @@ do not have any exact analogies in pure is a partial list of these special constructions. See the specification of package @code{Sprint} in file @file{sprint.ads} for a full list. +If the switch @option{-gnatL} is used in conjunction with +@cindex @option{-gnatL} (@command{gcc}) +@option{-gnatG}, then the original source lines are interspersed +in the expanded source (as comment lines with the original line number). + @table @code @item new @var{xxx} [storage_pool = @var{yyy}] Shows the storage pool being used for an allocator. @@ -6397,6 +6550,11 @@ Note that @option{-gnatD} actually impli automatically, so it is not necessary to give both options. In other words @option{-gnatD} is equivalent to @option{-gnatDG}). +If the switch @option{-gnatL} is used in conjunction with +@cindex @option{-gnatL} (@command{gcc}) +@option{-gnatDG}, then the original source lines are interspersed +in the expanded source (as comment lines with the original line number). + @ifclear vms @item -gnatR[0|1|2|3[s]] @cindex @option{-gnatR} (@command{gcc}) @@ -6407,7 +6565,7 @@ the @option{-gnatR} switch). For @option so @option{-gnatR} with no parameter has the same effect), size and alignment information is listed for declared array and record types. For @option{-gnatR2}, size and alignment information is listed for all -expression information for values that are computed at run time for +expressions for values that are computed at run time for variant records. These symbolic expressions have a mostly obvious format with #n being used to represent the value of the n'th discriminant. See source files @file{repinfo.ads/adb} in the @@ -6524,6 +6682,11 @@ is available for the target in use (see @end table @noindent +The same option @option{--RTS} must be used both for @command{gcc} +and @command{gnatbind}. Passing this option to @command{gnatmake} +(@pxref{Switches for gnatmake}) will ensure the required consistency +through the compilation and binding steps. + The @code{setjmp/longjmp} approach is available on all targets, while the @code{zero cost} approach is available on selected targets. To determine whether zero cost exceptions can be used for a @@ -7326,7 +7489,6 @@ semantics should match as closely as pos requirements of the Ada RM, and in particular sets the default scheduling policy to @code{FIFO_Within_Priorities}. - @item ^-u@var{n}^/DYNAMIC_STACK_USAGE=@var{n}^ @cindex @option{^-u^/DYNAMIC_STACK_USAGE^} (@code{gnatbind}) Enable dynamic stack usage, with n result stored and displayed at program @@ -8133,7 +8295,6 @@ Prefer linking with object libraries ove @end table - @node The GNAT Make Program gnatmake @chapter The GNAT Make Program @command{gnatmake} @findex gnatmake @@ -8877,8 +9038,8 @@ elimination feature, which can reduce th @ifnottex @menu * Performance Considerations:: -* Reducing the Size of Ada Executables with gnatelim:: -* Reducing the Size of Executables with unused subprogram/data elimination:: +* Reducing Size of Ada Executables with gnatelim:: +* Reducing Size of Executables with unused subprogram/data elimination:: @end menu @end ifnottex @@ -9253,8 +9414,8 @@ specified. @noindent Calls to subprograms in @code{with}'ed units are normally not inlined. -To achieve this level of inlining, the following conditions must all be -true: +To achieve actual inlining (that is, replacement of the call by the code +in the body of the subprogram), the following conditions must all be true. @itemize @bullet @item @@ -9277,6 +9438,11 @@ The @option{^-gnatn^/INLINE^} switch is used in the @command{gcc} command line @end itemize +Even if all these conditions are met, it may not be possible for +the compiler to inline the call, due to the length of the body, +or features in the body that make it impossible for the compiler +to do the inlining. + Note that specifying the @option{-gnatn} switch causes additional compilation dependencies. Consider the following: @@ -9578,8 +9744,8 @@ the user to determine the distribution o @pxref{Profiling} for details of usage. @end ifset -@node Reducing the Size of Ada Executables with gnatelim -@section Reducing the Size of Ada Executables with @code{gnatelim} +@node Reducing Size of Ada Executables with gnatelim +@section Reducing Size of Ada Executables with @code{gnatelim} @findex gnatelim @noindent @@ -9798,8 +9964,8 @@ $ gnatmake ^-f main_prog^/FORCE_COMPILE @end enumerate -@node Reducing the Size of Executables with unused subprogram/data elimination -@section Reducing the Size of Executables with Unused Subprogram/Data Elimination +@node Reducing Size of Executables with unused subprogram/data elimination +@section Reducing Size of Executables with Unused Subprogram/Data Elimination @findex unused subprogram/data elimination @noindent @@ -9809,6 +9975,7 @@ your executable just by setting options @menu * About unused subprogram/data elimination:: * Compilation options:: +* Example of unused subprogram/data elimination:: @end menu @node About unused subprogram/data elimination @@ -9822,8 +9989,8 @@ never used by this executable. This feature will allow you to eliminate such unused code from your executable, making it smaller (in disk and in memory). -This functionality is only available on native x86 GNU/Linux platform for the -moment. +This functionality is available on all platforms using elf binary format and +having GNU binutils version 2.16.1. @node Compilation options @subsection Compilation options @@ -9844,8 +10011,12 @@ function or data in a separate section i Once the objects and static libraries are created with these options, the linker can perform the dead code elimination. You can do this by setting the @option{-Wl,--gc-sections} option to gcc command or in the -@option{-largs} section of gnatmake. This will create the final executable, -without including the code and data determined as never accessed. +@option{-largs} section of gnatmake. This will perform a garbage collection of +code and data never referenced. + +If the linker performs a partial link (@option{-r} ld linker option), then you +will need to provide one or several entry point using the +@option{-e} / @option{--entry} ld option. Note that objects compiled without the @option{-ffunction-sections} and @option{-fdata-sections} options can still be linked with the executable. @@ -9853,8 +10024,69 @@ However, no dead code elimination will b be linked as is). The GNAT static library is now compiled with -ffunction-sections and --fdata-sections. This allows you to eliminate the unused code of the GNAT -library from your executable. +-fdata-sections on some platforms. This allows you to eliminate the unused code +and data of the GNAT library from your executable. + +@node Example of unused subprogram/data elimination +@subsection Example of unused subprogram/data elimination + +@noindent +Here is a simple example: + +@smallexample @c ada +with Aux; + +procedure Test is +begin + Aux.Used (10); +end Test; + +package Aux is + Used_Data : Integer; + Unused_Data : Integer; + + procedure Used (Data : Integer); + procedure Unused (Data : Integer); +end Aux; + +package body Aux is + procedure Used (Data : Integer) is + begin + Used_Data := Data; + end Used; + + procedure Unused (Data : Integer) is + begin + Unused_Data := Data; + end Unused; +end Aux; +@end smallexample + +@noindent +@code{Unused} and @code{Unused_Data} are never referenced in this code +excerpt, and hence they may be safely removed from the final executable. + +@smallexample +$ gnatmake test + +$ nm test | grep used +020015f0 T aux__unused +02005d88 B aux__unused_data +020015cc T aux__used +02005d84 B aux__used_data + +$ gnatmake test -cargs -fdata-sections -ffunction-sections \ + -largs -Wl,--gc-sections + +$ nm test | grep used +02005350 T aux__used +0201ffe0 B aux__used_data +@end smallexample + +@noindent +It can be observed that the procedure @code{Unused} and the object +@code{Unused_Data} are removed by the linker when using the +appropriate options. @c ******************************** @node Renaming Files Using gnatchop @@ -15778,7 +16010,6 @@ the description of the @command{gnatmetr Alternatively, you may use a project file and invoke @command{gnatmetric} through the @command{gnat} driver. - The @command{gnatmetric} command has the form @smallexample @@ -16004,7 +16235,6 @@ The number of blank lines @end table - @node Syntax Metrics Control @subsection Syntax Metrics Control @cindex Syntax metrics control in @command{gnatmetric} @@ -18219,7 +18449,6 @@ user and it is implicitly used for each for T1'Storage_Size use 10_000; @end smallexample - @node The GNAT Debug Pool Facility @section The GNAT Debug Pool Facility @findex Debug Pool @@ -18424,6 +18653,12 @@ $ gnatmake -g my_program -largs -lgmem @end smallexample @noindent +As library @file{libgmem.a} contains an alternate body for package +@code{System.Memory}, @file{s-memory.adb} should not be compiled and linked +when an executable is linked with library @file{libgmem.a}. It is then not +recommended to use @command{gnatmake} with switch @option{^-a^/ALL_FILES^}. + +@noindent When @file{my_program} is executed, the file @file{gmem.out} is produced. This file contains information about all allocations and deallocations performed by the program. It is produced by the instrumented allocations and @@ -18904,11 +19139,11 @@ amount of straightforward ASIS-based pro @command{gnatcheck} has the command-line interface of the form @smallexample -$ gnatcheck [@i{switches}] @{@i{filename}@} [@i{^-files^/FILES^=@{arg_list_filename@}}] +$ gnatcheck [@i{switches}] @{@i{filename}@} + [@i{^-files^/FILES^=@{arg_list_filename@}}] [@i{-cargs gcc_switches}] [@i{-rules rule_options}] @end smallexample - @noindent where @itemize @bullet @@ -18967,7 +19202,6 @@ messages ordered by rules. Section 3 contains messages ordered by source files. @end itemize - @node General gnatcheck Switches @section General @command{gnatcheck} Switches @@ -20679,7 +20913,6 @@ begin end STB; @end smallexample - @c ****************************** @ifset vms @node Compatibility with HP Ada @@ -20708,7 +20941,7 @@ Except where otherwise indicated, the de applies to both the Alpha and I64 platforms. For information on porting Ada code from GNAT on Alpha OpenVMS to GNAT on -I64 OpenVMS, see @ref{Transitioning from Alpha to I64 OpenVMS}. +I64 OpenVMS, see @ref{Transitioning to 64-Bit GNAT for OpenVMS}. The discussion in this chapter addresses specifically the implementation of Ada 83 for HP OpenVMS Alpha Systems. In cases where the implementation @@ -20721,7 +20954,6 @@ be implemented. The description of prag @cite{GNAT Reference Manual} indicates whether or not they are applicable to non-VMS systems. - @menu * Ada 95 Compatibility:: * Differences in the Definition of Package System:: @@ -21038,7 +21270,7 @@ adds directly to package @code{System}. The type @code{System.Address} is a 64-bit integer type in GNAT for I64 OpenVMS. For more information, -see @ref{Transitioning from Alpha to I64 OpenVMS}. +see @ref{Transitioning to 64-Bit GNAT for OpenVMS}. GNAT is compatible with HP Ada in its handling of address clauses, except for some limitations in @@ -21278,7 +21510,6 @@ HP Ada can call C code that is already t GNAT uses the facilities of DECthreads, and Ada tasks are mapped to threads. - @node Assigning Task IDs @subsection Assigning Task IDs @@ -21637,14 +21868,12 @@ incompatibilities and to make them inter (@pxref{Changes to DECLIB}, for details). The units are located in the @file{DECLIB} directory. - The GNAT RTL is contained in the @file{ADALIB} directory, and the default search path is set up to find @code{DECLIB} units in preference to @code{ADALIB} units with the same name (@code{TEXT_IO}, @code{SEQUENTIAL_IO}, and @code{DIRECT_IO}, for example). - @menu * Changes to DECLIB:: @end menu @@ -22272,7 +22501,6 @@ use with @value{EDITION} on Alpha and I6 Aside from the debugger, all the OpenVMS tools identified are part of the DECset package. - @iftex @c Specify table in TeX since Texinfo does a poor job @tex @@ -22340,10 +22568,10 @@ of the DECset package. @c the TeX version above for the printed version @flushleft @c @multitable @columnfractions .3 .4 .4 -@multitable {Source Code Analyzer /}{Product with HP Ada}{Product with GNAT Pro} +@multitable {Source Code Analyzer /}{Tool with HP Ada}{Tool with GNAT Pro} @item @i{Tool} - @tab @i{Product with HP Ada} - @tab @i{Product with @value{EDITION}} + @tab @i{Tool with HP Ada} + @tab @i{Tool with @value{EDITION}} @item Code Management@*System @tab HP CMS @tab HP CMS @@ -22377,7 +22605,6 @@ of the DECset package. @end ifset - @c ************************************** @node Platform-Specific Information for the Run-Time Libraries @appendix Platform-Specific Information for the Run-Time Libraries @@ -25355,6 +25582,13 @@ which were not properly specified by add @code{Elaborate_All} pragmas, then indeed it is possible that two different compilers can choose different orders. +However, GNAT does attempt to diagnose the common situation where there +are uninitialized variables in the visible part of a package spec, and the +corresponding package body has an elaboration block that directly or +indirectly initialized one or more of these variables. This is the situation +in which a pragma Elaborate_Body is usually desirable, and GNAT will generate +a warning that suggests this addition if it detects this situation. + The @code{gnatbind} @option{^-p^/PESSIMISTIC_ELABORATION^} switch may be useful in smoking out problems. This switch causes bodies to be elaborated as late as possible @@ -26118,7 +26352,7 @@ applications developed in other Ada envi * Compatibility with HP Ada 83:: @end ifclear @ifset vms -* Transitioning from Alpha to I64 OpenVMS:: +* Transitioning to 64-Bit GNAT for OpenVMS:: @end ifset @end menu @@ -26630,8 +26864,14 @@ indicates whether or not they are applic @end ifclear @ifset vms -@node Transitioning from Alpha to I64 OpenVMS -@section Transitioning from Alpha to I64 OpenVMS +@node Transitioning to 64-Bit GNAT for OpenVMS +@section Transitioning to 64-Bit @value{EDITION} for OpenVMS + +@noindent +This section is meant to assist users of pre-2006 @value{EDITION} +for Alpha OpenVMS who are transitioning to 64-bit @value{EDITION}, +the version of the GNAT technology supplied in 2006 and later for +OpenVMS on both Alpha and I64. @menu * Introduction to transitioning:: @@ -26641,12 +26881,10 @@ indicates whether or not they are applic @end menu @node Introduction to transitioning -@subsection Introduction to transitioning +@subsection Introduction @noindent -This section is meant to assist users of @value{EDITION} -for Alpha OpenVMS who are planning to transition to the I64 architecture. -@value{EDITION} for Open VMS I64 has been designed to meet +64-bit @value{EDITION} for Open VMS has been designed to meet three main goals: @enumerate @@ -26658,7 +26896,7 @@ Allowing maximum backward compatibility, Ada source code @item -Supplying a path for exploiting the full I64 address range +Supplying a path for exploiting the full 64-bit address range @end enumerate @noindent @@ -26681,18 +26919,16 @@ this approach provides a simple, gradual use of larger memories than available for 32-bit systems. Also, newly written applications or libraries will by default be fully compatible with future systems exploiting 64-bit -addressing capabilities present in I64. +addressing capabilities. @ref{Migration of 32 bit code}, will focus on porting applications that do not require more than 2 GB of addressable memory. This code will be referred to as @emph{32-bit code}. -For applications intending to exploit the full I64 address space, +For applications intending to exploit the full 64-bit address space, @ref{Taking advantage of 64 bit addressing}, will consider further changes that may be required. -Such code is called @emph{64-bit code} in the -remainder of this guide. - +Such code will be referred to below as @emph{64-bit code}. @node Migration of 32 bit code @subsection Migration of 32-bit code @@ -26702,7 +26938,7 @@ remainder of this guide. * Access types:: * Unchecked conversions:: * Predefined constants:: -* Single source compatibility:: +* Interfacing with C:: * Experience with source compatibility:: @end menu @@ -26722,13 +26958,12 @@ approach has been taken: @code{System.Short_Address} is a 32-bit subtype of @code{System.Address} @end itemize - @noindent Since @code{System.Short_Address} is a subtype of @code{System.Address}, a @code{Short_Address} may be used where an @code{Address} is required, and vice versa, without needing explicit type conversions. -By virtue of the Open VMS I64 parameter passing conventions, +By virtue of the Open VMS parameter passing conventions, even imported and exported subprograms that have 32-bit address parameters are compatible with those that have 64-bit address parameters. @@ -26748,8 +26983,8 @@ generally uses representation clauses to layout where required. If such a representation clause uses 32 bits for a component having -the type @code{System.Address}, GNAT Pro for OpenVMS I64 will detect -that error and produce a specific diagnostic message. +the type @code{System.Address}, 64-bit @value{EDITION} for OpenVMS +will detect that error and produce a specific diagnostic message. The developer should then determine whether the representation should be 64 bits or not and make either of two changes: change the size to 64 bits and leave the type as @code{System.Address}, or @@ -26801,13 +27036,16 @@ as the source type. @subsubsection Predefined constants @noindent -The following predefined constants have changed: - -@multitable {@code{System.Address_Size}} {2**32} {2**64} -@item @b{Constant} @tab @b{Old} @tab @b{New} -@item @code{System.Word_Size} @tab 32 @tab 64 -@item @code{System.Memory_Size} @tab 2**32 @tab 2**64 -@item @code{System.Address_Size} @tab 32 @tab 64 +The following table shows the correspondence between pre-2006 versions of +@value{EDITION} on Alpha OpenVMS (``Old'') and 64-bit @value{EDITION} +(``New''): + +@multitable {@code{System.Short_Memory_Size}} {2**32} {2**64} +@item @b{Constant} @tab @b{Old} @tab @b{New} +@item @code{System.Word_Size} @tab 32 @tab 64 +@item @code{System.Memory_Size} @tab 2**32 @tab 2**64 +@item @code{System.Short_Memory_Size} @tab 2**32 @tab 2**32 +@item @code{System.Address_Size} @tab 32 @tab 64 @end multitable @noindent @@ -26821,23 +27059,43 @@ The program @command{gnatfind} may be us references to the above constants, so that you can verify that they are still correct. -@node Single source compatibility -@subsubsection Single source compatibility +@node Interfacing with C +@subsubsection Interfacing with C @noindent -In order to allow the same source code to be compiled on -both Alpha and I64 platforms, GNAT Pro for Alpha OpenVMS -defines @code{System.Short_Address} and System.Short_Memory_Size -as aliases of respectively @code{System.Address} and -@code{System.Memory_Size}. -(These aliases also leave the door open for a possible -future ``upgrade'' of OpenVMS Alpha to a 64-bit address space.) +In order to minimize the impact of the transition to 64-bit addresses on +legacy programs, some fundamental types in the @code{Interfaces.C} +package hierarchy continue to be represented in 32 bits. +These types are: @code{ptrdiff_t}, @code{size_t}, and @code{chars_ptr}. +This eases integration with the default HP C layout choices, for example +as found in the system routines in @code{DECC$SHR.EXE}. +Because of this implementation choice, the type fully compatible with +@code{chars_ptr} is now @code{Short_Address} and not @code{Address}. +Depending on the context the compiler will issue a +warning or an error when type @code{Address} is used, alerting the user to a +potential problem. Otherwise 32-bit programs that use +@code{Interfaces.C} should normally not require code modifications + +The other issue arising with C interfacing concerns pragma @code{Convention}. +For VMS 64-bit systems, there is an issue of the appropriate default size +of C convention pointers in the absence of an explicit size clause. The HP +C compiler can choose either 32 or 64 bits depending on compiler options. +GNAT chooses 32-bits rather than 64-bits in the default case where no size +clause is given. This proves a better choice for porting 32-bit legacy +applications. In order to have a 64-bit representation, it is necessary to +specify a size representation clause. For example: + +@smallexample @c ada +type int_star is access Interfaces.C.int; +pragma Convention(C, int_star); +for int_star'Size use 64; -- Necessary to get 64 and not 32 bits +@end smallexample @node Experience with source compatibility @subsubsection Experience with source compatibility @noindent -The Security Server and STARLET provide an interesting ``test case'' +The Security Server and STARLET on I64 provide an interesting ``test case'' for source compatibility issues, since it is in such system code where assumptions about @code{Address} size might be expected to occur. Indeed, there were a small number of occasions in the Security Server @@ -26854,10 +27112,8 @@ there was an implicit assumption that an 32 bits. These compiled without error, but their usage resulted in run-time error returns from STARLET system calls. -To assist in the compile-time detection of such situations, we -plan to include a switch to generate a warning message when a -record component is of type @code{Address}. - +Future GNAT technology enhancements may include a tool that detects and flags +these sorts of potential source code porting problems. @c **************************************** @node Taking advantage of 64 bit addressing @@ -26920,7 +27176,6 @@ use the following representation clause: for T'Storage_Pool use System.Pool_64; @end smallexample - @node Restrictions on use of 64 bit objects @subsubsection Restrictions on use of 64-bit objects @@ -26974,7 +27229,6 @@ but never allocate objects outside the 3 Using general access types ensures maximum compatibility with both 32-bit and 64-bit code. - @node STARLET and other predefined libraries @subsubsection STARLET and other predefined libraries @@ -26989,14 +27243,14 @@ in 64-bit address space are acceptable. @subsection Technical details @noindent -GNAT Pro for Open VMS I64 takes advantage of the freedom given in the Ada -standard with respect to the type of @code{System.Address}. Previous versions -of GNAT Pro have defined this type as private and implemented it as -a modular type. +64-bit @value{EDITION} for Open VMS takes advantage of the freedom given in the +Ada standard with respect to the type of @code{System.Address}. Previous +versions of GNAT Pro have defined this type as private and implemented it as a +modular type. In order to allow defining @code{System.Short_Address} as a proper subtype, and to match the implicit sign extension in parameter passing, -in GNAT Pro for Open VMS I64, @code{System.Address} is defined as a +in 64-bit @value{EDITION} for Open VMS, @code{System.Address} is defined as a visible (i.e., non-private) integer type. Standard operations on the type, such as the binary operators ``+'', ``-'', etc., that take @code{Address} operands and return an @code{Address} result, @@ -27010,10 +27264,9 @@ code portability.) Defining @code{Address} as a visible integer type helps achieve maximum compatibility for existing Ada code, -without sacrificing the capabilities of the I64 architecture. +without sacrificing the capabilities of the 64-bit architecture. @end ifset - @c ************************************************ @ifset unw @node Microsoft Windows Topics @@ -28868,9 +29121,13 @@ approach to debug a program as described It is possible to specify the program stack size at link time. On modern versions of Windows, starting with XP, this is mostly useful to set the size of the main stack (environment task). The other task stacks are set with pragma -Linker_Options or with gnatbind -d. On older versions of Windows (2000, NT4, -etc.), it is not possible to set the reserve size of individual tasks and thus -the link-time stack size applies to all tasks. +Storage_Size or with gnatbind -d. + +Older versions of Windows (2000, NT4, etc.) do +not provide any means of setting the reserve size of individual tasks, thus the +link-time stack size applies to all tasks and pragma Storage_Size has no effect. +It means, in particular, that Stack Overflow checks are made against this +link-time specified size. This setting can be done with @command{gnatlink} using either: @@ -28928,7 +29185,6 @@ because the coma is a separator for this @end itemize - @end ifset @c ********************************** Index: gnat_rm.texi =================================================================== --- gnat_rm.texi (revision 118179) +++ gnat_rm.texi (working copy) @@ -8,7 +8,7 @@ @c o @c G N A T _ RM o @c o -@c Copyright (C) 1995-2005 Free Software Foundation o +@c Copyright (C) 1995-2006 Free Software Foundation o @c o @c o @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o @@ -17,8 +17,7 @@ @setfilename gnat_rm.info -@set FSFEDITION - +@set EDITION GNAT @settitle GNAT Reference Manual @setchapternewpage odd @@ -176,6 +175,7 @@ Implementation Defined Pragmas * Pragma Stream_Convert:: * Pragma Style_Checks:: * Pragma Subtitle:: +* Pragma Suppress:: * Pragma Suppress_All:: * Pragma Suppress_Exception_Locations:: * Pragma Suppress_Initialization:: @@ -196,6 +196,7 @@ Implementation Defined Pragmas * Pragma Volatile:: * Pragma Warnings:: * Pragma Weak_External:: +* Pragma Wide_Character_Encoding:: Implementation Defined Attributes @@ -234,6 +235,7 @@ Implementation Defined Attributes * Safe_Large:: * Small:: * Storage_Unit:: +* Stub_Type:: * Target_Name:: * Tick:: * To_Address:: @@ -716,6 +718,7 @@ consideration, the use of these pragmas * Pragma Stream_Convert:: * Pragma Style_Checks:: * Pragma Subtitle:: +* Pragma Suppress:: * Pragma Suppress_All:: * Pragma Suppress_Exception_Locations:: * Pragma Suppress_Initialization:: @@ -736,6 +739,7 @@ consideration, the use of these pragmas * Pragma Volatile:: * Pragma Warnings:: * Pragma Weak_External:: +* Pragma Wide_Character_Encoding:: @end menu @node Pragma Abort_Defer @@ -3052,32 +3056,41 @@ will always generate an invalid value if Syntax: @smallexample @c ada -pragma Obsolescent [(static_string_EXPRESSION [,Ada_05])]; +pragma Obsolescent + (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]); @end smallexample @noindent -This pragma can occur immediately following a subprogram -declaration and indicates that the associated function or procedure +This pragma can occur immediately following a declaration of an entity, +including the case of a record component, and usually the Entity name +must match the name of the entity declared by this declaration. +Alternatively, the pragma can immediately follow an +enumeration type declaration, where the entity argument names one of the +enumeration literals. + +This pragma is used to indicate that the named entity is considered obsolescent and should not be used. Typically this is used when an API must be modified by eventually removing or modifying -existing subprograms. The pragma can be used at an intermediate stage -when the subprogram is still present, but will be removed later. +existing subprograms or other entities. The pragma can be used at an +intermediate stage when the entity is still present, but will be +removed later. The effect of this pragma is to output a warning message on a call to a program thus marked that the subprogram is obsolescent if the appropriate warning option in the -compiler is activated. If a parameter is present, then a second +compiler is activated. If the string parameter is present, then a second warning message is given containing this text. In addition, a call to such a program is considered a violation of pragma Restrictions (No_Obsolescent_Features). This pragma can also be used as a program unit pragma for a package, -in which case it indicates that the entire package is considered +in which case the entity name is the name of the package, and the +pragma indicates that the entire package is considered obsolescent. In this case a client @code{with}'ing such a package violates the restriction, and the @code{with} statement is flagged with warnings if the warning option is set. -If the optional second parameter is present (which must be exactly +If the optional third parameter is present (which must be exactly the identifier Ada_05, no other argument is allowed), then the indication of obsolescence applies only when compiling in Ada 2005 mode. This is primarily intended for dealing with the situations @@ -3085,6 +3098,47 @@ in the predefined library where subprogr have become defined as obsolescent in Ada 2005 (e.g. in Ada.Characters.Handling), but may be used anywhere. +The following examples show typical uses of this pragma: + +@smallexample @c ada +package p is + pragma Obsolescent + (Entity => p, "use pp instead of p"); +end p; + +package q is + procedure q2; + pragma Obsolescent + (Entity => q2, "use q2new instead"); + + type R is new integer; + pragma Obsolescent + (Entity => R, "use RR in Ada 2005", Ada_05); + + type M is record + F1 : Integer; + F2 : Integer; + pragma Obsolescent (Entity => F2); + F3 : Integer; + end record; + + type E is (a, bc, 'd', quack); + pragma Obsolescent (Entity => bc) + pragma Obsolescent (Entity => 'd') + + function "+" + (a, b : character) return character; + pragma Obsolescent (Entity => "+"); +end; +@end smallexample + +@noindent +In an earlier version of GNAT, the Entity parameter was not required, +and this form is still accepted for compatibility purposes. If the +Entity parameter is omitted, then the pragma applies to the declaration +immediately preceding the pragma (this form cannot be used for the +enumeration literal case). + @node Pragma Passive @unnumberedsec Pragma Passive @findex Passive @@ -3718,6 +3772,24 @@ pragma Subtitle ([Subtitle =>] STRING_LI This pragma is recognized for compatibility with other Ada compilers but is ignored by GNAT@. +@node Pragma Suppress +@unnumberedsec Pragma Suppress +@findex Suppress +@noindent +Syntax: + +@smallexample @c ada +pragma Suppress (Identifier [, [On =>] Name]); +@end smallexample + +@noindent +This is a standard pragma, and supports all the check names required in +the RM. It is included here because GNAT recognizes one additional check +name: @code{Alignment_Check} which can be used to suppress alignment checks +on addresses used in address clauses. Such checks can also be suppressed +by suppressing range checks, but the specific use of @code{Alignment_Check} +allows suppression of alignment checks without suppressing other range checks. + @node Pragma Suppress_All @unnumberedsec Pragma Suppress_All @findex Suppress_All @@ -3966,64 +4038,12 @@ pragma Unchecked_Union (first_subtype_lo @end smallexample @noindent -This pragma is used to declare that the specified type should be represented -in a manner -equivalent to a C union type, and is intended only for use in -interfacing with C code that uses union types. In Ada terms, the named -type must obey the following rules: - -@itemize @bullet -@item -It is a non-tagged non-limited record type. -@item -It has a single discrete discriminant with a default value. -@item -The component list consists of a single variant part. -@item -Each variant has a component list with a single component. -@item -No nested variants are allowed. -@item -No component has an explicit default value. -@item -No component has a non-static constraint. -@end itemize - -@noindent -In addition, given a type that meets the above requirements, the -following restrictions apply to its use throughout the program: - -@itemize @bullet -@item -The discriminant name can be mentioned only in an aggregate. -@item -No subtypes may be created of this type. -@item -The type may not be constrained by giving a discriminant value. -@item -The type cannot be passed as the actual for a generic formal with a -discriminant. -@end itemize - -@noindent -Equality and inequality operations on @code{unchecked_unions} are not -available, since there is no discriminant to compare and the compiler -does not even know how many bits to compare. It is implementation -dependent whether this is detected at compile time as an illegality or -whether it is undetected and considered to be an erroneous construct. In -GNAT, a direct comparison is illegal, but GNAT does not attempt to catch -the composite case (where two composites are compared that contain an -unchecked union component), so such comparisons are simply considered -erroneous. - -The layout of the resulting type corresponds exactly to a C union, where -each branch of the union corresponds to a single variant in the Ada -record. The semantics of the Ada program is not changed in any way by -the pragma, i.e.@: provided the above restrictions are followed, and no -erroneous incorrect references to fields or erroneous comparisons occur, -the semantics is exactly as described by the Ada reference manual. -Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the -type and the default convention is C. +This pragma is used to specify a representation of a record type that is +equivalent to a C union. It was introduced as a GNAT implementation defined +pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this +pragma, making it language defined, and GNAT fully implements this extended +version in all language modes (Ada 83, Ada 95, and Ada 2005). For full +details, consult the Ada 2005 RM, section 8.3.3. @node Pragma Unimplemented_Unit @unnumberedsec Pragma Unimplemented_Unit @@ -4078,6 +4098,7 @@ Syntax: @smallexample @c ada pragma Unreferenced (local_NAME @{, local_NAME@}); +pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@}); @end smallexample @noindent @@ -4112,6 +4133,12 @@ declaration, then this pragma should not unit would not be flagged); pragma Obsolescent can be used instead for this purpose, see @xref{Pragma Obsolescent}. +The second form of pragma @code{Unreferenced} is used within a context +clause. In this case the arguments must be unit names of units previously +mentioned in @code{with} clauses (similar to the usage of pragma +@code{Elaborate_All}. The effect is to suppress warnings about unreferenced +units. + @node Pragma Unreserve_All_Interrupts @unnumberedsec Pragma Unreserve_All_Interrupts @findex Unreserve_All_Interrupts @@ -4274,8 +4301,10 @@ Dec Ada 83. Syntax: @smallexample @c ada -pragma Warnings (On | Off [, local_NAME]); +pragma Warnings (On | Off); +pragma Warnings (On | Off, local_NAME); pragma Warnings (static_string_EXPRESSION); +pragma Warnings (On | Off, static_string_EXPRESSION); @end smallexample @noindent @@ -4286,14 +4315,14 @@ current unit. If generation of warnings pragma, then no warning messages are output, regardless of the setting of the command line switches. -The form with a single argument is a configuration pragma. +The form with a single argument may be used as a configuration pragma. If the @var{local_NAME} parameter is present, warnings are suppressed for the specified entity. This suppression is effective from the point where it occurs till the end of the extended scope of the variable (similar to the scope of @code{Suppress}). -The form with a static_string_EXPRESSION argument provides more precise +The form with a single static_string_EXPRESSION argument provides more precise control over which warnings are active. The string is a list of letters specifying which warnings are to be activated and which deactivated. The code for these letters is the same as the string used in the command @@ -4326,7 +4355,7 @@ l turn on warnings for missing elabora L turn off warnings for missing elaboration pragma m turn on warnings for variable assigned but not read M turn off warnings for variable assigned but not read -n normal warning mode (cancels s/e) +n normal warning mode (cancels -gnatws/-gnatwe) o turn on warnings for address clause overlay O turn off warnings for address clause overlay p turn on warnings for ineffective pragma Inline @@ -4338,6 +4367,8 @@ u turn on warnings for unused entity U turn off warnings for unused entity v turn on warnings for unassigned variable V turn off warnings for unassigned variable +w turn on warnings for wrong low bound assumption +W turn off warnings for wrong low bound assumption x turn on warnings for export/import X turn off warnings for export/import y turn on warnings for Ada 2005 incompatibility @@ -4351,7 +4382,39 @@ The specified warnings will be in effect or another pragma Warnings is encountered. The effect of the pragma is cumulative. Initially the set of warnings is the standard default set as possibly modified by compiler switches. Then each pragma Warning -modifies this set of warnings as specified. +modifies this set of warnings as specified. This form of the pragma may +also be used as a configuration pragma. + +The fourth form, with an On|Off parameter and a string, is used to +control individual messages, based on their text. The string argument +is a pattern that is used to match against the text of individual +warning messages (not including the initial "warnings: " tag). + +The pattern may start with an asterisk, which matches otherwise unmatched +characters at the start of the message, and it may also end with an asterisk +which matches otherwise unmatched characters at the end of the message. For +example, the string "*alignment*" could be used to match any warnings about +alignment problems. Within the string, the sequence "*" can be used to match +any sequence of characters enclosed in quotation marks. No other regular +expression notations are permitted. All characters other than asterisk in +these three specific cases are treated as literal characters in the match. + +There are two ways to use this pragma. The OFF form can be used as a +configuration pragma. The effect is to suppress all warnings (if any) +that match the pattern string throughout the compilation. + +The second usage is to suppress a warning locally, and in this case, two +pragmas must appear in sequence: + +@smallexample @c ada +pragma Warnings (Off, Pattern); +.. code where given warning is to be suppressed +pragma Warnings (On, Pattern); +@end smallexample + +@noindent +In this usage, the pattern string must match in the Off and On pragmas, +and at least one matching warning must be suppressed. @node Pragma Weak_External @unnumberedsec Pragma Weak_External @@ -4404,6 +4467,32 @@ package body External_Module is end External_Module; @end smallexample +@node Pragma Wide_Character_Encoding +@unnumberedsec Pragma Wide_Character_Encoding +@findex Wide_Character_Encoding +@noindent +Syntax: + +@smallexample @c ada +pragma Wide_Character_Encoding (IDENTIFIER | CHRARACTER_LITERAL); +@end smallexample + +@noindent +This pragma specifies the wide character encoding to be used in program +source text appearing subsequently. It is a configuration pragma, but may +also be used at any point that a pragma is allowed, and it is permissible +to have more than one such pragma in a file, allowing multiple encodings +to appear within the same file. + +The argument can be an identifier or a character literal. In the identifier +case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS}, +@code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal +case it is correspondingly one of the characters h,u,s,e,8,b. + +Note that when the pragma is used within a file, it affects only the +encoding within that file, and does not affect withed units, specs, +or subunits. + @node Implementation Defined Attributes @chapter Implementation Defined Attributes Ada 95 defines (throughout the Ada 95 reference manual, @@ -4459,6 +4548,7 @@ consideration, you should minimize the u * Safe_Large:: * Small:: * Storage_Unit:: +* Stub_Type:: * Target_Name:: * Tick:: * To_Address:: @@ -5041,6 +5131,27 @@ this attribute when applied to floating- @code{Standard'Storage_Unit} (@code{Standard} is the only permissible prefix) provides the same value as @code{System.Storage_Unit}. +@node Stub_Type +@unnumberedsec Stub_Type +@findex Stub_Type +@noindent +The GNAT implementation of remote access-to-classwide types is +organised as described in AARM section E.4 (20.t): a value of an RACW type +(designating a remote object) is represented as a normal access +value, pointing to a "stub" object which in turn contains the +necessary information to contact the designated remote object. A +call on any dispatching operation of such a stub object does the +remote call, if necessary, using the information in the stub object +to locate the target partition, etc. + +For a prefix @code{T} that denotes a remote access-to-classwide type, +@code{T'Stub_Type} denotes the type of the corresponding stub objects. + +By construction, the layout of @code{T'Stub_Type} is identical to that of +type @code{RACW_Stub_Type} declared in the internal implementation-defined +unit @code{System.Partition_Interface}. Use of this attribute will create +an implicit dependency on this unit. + @node Target_Name @unnumberedsec Target_Name @findex Target_Name @@ -7376,13 +7487,17 @@ where the certification protocol require @findex No_Dispatching_Calls This restriction ensures at compile time that the code generated by the compiler involves no dispatching calls. The use of this restriction allows the -safe use of record extensions and membership tests and ensures that the code -contains no indirect calls through a dispatching mechanism. (Note that this -includes internally-generated calls created by the compiler, for example in -the implementation of the predefined attributes on class-wide objects.) The +safe use of record extensions, classwide membership tests and other classwide +features not involving implicit dispatching. This restriction ensures that +the code contains no indirect calls through a dispatching mechanism. Note that +this includes internally-generated calls created by the compiler, for example +in the implementation of class-wide objects assignments. The membership test is allowed in the presence of this restriction, because its -implementation requires no dispatching. The following example indicates -constructs that violate this restriction. +implementation requires no dispatching. +This restriction is comparable to the official Ada restriction +@code{No_Dispatch} except that it is a bit less restrictive in that it allows +all classwide constructs that do not imply dispatching. +The following example indicates constructs that violate this restriction. @smallexample package Pkg is @@ -7400,10 +7515,11 @@ end Pkg; with Pkg; use Pkg; procedure Example is procedure Test (O : T'Class) is - N : Natural := O'Size; -- Error: Dispatching call + N : Natural := O'Size;-- Error: Dispatching call + C : T'Class := O; -- Error: implicit Dispatching Call begin if O in DT'Class then -- OK : Membership test - Q (DT (O)); -- OK : Type conversion plus direct call + Q (DT (O)); -- OK : Type conversion plus direct call else P (O); -- Error: Dispatching call end if; @@ -7599,6 +7715,14 @@ registry procedure). This restriction i a unit by unit basis, it need not be obeyed consistently throughout a partition. +In the case of aggregates with others, if the aggregate has a dynamic +size, there is no way to eliminate the elaboration code (such dynamic +bounds would be incompatible with @code{Preelaborate} in any case. If +the bounds are static, then use of this restriction actually modifies +the code choice of the compiler to avoid generating a loop, and instead +generate the aggregate statically if possible, no matter how many times +the data for the others clause must be repeatedly generated. + It is not possible to precisely document the constructs which are compatible with this restriction, since, unlike most other restrictions, this is not a restriction on the @@ -7617,6 +7741,10 @@ can be done by the loader, and requires is not possible to document the precise conditions under which the optimizer can figure this out. +Note that this the implementation of this restriction requires full +code generation. If it is used in conjunction with "semantics only" +checking, then some cases of violations may be missed. + @item No_Entry_Queue @findex No_Entry_Queue This restriction is a declaration that any protected entry compiled in @@ -10223,7 +10351,8 @@ Since this source of erroneous behavior checks (at compile time if possible, generating a warning, or at execution time with a run-time check) that the alignment is appropriate. If the run-time check fails, then @code{Program_Error} is raised. This run-time -check is suppressed if range checks are suppressed, or if +check is suppressed if range checks are suppressed, or if the special GNAT +check Alignment_Check is suppressed, or if @code{pragma Restrictions (No_Elaboration_Code)} is in effect. @findex Export @@ -10340,7 +10469,7 @@ conventions, and for example records are consistent with C@. This means that specifying convention C (for example) has no effect. -There are three exceptions to this general rule: +There are four exceptions to this general rule: @itemize @bullet @@ -10389,6 +10518,14 @@ then the GNAT generated code will treat values generated by GNAT, the conventional value 1 will be used for True, but when one of these values is read, any nonzero value is treated as True. +@item Access types on OpenVMS +For 64-bit OpenVMS systems, access types (other than those for unconstrained +arrays) are 64-bits long. An exception to this rule is for the case of +C-convention access types where there is no explicit size clause present (or +inheritied for derived types). In this case, GNAT chooses to make these +pointers 32-bits, which provides an easier path for migration of 32-bit legacy +code. size clause specifying 64-bits must be used to obtain a 64-bit pointer. + @end itemize @node Determining the Representations chosen by GNAT @@ -11615,10 +11752,49 @@ On input, brackets coding can also be us e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation is only used for wide characters with a code greater than @code{16#FF#}. +Note that brackets coding is not normally used in the context of +Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as +a portable way of encoding source files. In the contect of Wide_Text_IO +or Wide_Wide_Text_IO, it can only be used if the file does not contain +any instance of the left bracket character other than to encode wide +character values using the brackets encoding method. In practice it is +expected that some standard wide character encoding method such +as UTF-8 will be used for text input output. + +If brackets notation is used, then any occurrence of a left bracket +in the input file which is not the start of a valid wide character +sequence will cause Constraint_Error to be raised. It is possible to +encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO +input will interpret this as a left bracket. + +However, when a left bracket is output, it will be output as a left bracket +and not as ["5B"]. We make this decision because for normal use of +Wide_Text_IO for outputting messages, it is unpleasant to clobber left +brackets. For example, if we write: + +@smallexample + Put_Line ("Start of output [first run]"); +@end smallexample + +@noindent +we really do not want to have the left bracket in this message clobbered so +that the output reads: + +@smallexample + Start of output ["5B"]first run] +@end smallexample + +@noindent +In practice brackets encoding is reasonably useful for normal Put_Line use +since we won't get confused between left brackets and wide character +sequences in the output. But for input, or when files are written out +and read back in, it really makes better sense to use one of the standard +encoding methods such as UTF-8. + @end table @noindent -For the coding schemes other than Hex and Brackets encoding, +For the coding schemes other than UTF-8, Hex, or Brackets encoding, not all wide character values can be represented. An attempt to output a character that cannot be represented using the encoding scheme for the file causes @@ -13796,6 +13972,10 @@ optimizations with respect to the instru suppressed, and that in particular, for an instruction that has outputs, the instruction will still be generated, even if none of the outputs are used. See the full description in the GCC manual for further details. +Generally it is strongly advisable to use Volatile for any ASM statement +that is missing either input or output operands, or when two or more ASM +statements appear in sequence, to avoid unwanted optimizations. A warning +is generated if this advice is not followed. The @code{Asm} subprograms may be used in two ways. First the procedure forms can be used anywhere a procedure call would be valid, and Index: gnat-style.texi =================================================================== --- gnat-style.texi (revision 118179) +++ gnat-style.texi (working copy) @@ -712,7 +712,7 @@ alternative forms for the above spec are @item Function and procedure bodies should usually be sorted alphabetically. Do not attempt to sort them in some logical order by functionality. For a -sequence of subrpgroams specs, a general alphabetical sorting is also +sequence of subprogram specs, a general alphabetical sorting is also usually appropriate, but occasionally it makes sense to group by major function, with appropriate headers. @@ -749,7 +749,8 @@ A sequence of declarations may optionall begin by a blank line. Just as we optionally allow blank lines in general between declarations, this blank line should be present only if it improves readability. Generally we avoid this blank line if the declarative part is -small (one or two lines) and we include it if the declarative part is long. +small (one or two lines) and the body has no blank lines, and we include it +if the declarative part is long or if the body has blank lines. @item If the declarations in a subprogram contain at least one nested @@ -766,8 +767,78 @@ subprogram, there is a comment line and @end group @end smallexample +@item +When nested subprograms are present, variables that are referenced by any +nested subprogram should precede the nested subprogram specs. For variables +that are not referenced by nested procedures, the declarations can either also +be before any of the nested subprogram specs (this is the old style, more +generally used). Or then can come just before the begin, with a header. The +following example shows the two possible styles: + +@smallexample @c adanocomment +@group + procedure Style1 is + Var_Referenced_In_Nested : Integer; + Var_Referenced_Only_In_Style1 : Integer; + + proc Nested; + -- Comments ... + + + ------------ + -- Nested -- + ------------ + + procedure Nested is + begin + ... + end Nested; + + -- Start of processing for Style1 + + begin + ... + end Style1; + +@end group + +@group + procedure Style2 is + Var_Referenced_In_Nested : Integer; + + proc Nested; + -- Comments ... + + ------------ + -- Nested -- + ------------ + + procedure Nested is + begin + ... + end Nested; + + -- Local variables + + Var_Referenced_Only_In_Style2 : Integer; + + -- Start of processing for Style2 + + begin + ... + end Style2; + +@end group +@end smallexample + +@noindent +For new code, we generally prefer Style2, but we do not insist on +modifying all legacy occurrences of Style1, which is still much +more common in the sources. + @end itemize + @c ------------------------------------------------------------------------- @node Packages, Program Structure, Subprograms, Top @section Packages and Visibility Rules Index: ug_words =================================================================== --- ug_words (revision 118179) +++ ug_words (working copy) @@ -56,6 +56,7 @@ gcc -c ^ GNAT COMPILE -gnatdc ^ /TRACE_UNITS -gnatdO ^ /REPORT_ERRORS=IMMEDIATE -gnatC ^ /COMPRESS_NAMES +-gnatDG ^ /XDEBUG /EXPAND_SOURCEA -gnatD ^ /XDEBUG -gnatec ^ /CONFIGURATION_PRAGMAS_FILE -gnateD ^ /SYMBOL_PREPROCESSING @@ -70,6 +71,10 @@ gcc -c ^ GNAT COMPILE -gnatk ^ /FILE_NAME_MAX_LENGTH -gnatl ^ /LIST -gnatL ^ /LONGJMP_SETJMP +-gnatj ^ /JUSTIFY_MESSAGES +-gnatj0 ^ /NO_JUSTIFY_MESSAGES +-gnatjnn ^ /JUSTIFY_MESSAGES=nn +-gnatL ^ /INTERSPERSE_SOURCE -gnatm ^ /ERROR_LIMIT -gnatm2 ^ /ERROR_LIMIT=2 -gnatn ^ /INLINE=PRAGMA @@ -135,13 +140,19 @@ gcc -c ^ GNAT COMPILE -gnatwO ^ /WARNINGS=NOOVERLAYS -gnatwp ^ /WARNINGS=INEFFECTIVE_INLINE -gnatwP ^ /WARNINGS=NOINEFFECTIVE_INLINE +-gnatwq ^ /WARNINGS=MISSING_PARENS +-gnatwQ ^ /WARNINGS=NOMISSING_PARENS -gnatwr ^ /WARNINGS=REDUNDANT -gnatwR ^ /WARNINGS=NOREDUNDANT -gnatws ^ /WARNINGS=SUPPRESS +-gnatwt ^ /WARNINGS=DELETED_CODE +-gnatwT ^ /WARNINGS=NODELETED_CODE -gnatwu ^ /WARNINGS=UNUSED -gnatwU ^ /WARNINGS=NOUNUSED -gnatwv ^ /WARNINGS=VARIABLES_UNINITIALIZED -gnatwV ^ /WARNINGS=NOVARIABLES_UNINITIALIZED +-gnatww ^ /WARNINGS=LOWBOUND_ASSUMED +-gnatwW ^ /WARNINGS=NOLOWBOUND_ASSUMED -gnatwx ^ /WARNINGS=IMPORT_EXPORT_PRAGMAS -gnatwX ^ /WARNINGS=NOIMPORT_EXPORT_PRAGMAS -gnatwy ^ /WARNINGS=ADA_2005_COMPATIBILITY Index: elists.ads =================================================================== --- elists.ads (revision 118179) +++ elists.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2005, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -86,7 +86,7 @@ package Elists is function Elmts_Address return System.Address; -- Return address of Elmts table (used in Back_End for Gigi call) - function Node (Elmt : Elmt_Id) return Node_Id; + function Node (Elmt : Elmt_Id) return Node_Or_Entity_Id; pragma Inline (Node); -- Returns the value of a given list element. Returns Empty if Elmt -- is set to No_Elmt. @@ -98,13 +98,13 @@ package Elists is function First_Elmt (List : Elist_Id) return Elmt_Id; pragma Inline (First_Elmt); - -- Obtains the first element of the given element list or, if the - -- list has no items, then No_Elmt is returned. + -- Obtains the first element of the given element list or, if the list has + -- no items, then No_Elmt is returned. function Last_Elmt (List : Elist_Id) return Elmt_Id; pragma Inline (Last_Elmt); - -- Obtains the last element of the given element list or, if the - -- list has no items, then No_Elmt is returned. + -- Obtains the last element of the given element list or, if the list has + -- no items, then No_Elmt is returned. function Next_Elmt (Elmt : Elmt_Id) return Elmt_Id; pragma Inline (Next_Elmt); Index: xgnatugn.adb =================================================================== --- xgnatugn.adb (revision 118179) +++ xgnatugn.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2003-2005, Free Software Foundation, Inc. -- +-- Copyright (C) 2003-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -90,7 +90,7 @@ -- this is because we have menu problems if we let makeinfo handle -- these ifset/ifclear pairs. -- Note: @ifset/@ifclear commands for the edition flags (FSFEDITION, --- PROEDITION, ACADEMICEDITION) are passed through unchanged +-- PROEDITION, GPLEDITION) are passed through unchanged with Ada.Command_Line; use Ada.Command_Line; with Ada.Strings; use Ada.Strings; @@ -161,21 +161,21 @@ procedure Xgnatugn is -- It contains the Texinfo source code. Process_Source_File -- performs the necessary replacements. - type Flag_Type is (UNW, VMS, FSFEDITION, PROEDITION, ACADEMICEDITION); + type Flag_Type is (UNW, VMS, FSFEDITION, PROEDITION, GPLEDITION); -- The flags permitted in @ifset or @ifclear commands: -- -- Targets for preprocessing -- UNW (Unix and Windows) or VMS -- -- Editions of the manual - -- FSFEDITION, PROEDITION, or ACADEMICEDITION + -- FSFEDITION, PROEDITION, or GPLEDITION -- -- Conditional commands for target are processed by xgnatugn -- -- Conditional commands for edition are passed through unchanged subtype Target_Type is Flag_Type range UNW .. VMS; - subtype Edition_Type is Flag_Type range FSFEDITION .. ACADEMICEDITION; + subtype Edition_Type is Flag_Type range FSFEDITION .. GPLEDITION; Target : Target_Type; -- The Target variable is initialized using the command line Index: g-arrspl.ads =================================================================== --- g-arrspl.ads (revision 118179) +++ g-arrspl.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2002-2005, Free Software Foundation, Inc. -- +-- Copyright (C) 2002-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -90,6 +90,10 @@ package GNAT.Array_Split is -- is a sequence of Element along which to split the array. The source -- array is sliced at separator boundaries. The separators are not -- included as part of the resulting slices. + -- + -- Note that if From is terminated by a separator an extra empty element + -- is added to the slice set. If From only contains a separator the slice + -- set contains two empty elements. procedure Create (S : out Slice_Set; Index: sem.ads =================================================================== --- sem.ads (revision 118179) +++ sem.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2005, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -269,12 +269,54 @@ package Sem is -- Scope Stack -- ----------------- - -- The scope stack holds all entries of the scope table. As in the parser, - -- we use Last as the stack pointer, so that we can always find the scope - -- that is currently open in Scope_Stack.Table (Scope_Stack.Last). The - -- oldest entry, at Scope_Stack (0) is Standard. The entries in the table - -- include the entity for the referenced scope, together with information - -- used to restore the proper setting of check suppressions on scope exit. + -- The scope stack indicates the declarative regions that are currently + -- being processed (analyzed and/or expanded). The scope stack is one of + -- basic visibility structures in the compiler: entities that are declared + -- in a scope that is currently on the scope stack are immediately visible. + -- (leaving aside issues of hiding and overloading). + + -- Initially, the scope stack only contains an entry for package Standard. + -- When a compilation unit, subprogram unit, block or declarative region + -- is being processed, the corresponding entity is pushed on the scope + -- stack. It is removed after the processing step is completed. A given + -- entity can be placed several times on the scope stack, for example + -- when processing derived type declarations, freeze nodes, etc. The top + -- of the scope stack is the innermost scope currently being processed. + -- It is obtained through function Current_Scope. After a compilation unit + -- has been processed, the scope stack must contain only Standard. + -- The predicate In_Open_Scopes specifies whether a scope is currently + -- on the scope stack. + + -- This model is complicated by the need to compile units on the fly, in + -- the middle of the compilation of other units. This arises when compiling + -- instantiations, and when compiling run-time packages obtained through + -- rtsfind. Given that the scope stack is a single static and global + -- structure (not originally designed for the recursive processing required + -- by rtsfind for example) additional machinery is needed to indicate what + -- is currently being compiled. As a result, the scope stack holds several + -- contiguous sections that correspond to the compilation of a given + -- compilation unit. These sections are separated by distinct occurrences + -- of package Standard. The currently active section of the scope stack + -- goes from the current scope to the first occurrence of Standard, which + -- is additionally marked with the flag Is_Active_Stack_Base. The basic + -- visibility routine (Find_Direct_Name, sem_ch8) uses this contiguous + -- section of the scope stack to determine whether a given entity is or + -- is not visible at a point. In_Open_Scopes only examines the currently + -- active section of the scope stack. + + -- Similar complications arise when processing child instances. These + -- must be compiled in the context of parent instances, and therefore the + -- parents must be pushed on the stack before compiling the child, and + -- removed afterwards. Routines Save_Scope_Stack and Restore_Scope_Stack + -- are used to set/reset the visibility of entities declared in scopes + -- that are currently on the scope stack, and are used when compiling + -- instance bodies on the fly. + + -- It is clear in retrospect that all semantic processing and visibility + -- structures should have been fully recursive. The rtsfind mechanism, + -- and the complexities brought about by subunits and by generic child + -- units and their instantitions, have led to a hybrid model that carries + -- more state than one would wish. type Scope_Stack_Entry is record Entity : Entity_Id; @@ -294,9 +336,12 @@ package Sem is -- Marks Transient Scopes (See Exp_Ch7 body for details) Previous_Visibility : Boolean; - -- Used when installing the parent (s) of the current compilation - -- unit. The parent may already be visible because of an ongoing - -- compilation, and the proper visibility must be restored on exit. + -- Used when installing the parent(s) of the current compilation unit. + -- The parent may already be visible because of an ongoing compilation, + -- and the proper visibility must be restored on exit. The flag is + -- typically needed when the context of a child unit requires + -- compilation of a sibling. In other cases the flag is set to False. + -- See Sem_Ch10 (Install_Parents, Remove_Parents). Node_To_Be_Wrapped : Node_Id; -- Only used in transient scopes. Records the node which will @@ -306,33 +351,33 @@ package Sem is Actions_To_Be_Wrapped_After : List_Id; -- Actions that have to be inserted at the start or at the end of a -- transient block. Used to temporarily hold these actions until the - -- block is created, at which time the actions are moved to the - -- block. + -- block is created, at which time the actions are moved to the block. Pending_Freeze_Actions : List_Id; - -- Used to collect freeze entity nodes and associated actions that - -- are generated in a inner context but need to be analyzed outside, - -- such as records and initialization procedures. On exit from the - -- scope, this list of actions is inserted before the scope construct - -- and analyzed to generate the corresponding freeze processing and - -- elaboration of other associated actions. + -- Used to collect freeze entity nodes and associated actions that are + -- generated in a inner context but need to be analyzed outside, such as + -- records and initialization procedures. On exit from the scope, this + -- list of actions is inserted before the scope construct and analyzed + -- to generate the corresponding freeze processing and elaboration of + -- other associated actions. First_Use_Clause : Node_Id; - -- Head of list of Use_Clauses in current scope. The list is built - -- when the declarations in the scope are processed. The list is - -- traversed on scope exit to undo the effect of the use clauses. + -- Head of list of Use_Clauses in current scope. The list is built when + -- the declarations in the scope are processed. The list is traversed + -- on scope exit to undo the effect of the use clauses. Component_Alignment_Default : Component_Alignment_Kind; - -- Component alignment to be applied to any record or array types - -- that are declared for which a specific component alignment pragma - -- does not set the alignment. + -- Component alignment to be applied to any record or array types that + -- are declared for which a specific component alignment pragma does not + -- set the alignment. Is_Active_Stack_Base : Boolean; -- Set to true only when entering the scope for Standard_Standard from -- from within procedure Semantics. Indicates the base of the current - -- active set of scopes. Needed by In_Open_Scopes to handle cases - -- where Standard_Standard can be pushed in the middle of the active - -- set of scopes (occurs for instantiations of generic child units). + -- active set of scopes. Needed by In_Open_Scopes to handle cases where + -- Standard_Standard can be pushed anew on the scope stack to start a + -- new active section (see comment above). + end record; package Scope_Stack is new Table.Table ( Index: usage.adb =================================================================== --- usage.adb (revision 118179) +++ usage.adb (working copy) @@ -210,15 +210,27 @@ begin Write_Switch_Char ("i?"); Write_Line ("Identifier char set (?=1/2/3/4/5/8/9/p/f/n/w)"); + -- Line for -gnatj switch + + Write_Switch_Char ("jnn"); + Write_Line ("Format error and warning messages to fit nn character lines"); + -- Line for -gnatk switch Write_Switch_Char ("k"); Write_Line ("Limit file names to nn characters (k = krunch)"); - -- Line for -gnatl switch + -- Lines for -gnatl switch Write_Switch_Char ("l"); Write_Line ("Output full source listing with embedded error messages"); + Write_Switch_Char ("l=f"); + Write_Line ("Output full source listing to specified file"); + + -- Line for -gnatL switch + + Write_Switch_Char ("L"); + Write_Line ("List corresponding source text in -gnatG or -gnatD output"); -- Line for -gnatm switch @@ -317,6 +329,8 @@ begin Write_Line (" C turn off checking for copies"); Write_Line (" d turn on default (RM) checking"); Write_Line (" D turn off default (RM) checking"); + Write_Line (" e turn on checking for elementary components"); + Write_Line (" E turn off checking for elementary components"); Write_Line (" f turn on checking for floating-point"); Write_Line (" F turn off checking for floating-point"); Write_Line (" i turn on checking for in params"); @@ -339,7 +353,7 @@ begin Write_Switch_Char ("wxx"); Write_Line ("Enable selected warning modes, xx = list of parameters:"); - Write_Line (" a turn on all optional warnings (except d,h,l)"); + Write_Line (" a turn on all optional warnings (except d,h,l,t)"); Write_Line (" A turn off all optional warnings"); Write_Line (" b turn on warnings for bad fixed value " & "(not multiple of small)"); @@ -377,13 +391,22 @@ begin Write_Line (" O turn off warnings for address clause overlay"); Write_Line (" p turn on warnings for ineffective pragma Inline"); Write_Line (" P* turn off warnings for ineffective pragma Inline"); + Write_Line (" q turn on warnings for questionable " & + "missing paretheses"); + Write_Line (" Q* turn off warnings for questionable " & + "missing paretheses"); Write_Line (" r turn on warnings for redundant construct"); Write_Line (" R* turn off warnings for redundant construct"); Write_Line (" s suppress all warnings"); + Write_Line (" t turn on warnings for tracking deleted code"); + Write_Line (" T* turn off warnings for tracking deleted code"); Write_Line (" u turn on warnings for unused entity"); Write_Line (" U* turn off warnings for unused entity"); Write_Line (" v* turn on warnings for unassigned variable"); Write_Line (" V turn off warnings for unassigned variable"); + Write_Line (" w* turn on warnings for wrong low bound assumption"); + Write_Line (" W turn off warnings for wrong low bound " & + "assumption"); Write_Line (" x* turn on warnings for export/import"); Write_Line (" X turn off warnings for export/import"); Write_Line (" y* turn on warnings for Ada 2005 incompatibility"); Index: validsw.ads =================================================================== --- validsw.ads (revision 118179) +++ validsw.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2001-2005, Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -47,6 +47,12 @@ package Validsw is -- pragma, then the right side of assignments and also initializing -- expressions in object declarations are checked for validity. + Validity_Check_Components : Boolean := False; + -- Controls validity checking for assignment to elementary components of + -- records. If this switch is set true using -gnatVe, or an 'e' in the + -- argument of Validity_Checks pragma, then the right hand of an assignment + -- to such a component is checked for validity. + Validity_Check_Default : Boolean := True; -- Controls default (reference manual) validity checking. If this switch is -- set to True using -gnatVd or a 'd' in the argument of a Validity_ Checks Index: validsw.adb =================================================================== --- validsw.adb (revision 118179) +++ validsw.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2003 Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -34,6 +34,7 @@ package body Validsw is procedure Reset_Validity_Check_Options is begin + Validity_Check_Components := False; Validity_Check_Copies := False; Validity_Check_Default := True; Validity_Check_Floating_Point := False; @@ -75,6 +76,7 @@ package body Validsw is Add ('n', not Validity_Check_Default); Add ('c', Validity_Check_Copies); + Add ('e', Validity_Check_Components); Add ('f', Validity_Check_Floating_Point); Add ('i', Validity_Check_In_Params); Add ('m', Validity_Check_In_Out_Params); @@ -136,6 +138,9 @@ package body Validsw is when 'd' => Validity_Check_Default := True; + when 'e' => + Validity_Check_Components := True; + when 'f' => Validity_Check_Floating_Point := True; @@ -166,6 +171,9 @@ package body Validsw is when 'D' => Validity_Check_Default := False; + when 'E' => + Validity_Check_Components := False; + when 'I' => Validity_Check_In_Params := False; @@ -191,6 +199,7 @@ package body Validsw is Validity_Check_Tests := False; when 'a' => + Validity_Check_Components := True; Validity_Check_Copies := True; Validity_Check_Default := True; Validity_Check_Floating_Point := True; @@ -203,6 +212,7 @@ package body Validsw is Validity_Check_Tests := True; when 'n' => + Validity_Check_Components := False; Validity_Check_Copies := False; Validity_Check_Default := False; Validity_Check_Floating_Point := False; Index: vms_data.ads =================================================================== --- vms_data.ads (revision 118179) +++ vms_data.ads (working copy) @@ -744,7 +744,7 @@ package VMS_Data is -- -- Work quietly, only output warnings and errors. - S_Check_Sections : aliased constant S := "/SECTIONS= " & + S_Check_Sections : aliased constant S := "/SECTIONS=" & "DEFAULT " & "-s123 " & "COMPILER_STYLE " & @@ -752,7 +752,7 @@ package VMS_Data is "BY_RULES " & "-s2 " & "BY_FILES_BY_RULES " & - "-s3 "; + "-s3"; -- /SECTIONS[=section-option, section-option, ...] -- -- Specify what sections should be included into the report file. @@ -1566,22 +1566,33 @@ package VMS_Data is "!-gnatn,!-gnatN"; -- NODOC (see /INLINE) - S_GCC_Jumps : aliased constant S := "/LONGJMP_SETJMP " & + S_GCC_Intsrc : aliased constant S := "/INTERSPERSE_SOURCE " & "-gnatL"; - -- /NOLONGJMP_SETJMP (D) - -- /LONGJMP_SETJMP - -- - -- Causes the longjmp/setjmp approach to be used for exception handling. + + -- /NO_INTERSPERSE_SOURCE (D) + -- /INTERSPERSE_SOURCE -- - -- The default mechanism for OpenVMS is zero cost exceptions. This - -- qualifier can be used to modify this default, but it must be used for - -- all units in the partition, including all run-time library units. - -- One way to achieve this is to use the /ALL_FILES and /FORCE_COMPILE - -- for gnatmake. - -- This option is rarely used. One case in which it may be advantageous is - -- in an application where exception raising is common and the overall - -- performance of the application is improved by favoring exception - -- propagation. + -- Causes output from /XDEBUG or /EXPAND_SOURCE to be interspersed with + -- lines from the original source file, output as comment lines with the + -- associated line number. + + S_GCC_Just : aliased constant S := "/JUSTIFY_MESSAGES=#" & + "-gnatj#"; + + -- /NO_JUSTIFY_MESSAGES (D) + -- /JUSTIFY_MESSAGES=nnn + -- + -- Causes error messages to be reformatted so that a message and all its + -- continuation lines count as one warning or error in the statistics on + -- total errors, and the message is broken down into lines (justified) so + -- that no line is longer than nnn characters. The default message + -- behavior (each message counted separately and not reformatted to fit + -- a particular line length) can be obtained using /NO_JUSTIFY_MESSAGES. + + S_GCC_JustX : aliased constant S := "/NO_JUSTIFY_MESSAGES " & + "-gnatj0"; + + -- NODOC (see /JUSTIFY_MESSAGES) S_GCC_Length : aliased constant S := "/MAX_LINE_LENGTH=#" & "-gnatyM#"; @@ -1595,7 +1606,9 @@ package VMS_Data is -- /NOLIST (D) -- /LIST -- - -- Cause a full listing of the file to be generated. + -- Cause a full listing of the file to be generated. In the case where + -- a body is compiled, the corresponding spec is also listed, along + -- with any subunits. S_GCC_Mapping : aliased constant S := "/MAPPING_FILE=<" & "-gnatem>"; @@ -1767,6 +1780,19 @@ package VMS_Data is "-O0,!-O1,!-O2,!-O3"; -- NODOC (see /OPTIMIZE) + S_GCC_Output : aliased constant S := "/OUTPUT_FILE=<" & + "-gnatl=>"; + -- /OUTPUT_FILE=fname + -- + -- This has the same effect as /LIST except that the output is written + -- to a file instead of to standard output. If the given fname + -- does not start with a period, then it is the full name of the file + -- to be written. If fname starts with a period, the name of the file + -- is the concatenation of to the name of the file being compiled with + -- fname where the period is replace by an underline. For example, if + -- file xyz.adb is compiled with -gnatl=.lst, then the output is written + -- to file xyz.adb_lst. + S_GCC_Polling : aliased constant S := "/POLLING " & "-gnatP"; -- /NOPOLLING (D) @@ -2539,20 +2565,24 @@ package VMS_Data is "-gnatwp " & "NOINEFFECTIVE_INLINE " & "-gnatwP " & + "MISSING_PARENS " & + "-gnatwq " & + "NOMISSING_PARENS " & + "-gnatwQ " & "MODIFIED_UNREF " & "-gnatwm " & "NOMODIFIED_UNREF " & "-gnatwM " & - "OPTIONAL " & - "-gnatwa " & - "NOOPTIONAL " & - "-gnatwA " & "NORMAL " & "-gnatwn " & "OBSOLESCENT " & "-gnatwj " & "NOOBSOLESCENT " & "-gnatwJ " & + "OPTIONAL " & + "-gnatwa " & + "NOOPTIONAL " & + "-gnatwA " & "OVERLAYS " & "-gnatwo " & "NOOVERLAYS " & @@ -2563,6 +2593,10 @@ package VMS_Data is "-gnatwR " & "SUPPRESS " & "-gnatws " & + "DELETED_CODE " & + "-gnatwt " & + "NODELETED_CODE " & + "-gnatwT " & "UNINITIALIZED " & "-Wuninitialized " & "UNREFERENCED_FORMALS " & @@ -2581,6 +2615,10 @@ package VMS_Data is "-gnatwv " & "NOVARIABLES_UNINITIALIZED " & "-gnatwV " & + "LOWBOUND_ASSUMED " & + "-gnatww " & + "NOLOWBOUND_ASSUMED " & + "-gnatwW " & "IMPORT_EXPORT_PRAGMAS " & "-gnatwx " & "NOIMPORT_EXPORT_PRAGMAS " & @@ -2707,6 +2745,19 @@ package VMS_Data is -- inline a call, it will simply ignore the -- request silently. -- + -- MISSING_PARENS + -- Activate warnings for cases where parentheses + -- are not used and the result is potential + -- ambiguity from a reader's point of view. + -- For example (not a > b) when a and b are + -- modular means (not (a) > b) and very likely + -- the programmer intended (not (a > b)). + -- + -- NOMISSING_PARENS + -- Suppress warnings for cases where parentheses + -- are not used and the result is potential + -- ambiguity from a reader's point of view. + -- -- MODIFIED_UNREF Activates warnings for variables that are -- assigned (using an initialization value or with -- one or more assignment statements) but whose @@ -2853,8 +2904,6 @@ package VMS_Data is S_GCC_Wide : aliased constant S := "/WIDE_CHARACTER_ENCODING=" & "BRACKETS " & "-gnatWb " & - "NONE " & - "-gnatWn " & "HEX " & "-gnatWh " & "UPPER " & @@ -2977,15 +3026,6 @@ package VMS_Data is -- speed up compilation, but means that some -- tools cannot be used. - S_GCC_Zero : aliased constant S := "/ZERO_COST_EXCEPTIONS " & - "-gnatZ"; - -- /ZERO_COST_EXCEPTIONS - -- /NOZERO_COST_EXCEPTIONS - -- - -- As zero-cost exceptions is the default on VMS, this qualifier has - -- no effect, except that it cancels the effect of a previous - -- /LONGJMP_SETJUMP qualifier. - GCC_Switches : aliased constant Switches := (S_GCC_Ada_83 'Access, S_GCC_Ada_95 'Access, @@ -3015,9 +3055,12 @@ package VMS_Data is S_GCC_Immed 'Access, S_GCC_Inline 'Access, S_GCC_InlineX 'Access, - S_GCC_Jumps 'Access, + S_GCC_Intsrc 'Access, + S_GCC_Just 'Access, + S_GCC_JustX 'Access, S_GCC_Length 'Access, S_GCC_List 'Access, + S_GCC_Output 'Access, S_GCC_Mapping 'Access, S_GCC_Mess 'Access, S_GCC_Nesting 'Access, @@ -3056,8 +3099,7 @@ package VMS_Data is S_GCC_WideX 'Access, S_GCC_No_Back 'Access, S_GCC_Xdebug 'Access, - S_GCC_Xref 'Access, - S_GCC_Zero 'Access); + S_GCC_Xref 'Access); ---------------------------- -- Switches for GNAT ELIM -- @@ -4169,6 +4211,14 @@ package VMS_Data is -- -- When looking for source files also look in the specified directories. + S_Make_Stand : aliased constant S := "/STANDARD_OUTPUT_FOR_COMMANDS " & + "-S"; + -- /NOSTANDARD_OUTPUT_FOR_COMMANDS (D) + -- /STANDARD_OUTPUT_FOR_COMMANDS + -- + -- Output the commands for the compiler, the binder and the linker + -- on SYS$OUTPUT, instead of SYS$ERROR. + S_Make_Switch : aliased constant S := "/SWITCH_CHECK " & "-s"; -- /NOSWITCH_CHECK (D) @@ -4251,6 +4301,7 @@ package VMS_Data is S_Make_Search 'Access, S_Make_Skip 'Access, S_Make_Source 'Access, + S_Make_Stand 'Access, S_Make_Switch 'Access, S_Make_Unique 'Access, S_Make_Use_Map 'Access, Index: s-addope.ads =================================================================== --- s-addope.ads (revision 118179) +++ s-addope.ads (working copy) @@ -6,11 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2004-2005 Free Software Foundation, Inc. -- --- -- --- This specification is derived from the Ada Reference Manual for use with -- --- GNAT. The copyright notice above, and the license provisions that follow -- --- apply solely to the implementation dependent sections of this file. -- +-- Copyright (C) 2004-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -59,6 +55,13 @@ package System.Address_Operations is -- Standard (which may or may not be visible depending on the exact -- form of the declaration of type System.Address). + -- For addition, subtraction, and multiplication, the effect of overflow + -- is 2's complement wrapping (as though the type Address were unsigned). + + -- For division and modulus operations, the caller is responsible for + -- ensuring that the Right argument is non-zero, and the effect of the + -- call is not specified if a zero argument is passed. + function AddA (Left, Right : Address) return Address; function SubA (Left, Right : Address) return Address; function MulA (Left, Right : Address) return Address;