diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index 48ff50bd7376..94dc2198b782 100644 --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -93,7 +93,7 @@ package body Debug is -- dY Enable configurable run-time mode -- dZ Generate listing showing the contents of the dispatch tables - -- d.a + -- d.a Enable alignment promotion for non-scalar stand-alone objects -- d.b -- d.c -- d.d @@ -500,6 +500,12 @@ package body Debug is -- - In case of abstract subprograms the text "is abstract" is -- added at the end of the line. + -- d.a Enable alignment promotion for non-VMS targets. On VMS, by default + -- (in Optimize_Alignment (Off) mode), the alignment of stand-alone + -- objects is increased in some cases to enable the generation of + -- better code. Use of this debug flag enables this transformation + -- on non-VMS targets. + -- d.f Suppress folding of static expressions. This of course results -- in seriously non-conforming behavior, but is useful sometimes -- when tracking down handling of complex expressions. @@ -636,6 +642,8 @@ package body Debug is -- Documentation for gnatmake Debug Flags -- -------------------------------------------- + -- df Only output file names, not path names, in log + -- dn Do not delete temporary files created by gnatmake at the end -- of execution, such as temporary config pragma files, mapping -- files or project path files. diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index e85bff7d7123..8e3247d274da 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -8,7 +8,7 @@ @c o @c G N A T _ RM o @c o -@c Copyright (C) 1995-2007, Free Software Foundation o +@c Copyright (C) 1995-2008, Free Software Foundation o @c o @c o @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o @@ -34,7 +34,7 @@ @end direntry @copying -Copyright @copyright{} 1995-2007, 2008 Free Software Foundation, Inc. +Copyright @copyright{} 1995-2008, Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 @@ -108,7 +108,9 @@ Implementation Defined Pragmas * Pragma Assert:: * Pragma Ast_Entry:: * Pragma C_Pass_By_Copy:: +* Pragma Check:: * Pragma Check_Name:: +* Pragma Check_Policy:: * Pragma Comment:: * Pragma Common_Object:: * Pragma Compile_Time_Error:: @@ -174,6 +176,8 @@ Implementation Defined Pragmas * Pragma Passive:: * Pragma Persistent_BSS:: * Pragma Polling:: +* Pragma Postcondition:: +* Pragma Precondition:: * Pragma Profile (Ravenscar):: * Pragma Profile (Restricted):: * Pragma Psect_Object:: @@ -228,12 +232,14 @@ Implementation Defined Attributes * Emax:: * Enabled:: * Enum_Rep:: +* Enum_Val:: * Epsilon:: * Fixed_Value:: * Has_Access_Values:: * Has_Discriminants:: * Img:: * Integer_Value:: +* Invalid_Value:: * Large:: * Machine_Size:: * Mantissa:: @@ -380,6 +386,7 @@ The GNAT Library * GNAT.Table (g-table.ads):: * GNAT.Task_Lock (g-tasloc.ads):: * GNAT.Threads (g-thread.ads):: +* GNAT.Time_Stamp (g-timsta.ads):: * GNAT.Traceback (g-traceb.ads):: * GNAT.Traceback.Symbolic (g-trasym.ads):: * GNAT.UTF_32 (g-utf_32.ads):: @@ -702,7 +709,9 @@ consideration, the use of these pragmas should be minimized. * Pragma Assert:: * Pragma Ast_Entry:: * Pragma C_Pass_By_Copy:: +* Pragma Check:: * Pragma Check_Name:: +* Pragma Check_Policy:: * Pragma Comment:: * Pragma Common_Object:: * Pragma Compile_Time_Error:: @@ -768,6 +777,8 @@ consideration, the use of these pragmas should be minimized. * Pragma Passive:: * Pragma Persistent_BSS:: * Pragma Polling:: +* Pragma Postcondition:: +* Pragma Precondition:: * Pragma Profile (Ravenscar):: * Pragma Profile (Restricted):: * Pragma Psect_Object:: @@ -933,7 +944,7 @@ Syntax: @smallexample @c ada pragma Assert ( boolean_EXPRESSION - [, static_string_EXPRESSION]); + [, string_EXPRESSION]); @end smallexample @noindent @@ -1050,6 +1061,34 @@ You can also pass records by copy by specifying the convention @code{Import} and @code{Export} pragmas, which allow specification of passing mechanisms on a parameter by parameter basis. +@node Pragma Check +@unnumberedsec Pragma Check +@cindex Assertions +@cindex Named assertions +@findex Check +@noindent +Syntax: +@smallexample @c ada +pragma Check ( + [Name =>] Identifier, + [Check =>] Boolean_EXPRESSION + [, [Message =>] string_EXPRESSION] ); +@end smallexample + +@noindent +This pragma is similar to the predefined pragma @code{Assert} except that an +extra identifier argument is present. In conjunction with pragma +@code{Check_Policy}, this can be used to define groups of assertions that can +be independently controlled. The identifier @code{Assertion} is special, it +refers to the normal set of pragma @code{Assert} statements. The identifiers +@code{Precondition} and @code{Postcondition} correspond to the pragmas of these +names, so these three names would normally not be used directly in a pragma +@code{Check}. + +Checks introduced by this pragma are normally deactivated by default. They can +be activated either by the command line option @option{-gnata}, which turns on +all checks, or individually controlled using pragma @code{Check_Policy}. + @node Pragma Check_Name @unnumberedsec Pragma Check_Name @cindex Defining check names @@ -1065,7 +1104,7 @@ pragma Check_Name (check_name_IDENTIFIER); This is a configuration pragma that defines a new implementation defined check name (unless IDENTIFIER matches one of the predefined check names, in which case the pragma has no effect). Check names -are global to a partition, so if two more more configuration pragmas +are global to a partition, so if two or more configuration pragmas are present in a partition mentioning the same name, only one new check name is introduced. @@ -1079,6 +1118,60 @@ the current unit, or if it appears at the start of any unit that is part of the dependency set of the current unit (e.g., units that are mentioned in @code{with} clauses). +@node Pragma Check_Policy +@unnumberedsec Pragma Check_Policy +@cindex Controlling assertions +@cindex Assertions, control +@cindex Check pragma control +@cindex Named assertions +@findex Check +@noindent +Syntax: +@smallexample @c ada +pragma Check_Policy ([Name =>] Identifier, POLICY_IDENTIFIER); + +POLICY_IDENTIFIER ::= On | Off | Check | Ignore +@end smallexample + +@noindent +This pragma is similar to the predefined pragma @code{Assertion_Policy}, +except that it controls sets of named assertions introduced using the +@code{Check} pragmas. It can be used as a configuration pragma or (unlike +@code{Assertion_Policy}) can be used within a declarative part, in which case +it controls the status to the end of the corresponding construct (in a manner +identical to pragma @code{Suppress)}. + +The identifier given as the first argument corresponds to a name used in +associated @code{Check} pragmas. For example, if the pragma: + +@smallexample @c ada +pragma Check_Policy (Critical_Error, Off); +@end smallexample + +@noindent +is given, then subsequent @code{Check} pragmas whose first argument is also +@code{Critical_Error} will be disabled. The special identifier @code{Assertion} +controls the behavior of normal @code{Assert} pragmas (thus a pragma +@code{Check_Policy} with this identifier is similar to the normal +@code{Assertion_Policy} pragma except that it can appear within a +declarative part). + +The special identifiers @code{Precondition} and @code{Postcondition} control +the status of preconditions and postconditions. If a @code{Precondition} pragma +is encountered, it is ignored if turned off by a @code{Check_Policy} specifying +that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use +of the name @code{Postcondition} controls whether @code{Postcondition} pragmas +are recognized. + +The check policy is @code{Off} to turn off corresponding checks, and @code{On} +to turn on corresponding checks. The default for a set of checks for which no +@code{Check_Policy} is given is @code{Off} unless the compiler switch +@option{-gnata} is given, which turns on all checks by default. + +The check policy settings @code{Check} and @code{Ignore} are also recognized +as synonyms for @code{On} and @code{Off}. These synonyms are provided for +compatibility with the standard @code{Assertion_Policy} pragma. + @node Pragma Comment @unnumberedsec Pragma Comment @findex Comment @@ -2767,7 +2860,7 @@ a handler. Note that certain signals on many operating systems cannot be caught and handled by applications. In such cases, the pragma is ignored. See the operating system documentation, or the value of the array @code{Reserved} -declared in the specification of package @code{System.OS_Interface}. +declared in the spec of package @code{System.OS_Interface}. Overriding the default state of signals used by the Ada runtime may interfere with an application's runtime behavior in the cases of the synchronous signals, @@ -3456,9 +3549,10 @@ As noted above, this is a configuration pragma, and there is a requirement that all units in a partition be compiled with a consistent setting of the optimization setting. This would normally be achieved by use of a configuration pragma file containing the appropriate setting. The exception to this rule is -that predefined units in the GNAT library (that is, members of the Ada, System, -Interfaces, GNAT hierarchies) ignore the setting of this pragma, and thus the -consistency requirement does not apply to them. +that units with an explicit configuration pragma in the same file as the source +unit are excluded from the consistency check, as are all predefined units. The +latter are commpiled by default in pragma Optimize_Alignment (Off) mode if no +pragma appears at the start of the file. @node Pragma Passive @unnumberedsec Pragma Passive @@ -3555,6 +3649,194 @@ Note that polling can also be enabled by use of the @option{-gnatP} switch. @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for details. +@node Pragma Postcondition +@unnumberedsec Pragma Postcondition +@cindex Postconditions +@cindex Checks, postconditions +@findex Postconditions +@noindent +Syntax: + +@smallexample @c ada +pragma Postcondition ( + [Check =>] Boolean_Expression + [,[Message =>] String_Expression]); +@end smallexample + +@noindent +The @code{Postcondition} pragma allows specification of automatic +postcondition checks for subprograms. These checks are similar to +assertions, but are automatically inserted just prior to the return +statements of the subprogram with which they are associated. +Furthermore, the boolean expression which is the condition which +must be true may contain references to function'Result in the case +of a function to refer to the returned value. + +@code{Postcondition} pragmas may appear either immediate following the +(separate) declaration of a subprogram, or at the start of the +declarations of a subprogram body. Only other pragmas may intervene +(that is appear between the subprogram declaration and its +postconditions, or appear before the postcondition in the +declaration sequence in a subprogram body). In the case of a +postcondition appearing after a subprogram declaration, the +formal arguments of the subprogram are visible, and can be +referenced in the postcondition expressions. + +The postconditions are collected and automatically tested just +before any return (implicit or explicit) in the subprogram body. +A postcondition is only recognized if postconditions are active +at the time the pragma is encountered. The compiler switch @option{gnata} +turns on all postconditions by default, and pragma @code{Check_Policy} +with an identifier of @code{Postcondition} can also be used to +control whether postconditions are active. + +The general approach is that postconditions are placed in the spec +if they represent functional aspects which make sense to the client. +For example we might have: + +@smallexample @c ada + function Direction return Integer; + pragma Postcondition + (Direction'Result = +1 + or else + Direction'Result = -1); +@end smallexample + +@noindent +which serves to document that the result must be +1 or -1, and +will test that this is the case at run time if postcondition +checking is active. + +Postconditions within the subprogram body can be used to +check that some internal aspect of the implementation, +not visible to the client, is operating as expected. +For instance if a square root routine keeps an internal +counter of the number of times it is called, then we +might have the following postcondition: + +@smallexample @c ada + Sqrt_Calls : Natural := 0; + + function Sqrt (Arg : Float) return Float is + pragma Postcondition + (Sqrt_Calls = Sqrt_Calls'Old + 1); + ... + end Sqrt +@end smallexample + +@noindent +As this example, shows, the use of the @code{Old} attribute +is often useful in postconditions to refer to the state on +entry to the subprogram. + +Note that postconditions are only checked on normal returns +from the subprogram. If an abnormal return results from +raising an exception, then the postconditions are not checked. + +If a postcondition fails, then the exception +@code{System.Assertions.Assert_Failure} is raised. If +a message argument was supplied, then the given string +will be used as the exception message. If no message +argument was supplied, then the default message has +the form "Postcondition failed at file:line". The +exception is raised in the context of the subprogram +body, so it is posssible to catch postcondition failures +within the subprogram body itself. + +Within a package spec, normal visibility rules +in Ada would prevent forward references within a +postcondition pragma to functions defined later in +the same package. This would introduce undesirable +ordering constraints. To avoid this problem, all +postcondition pragmas are analyzed at the end of +the package spec, allowing forward references. + +The following example shows that this even allows +mutually recursive postconditions as in: + +@smallexample @c ada +package Parity_Functions is + function Odd (X : Natural) return Boolean; + pragma Postcondition + (Odd'Result = + (x = 1 + or else + (x /= 0 and then Even (X - 1)))); + + function Even (X : Natural) return Boolean; + pragma Postcondition + (Even'Result = + (x = 0 + or else + (x /= 1 and then Odd (X - 1)))); + +end Parity_Functions; +@end smallexample + +@noindent +There are no restrictions on the complexity or form of +conditions used within @code{Postcondition} pragmas. +The following example shows that it is even possible +to verify performance behavior. + +@smallexample @c ada +package Sort is + + Performance : constant Float; + -- Performance constant set by implementation + -- to match target architecture behavior. + + procedure Treesort (Arg : String); + -- Sorts characters of argument using N*logN sort + pragma Postcondition + (Float (Clock - Clock'Old) <= + Float (Arg'Length) * + log (Float (Arg'Length)) * + Performance); +end Sort; +@end smallexample + +@node Pragma Precondition +@unnumberedsec Pragma Precondition +@cindex Preconditions +@cindex Checks, preconditions +@findex Preconditions +@noindent +Syntax: + +@smallexample @c ada +pragma Precondition ( + [Check =>] Boolean_Expression + [,[Message =>] String_Expression]); +@end smallexample + +@noindent +The @code{Precondition} pragma is similar to @code{Postcondition} +except that the corresponding checks take place immediately upon +entry to the subprogram, and if a precondition fails, the exception +is raised in the context of the caller, and the attribute 'Result +cannot be used within the precondition expression. + +Otherwise, the placement and visibility rules are identical to those +described for postconditions. The following is an example of use +within a package spec: + +@smallexample @c ada +package Math_Functions is + ... + function Sqrt (Arg : Float) return Float; + pragma Precondition (Arg >= 0.0) + ... +end Math_Functions; +@end smallexample + +@code{Postcondition} pragmas may appear either immediate following the +(separate) declaration of a subprogram, or at the start of the +declarations of a subprogram body. Only other pragmas may intervene +(that is appear between the subprogram declaration and its +postconditions, or appear before the postcondition in the +declaration sequence in a subprogram body). + @node Pragma Profile (Ravenscar) @unnumberedsec Pragma Profile (Ravenscar) @findex Ravenscar @@ -4196,7 +4478,7 @@ The @code{Task_Info} pragma provides system dependent control over aspects of tasking implementation, for example, the ability to map tasks to specific processors. For details on the facilities available for the version of GNAT that you are using, see the documentation -in the specification of package System.Task_Info in the runtime +in the spec of package System.Task_Info in the runtime library. @node Pragma Task_Name @@ -4524,7 +4806,7 @@ functions. For example, if this pragma is used, then pressing a program can then handle the @code{SIGINT} interrupt as it chooses. For a full list of the interrupts handled in a specific implementation, -see the source code for the specification of @code{Ada.Interrupts.Names} in +see the source code for the spec of @code{Ada.Interrupts.Names} in file @file{a-intnam.ads}. This is a target dependent file that contains the list of interrupts recognized for a given target. The documentation in this file also specifies what interrupts are affected by the use of @@ -4765,12 +5047,10 @@ 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 +The pattern may contain asterisks which match zero or more characters in +the message. For example, you can use +@code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning +message @code{warning: 960 bits of "a" unused}. 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. @@ -4904,12 +5184,14 @@ consideration, you should minimize the use of these attributes. * Emax:: * Enabled:: * Enum_Rep:: +* Enum_Val:: * Epsilon:: * Fixed_Value:: * Has_Access_Values:: * Has_Discriminants:: * Img:: * Integer_Value:: +* Invalid_Value:: * Large:: * Machine_Size:: * Mantissa:: @@ -5128,7 +5410,7 @@ error. @noindent This attribute can only be applied to a program unit name. It returns the entity for the corresponding elaboration procedure for elaborating -the specification of the referenced unit. This is used in the main +the spec of the referenced unit. This is used in the main generated elaboration procedure by the binder and is not normally used in any other context. However, there may be specialized situations in which it is useful to be able to call this elaboration procedure from @@ -5200,6 +5482,27 @@ integer type, and the argument is a variable, so that the universal integer calculation is done at run time, then the call to @code{Enum_Rep} may raise @code{Constraint_Error}. +@node Enum_Val +@unnumberedsec Enum_Val +@cindex Representation of enums +@findex Enum_Val +@noindent +For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a +function with the following spec: + +@smallexample @c ada +function @var{S}'Enum_Rep (Arg : @i{Universal_Integer) + return @var{S}'Base}; +@end smallexample + +@noindent +The function returns the enumeration value whose representation matches the +argument, or raises Constraint_Error if no enumeration literal of the type +has the matching value. +This will be equal to value of the @code{Val} attribute in the +absence of an enumeration representation clause. This is a static +attribute (i.e.@: the result is static if the argument is static). + @node Epsilon @unnumberedsec Epsilon @cindex Ada 83 attributes @@ -5311,6 +5614,17 @@ that there are full range checks, to ensure that the result is in range. This attribute is primarily intended for use in implementation of the standard input-output functions for fixed-point values. +@node Invalid_Value +@unnumberedsec Invalid_Value +@findex Invalid_Value +@noindent +For every scalar type S, S'Invalid_Value returns an undefined value of the +type. If possible this value is an invalid representation for the type. The +value returned is identical to the value used to initialize an otherwise +uninitialized value of the type if pragma Initialize_Scalars is used, +including the ability to modify the value with the binder -Sxx flag and +relevant environment variables at run time. + @node Large @unnumberedsec Large @cindex Ada 83 attributes @@ -7910,6 +8224,18 @@ is made to queue more than the specified number of tasks on such an entry. This restriction ensures at compile time that there is no implicit or explicit dependence on the package @code{Ada.Calendar}. +@item No_Default_Initialization +@findex No_Default_Initialization + +This restriction prohibits any instance of default initialization of variables. +The binder implements a consistency rule which prevents any unit compiled +without the restriction from with'ing a unit with the restriction (this allows +the generation of initialization procedures to be skipped, since you can be +sure that no call is ever generated to an initialization procedure in a unit +with the restriction active). If used in conjunction with Initialize_Scalars or +Normalize_Scalars, the effect is to prohibit all cases of variables declared +without a specific initializer (including the case of OUT scalar parameters). + @item No_Direct_Boolean_Operators @findex No_Direct_Boolean_Operators This restriction ensures that no logical (and/or/xor) or comparison @@ -8485,11 +8811,11 @@ letters. @end cartouche @noindent The string passed to @code{Linker_Options} is presented uninterpreted as -an argument to the link command, unless it contains Ascii.NUL characters. +an argument to the link command, unless it contains ASCII.NUL characters. NUL characters if they appear act as argument separators, so for example @smallexample @c ada -pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef"); +pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef"); @end smallexample @noindent @@ -9435,9 +9761,10 @@ will be as described for primitive types, e.g.@: a packed array of length @item @emph{Records}. For the normal non-packed case, the alignment of a record is equal to the maximum alignment of any of its components. For tagged records, this -includes the implicit access type used for the tag. If a pragma @code{Pack} is -used and all fields are packable (see separate section on pragma @code{Pack}), -then the resulting alignment is 1. +includes the implicit access type used for the tag. If a pragma @code{Pack} +is used and all components are packable (see separate section on pragma +@code{Pack}), then the resulting alignment is 1, unless the layout of the +record makes it profitable to increase it. A special case is when: @itemize @bullet @@ -9470,7 +9797,8 @@ strict alignment. An alignment clause may specify a larger alignment than the default value up to some maximum value dependent on the target (obtainable by using the attribute reference @code{Standard'Maximum_Alignment}). It may also specify -a smaller alignment than the default value, for example +a smaller alignment than the default value for enumeration, integer and +fixed point types, as well as for record types, for example @smallexample @c ada type V is record @@ -9993,11 +10321,10 @@ In other words, the value specified must be at least equal to the size of this subtype, and must be a multiple of the alignment value. In addition, component size clauses are allowed which cause the array -to be packed, by specifying a smaller value. The cases in which this -is allowed are for component size values in the range 1 through 63. The value -specified must not be smaller than the Size of the subtype. GNAT will -accurately honor all packing requests in this range. For example, if -we have: +to be packed, by specifying a smaller value. A first case is for +component size values in the range 1 through 63. The value specified +must not be smaller than the Size of the subtype. GNAT will accurately +honor all packing requests in this range. For example, if we have: @smallexample @c ada type r is array (1 .. 8) of Natural; @@ -10008,6 +10335,23 @@ for r'Component_Size use 31; then the resulting array has a length of 31 bytes (248 bits = 8 * 31). Of course access to the components of such an array is considerably less efficient than if the natural component size of 32 is used. +A second case is when the subtype of the component is a record type +padded because of its default alignment. For example, if we have: + +@smallexample @c ada +type r is record + i : Integer; + j : Integer; + b : Boolean; +end record; + +type a is array (1 .. 8) of r; +for a'Component_Size use 72; +@end smallexample + +@noindent +then the resulting array has a length of 72 bytes, instead of 96 bytes +if the alignment of the record (4) was obeyed. Note that there is no point in giving both a component size clause and a pragma Pack for the same array type. if such duplicate @@ -10389,6 +10733,8 @@ Any scalar type Any type whose size is specified with a size clause @item Any packed array type with a static size +@item +Any record type padded because of its default alignment @end itemize @noindent @@ -12973,6 +13319,7 @@ of GNAT, and will generate a warning message. * GNAT.Table (g-table.ads):: * GNAT.Task_Lock (g-tasloc.ads):: * GNAT.Threads (g-thread.ads):: +* GNAT.Time_Stamp (g-timsta.ads):: * GNAT.Traceback (g-traceb.ads):: * GNAT.Traceback.Symbolic (g-trasym.ads):: * GNAT.UTF_32 (g-utf_32.ads):: @@ -14072,6 +14419,17 @@ A very simple facility for locking and unlocking sections of code using a single global task lock. Appropriate for use in situations where contention between tasks is very rarely expected. +@node GNAT.Time_Stamp (g-timsta.ads) +@section @code{GNAT.Time_Stamp} (@file{g-timsta.ads}) +@cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads}) +@cindex Time stamp +@cindex Current time + +@noindent +Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that +represents the current date and time in ISO 8601 format. This is a very simple +routine with minimal code and there are no dependencies on any other unit. + @node GNAT.Threads (g-thread.ads) @section @code{GNAT.Threads} (@file{g-thread.ads}) @cindex @code{GNAT.Threads} (@file{g-thread.ads}) @@ -15727,9 +16085,9 @@ Syntax: @smallexample package_declaration ::= - package_specification | package_renaming + package_spec | package_renaming -package_specification ::= +package_spec ::= @b{package} package_identifier @b{is} @{simple_declarative_item@} @b{end} package_identifier ; diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 69a2a3dd66e1..799d720b535b 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -325,6 +325,7 @@ The GNAT Make Program gnatmake Improving Performance * Performance Considerations:: +* Text_IO Suggestions:: * Reducing Size of Ada Executables with gnatelim:: * Reducing Size of Executables with unused subprogram/data elimination:: @@ -417,6 +418,7 @@ File Name Krunching Using gnatkr * Examples of gnatkr Usage:: Preprocessing Using gnatprep +* Preprocessing Symbols:: * Using gnatprep:: * Switches for gnatprep:: * Form of Definitions File:: @@ -3777,6 +3779,16 @@ Any occurrences of pragma @code{Inline} or @code{Inline_Always} are ignored, and @option{-gnatn} and @option{-gnatN} have no effect if this switch is present. +@item -fno-inline-functions +@cindex @option{-fno-inline-functions} (@command{gcc}) +Suppresses automatic inlining of small subprograms, which is enabled +if @option{-O3} is used. + +@item -fno-inline-functions-called-once +@cindex @option{-fno-inline-functions-called-once} (@command{gcc}) +Suppresses inlining of subprograms local to the unit and called once +from within it, which is enabled if @option{-O1} is used. + @item -fno-strict-aliasing @cindex @option{-fno-strict-aliasing} (@command{gcc}) Causes the compiler to avoid assumptions regarding non-aliasing @@ -3823,6 +3835,9 @@ Allow full Ada 2005 features. Assertions enabled. @code{Pragma Assert} and @code{pragma Debug} to be activated. Note that these pragmas can also be controlled using the configuration pragmas @code{Assertion_Policy} and @code{Debug_Policy}. +It also activates pragmas @code{Check}, @code{Precondition}, and +@code{Postcondition}. Note that these pragmas can also be controlled +using the configuration pragma @code{Check_Policy}. @item -gnatA @cindex @option{-gnatA} (@command{gcc}) @@ -4240,7 +4255,7 @@ version, not the GNAT version. Turn off warnings generated by the back end of the compiler. Use of this switch also causes the default for front end warnings to be set to suppress (as though @option{-gnatws} had appeared at the start of -the options. +the options). @end table @@ -4874,6 +4889,13 @@ This switch causes warning messages to be treated as errors. The warning string still appears, but the warning messages are counted as errors, and prevent the generation of an object file. +@item -gnatw.e +@emph{Activate every optional warning} +@cindex @option{-gnatw.e} (@command{gcc}) +@cindex Warnings, activate every optional warning +This switch activates all optional warnings, including those which +are not activated by @code{-gnatwa}. + @item -gnatwf @emph{Activate warnings on unreferenced formals.} @cindex @option{-gnatwf} (@command{gcc}) @@ -4989,20 +5011,32 @@ This warning can also be turned on using @option{-gnatwa}. This switch disables warnings on variables that could be declared constants. @item -gnatwl -@emph{Activate warnings for missing elaboration pragmas.} +@emph{Activate warnings for elaboration pragmas.} @cindex @option{-gnatwl} (@command{gcc}) @cindex Elaboration, warnings This switch activates warnings on missing @code{Elaborate_All} and @code{Elaborate} pragmas. See the section in this guide on elaboration checking for details on -when such pragmas should be used. Warnings are also generated if you +when such pragmas should be used. In dynamic elaboration mode, this switch +generations warnings about the need to add elaboration pragmas. Note however, +that if you blindly follow these warnings, and add @code{Elaborate_All} +warnings wherever they are recommended, you basically end up with the +equivalent of the static elaboration model, which may not be what you want for +legacy code for which the static model does not work. + +For the static model, the messages generated are labeled "info:" (for +information messages). They are not warnings to add elaboration pragmas, +merely informational messages showing what implicit elaboration pragmas +have been added, for use in analyzing elaboration circularity problems. + +Warnings are also generated if you are using the static mode of elaboration, and a @code{pragma Elaborate} is encountered. The default is that such warnings are not generated. This warning is not automatically turned on by the use of @option{-gnatwa}. @item -gnatwL -@emph{Suppress warnings for missing elaboration pragmas.} +@emph{Suppress warnings for elaboration pragmas.} @cindex @option{-gnatwL} (@command{gcc}) This switch suppresses warnings on missing Elaborate and Elaborate_All pragmas. See the section in this guide on elaboration checking for details on @@ -5093,6 +5127,26 @@ This switch suppresses warnings on ineffective pragma Inlines. If the inlining mechanism cannot inline a call, it will simply ignore the request silently. +@item -gnatw.p +@emph{Activate warnings on parameter ordering.} +@cindex @option{-gnatw.p} (@command{gcc}) +@cindex Parameter order, warnings +This switch activates warnings for cases of suspicious parameter +ordering when the list of arguments are all simple identifiers that +match the names of the formals, but are in a different order. The +warning is suppressed if any use of named parameter notation is used, +so this is the appropriate way to suppress a false positive (and +serves to emphasize that the "misordering" is deliberate). The +default is +that such warnings are not given. +This warning can also be turned on using @option{-gnatwa}. + +@item -gnatw.P +@emph{Suppress warnings on parameter ordering.} +@cindex @option{-gnatw.P} (@command{gcc}) +This switch suppresses warnings on cases of suspicious parameter +ordering. + @item -gnatwq @emph{Activate warnings on questionable missing parentheses.} @cindex @option{-gnatwq} (@command{gcc}) @@ -5343,21 +5397,31 @@ This switch suppresses warnings for unchecked conversions where the types are known at compile time to have different sizes or conventions. +@item ^-Wunused^WARNINGS=UNUSED^ +@cindex @option{-Wunused} +The warnings controlled by the @option{-gnatw} switch are generated by +the front end of the compiler. The @option{GCC} back end can provide +additional warnings and they are controlled by the @option{-W} switch. +For example, @option{^-Wunused^WARNINGS=UNUSED^} activates back end +warnings for entities that are declared but not referenced. + @item ^-Wuninitialized^WARNINGS=UNINITIALIZED^ @cindex @option{-Wuninitialized} -The warnings controlled by the @option{-gnatw} switch are generated by the -front end of the compiler. In some cases, the @option{^gcc^GCC^} back end -can provide additional warnings. One such useful warning is provided by -@option{^-Wuninitialized^WARNINGS=UNINITIALIZED^}. This must be used in -conjunction with turning on optimization mode. This causes the flow -analysis circuits of the back end optimizer to output additional -warnings about uninitialized variables. +Similarly, @option{^-Wuninitialized^WARNINGS=UNINITIALIZED^} activates +the back end warning for uninitialized variables. This switch must be +used in conjunction with an optimization level greater than zero. + +@item ^-Wall^/ALL_BACK_END_WARNINGS^ +@cindex @option{-Wall} +This switch enables all the above warnings from the @option{GCC} back end. +The code generator detects a number of warning situations that are missed +by the @option{GNAT} front end, and this switch can be used to activate them. +The use of this switch also sets the default front end warning mode to +@option{-gnatwa}, that is, most front end warnings activated as well. @item ^-w^/NO_BACK_END_WARNINGS^ @cindex @option{-w} -This switch suppresses warnings from the @option{^gcc^GCC^} back end. The -code generator detects a number of warning situations that are missed -by the @option{GNAT} front end, and this switch can be used to suppress them. +Conversely, this switch suppresses warnings from the @option{GCC} back end. The use of this switch also sets the default front end warning mode to @option{-gnatws}, that is, front end warnings suppressed as well. @@ -5694,12 +5758,12 @@ checks to be performed. The following checks are defined: @table @option @c !sort! -@item 1-9 +@item 0-9 @emph{Specify indentation level.} If a digit from 1-9 appears ^in the string after @option{-gnaty}^as an option for /STYLE_CHECKS^ then proper indentation is checked, with the digit indicating the -indentation level required. +indentation level required. A value of zero turns off this style check. The general style of required indentation is as specified by the examples in the Ada Reference Manual. Full line comments must be aligned with the @code{--} starting on a column that is a multiple of @@ -5709,30 +5773,26 @@ of a statement. @item ^a^ATTRIBUTE^ @emph{Check attribute casing.} -If the ^letter a^word ATTRIBUTE^ appears in the string after @option{-gnaty} -then attribute names, including the case of keywords such as @code{digits} +Attribute names, including the case of keywords such as @code{digits} used as attributes names, must be written in mixed case, that is, the initial letter and any letter following an underscore must be uppercase. All other letters must be lowercase. @item ^A^ARRAY_INDEXES^ @emph{Use of array index numbers in array attributes.} -If the ^letter A^word ARRAY_INDEXES^ appears in the string after -@option{-gnaty} then when using the array attributes First, Last, Range, +When using the array attributes First, Last, Range, or Length, the index number must be omitted for one-dimensional arrays and is required for multi-dimensional arrays. @item ^b^BLANKS^ @emph{Blanks not allowed at statement end.} -If the ^letter b^word BLANKS^ appears in the string after @option{-gnaty} then -trailing blanks are not allowed at the end of statements. The purpose of this +Trailing blanks are not allowed at the end of statements. The purpose of this rule, together with h (no horizontal tabs), is to enforce a canonical format for the use of blanks to separate source tokens. @item ^c^COMMENTS^ @emph{Check comments.} -If the ^letter c^word COMMENTS^ appears in the string after @option{-gnaty} -then comments must meet the following set of rules: +Comments must meet the following set of rules: @itemize @bullet @@ -5784,64 +5844,55 @@ example: @item ^d^DOS_LINE_ENDINGS^ @emph{Check no DOS line terminators present.} -If the ^letter d^word DOS_LINE_ENDINGS^ appears in the string after -@option{-gnaty} then all lines must be terminated by a single ASCII.LF +All lines must be terminated by a single ASCII.LF character (in particular the DOS line terminator sequence CR/LF is not allowed). @item ^e^END^ @emph{Check end/exit labels.} -If the ^letter e^word END^ appears in the string after @option{-gnaty} then -optional labels on @code{end} statements ending subprograms and on +Optional labels on @code{end} statements ending subprograms and on @code{exit} statements exiting named loops, are required to be present. @item ^f^VTABS^ @emph{No form feeds or vertical tabs.} -If the ^letter f^word VTABS^ appears in the string after @option{-gnaty} then -neither form feeds nor vertical tab characters are permitted +Neither form feeds nor vertical tab characters are permitted in the source text. @item ^g^GNAT^ @emph{GNAT style mode} -If the ^letter g^word GNAT^ appears in the string after @option{-gnaty} then -the set of style check switches is set to match that used by the GNAT sources. +The set of style check switches is set to match that used by the GNAT sources. This may be useful when developing code that is eventually intended to be incorporated into GNAT. For further details, see GNAT sources. @item ^h^HTABS^ @emph{No horizontal tabs.} -If the ^letter h^word HTABS^ appears in the string after @option{-gnaty} then -horizontal tab characters are not permitted in the source text. +Horizontal tab characters are not permitted in the source text. Together with the b (no blanks at end of line) check, this enforces a canonical form for the use of blanks to separate source tokens. @item ^i^IF_THEN^ @emph{Check if-then layout.} -If the ^letter i^word IF_THEN^ appears in the string after @option{-gnaty}, -then the keyword @code{then} must appear either on the same +The keyword @code{then} must appear either on the same line as corresponding @code{if}, or on a line on its own, lined up under the @code{if} with at least one non-blank line in between containing all or part of the condition to be tested. @item ^I^IN_MODE^ @emph{check mode IN keywords} -If the ^letter I (upper case)^word IN_MODE^ appears in the string -after @option{-gnaty} then mode @code{in} (the default mode) is not +Mode @code{in} (the default mode) is not allowed to be given explicitly. @code{in out} is fine, but not @code{in} on its own. @item ^k^KEYWORD^ @emph{Check keyword casing.} -If the ^letter k^word KEYWORD^ appears in the string after @option{-gnaty} then -all keywords must be in lower case (with the exception of keywords +All keywords must be in lower case (with the exception of keywords such as @code{digits} used as attribute names to which this check does not apply). @item ^l^LAYOUT^ @emph{Check layout.} -If the ^letter l^word LAYOUT^ appears in the string after @option{-gnaty} then -layout of statement and declaration constructs must follow the +Layout of statement and declaration constructs must follow the recommendations in the Ada Reference Manual, as indicated by the form of the syntax rules. For example an @code{else} keyword must be lined up with the corresponding @code{if} keyword. @@ -5918,16 +5969,13 @@ Clear : @item ^Lnnn^MAX_NESTING=nnn^ @emph{Set maximum nesting level} -If the sequence ^Lnnn^MAX_NESTING=nnn^, where nnn is a decimal number in -the range 0-999, appears in the string after @option{-gnaty} then the -maximum level of nesting of constructs (including subprograms, loops, -blocks, packages, and conditionals) may not exceed the given value. A -value of zero disconnects this style check. +The maximum level of nesting of constructs (including subprograms, loops, +blocks, packages, and conditionals) may not exceed the given value +@option{nnn}. A value of zero disconnects this style check. @item ^m^LINE_LENGTH^ @emph{Check maximum line length.} -If the ^letter m^word LINE_LENGTH^ appears in the string after @option{-gnaty} -then the length of source lines must not exceed 79 characters, including +The length of source lines must not exceed 79 characters, including any trailing blanks. The value of 79 allows convenient display on an 80 character wide device or window, allowing for possible special treatment of 80 character lines. Note that this count is of @@ -5937,21 +5985,22 @@ a single character (however many bytes are needed in the encoding). @item ^Mnnn^MAX_LENGTH=nnn^ @emph{Set maximum line length.} -If the sequence ^M^MAX_LENGTH=^nnn, where nnn is a decimal number, appears in -the string after @option{-gnaty} then the length of lines must not exceed the -given value. The maximum value that can be specified is 32767. +The length of lines must not exceed the +given value @option{nnn}. The maximum value that can be specified is 32767. @item ^n^STANDARD_CASING^ @emph{Check casing of entities in Standard.} -If the ^letter n^word STANDARD_CASING^ appears in the string -after @option{-gnaty} then any identifier from Standard must be cased +Any identifier from Standard must be cased to match the presentation in the Ada Reference Manual (for example, @code{Integer} and @code{ASCII.NUL}). +@item ^N^NONE^ +@emph{Turn off all style checks} +All style check options are turned off. + @item ^o^ORDERED_SUBPROGRAMS^ @emph{Check order of subprogram bodies.} -If the ^letter o^word ORDERED_SUBPROGRAMS^ appears in the string -after @option{-gnaty} then all subprogram bodies in a given scope +All subprogram bodies in a given scope (e.g.@: a package body) must be in alphabetical order. The ordering rule uses normal Ada rules for comparing strings, ignoring casing of letters, except that if there is a trailing numeric suffix, then @@ -5960,31 +6009,27 @@ before Junk10). @item ^p^PRAGMA^ @emph{Check pragma casing.} -If the ^letter p^word PRAGMA^ appears in the string after @option{-gnaty} then -pragma names must be written in mixed case, that is, the +Pragma names must be written in mixed case, that is, the initial letter and any letter following an underscore must be uppercase. All other letters must be lowercase. @item ^r^REFERENCES^ @emph{Check references.} -If the ^letter r^word REFERENCES^ appears in the string after @option{-gnaty} -then all identifier references must be cased in the same way as the +All identifier references must be cased in the same way as the corresponding declaration. No specific casing style is imposed on identifiers. The only requirement is for consistency of references with declarations. @item ^S^STATEMENTS_AFTER_THEN_ELSE^ @emph{Check no statements after THEN/ELSE.} -If the ^letter S^word STATEMENTS_AFTER_THEN_ELSE^ appears in the -string after @option{-gnaty} then it is not permitted to write any -statements on the same line as a THEN OR ELSE keyword following the +No statements are allowed +on the same line as a THEN OR ELSE keyword following the keyword in an IF statement. OR ELSE and AND THEN are not affected, and a special exception allows a pragma to appear after ELSE. @item ^s^SPECS^ @emph{Check separate specs.} -If the ^letter s^word SPECS^ appears in the string after @option{-gnaty} then -separate declarations (``specs'') are required for subprograms (a +Separate declarations (``specs'') are required for subprograms (a body is not allowed to serve as its own declaration). The only exception is that parameterless library level procedures are not required to have a separate declaration. This exception covers @@ -5992,8 +6037,7 @@ the most frequent form of main program procedures. @item ^t^TOKEN^ @emph{Check token spacing.} -If the ^letter t^word TOKEN^ appears in the string after @option{-gnaty} then -the following token spacing rules are enforced: +The following token spacing rules are enforced: @itemize @bullet @@ -6042,16 +6086,41 @@ A vertical bar must be surrounded by spaces. @item ^u^UNNECESSARY_BLANK_LINES^ @emph{Check unnecessary blank lines.} -Check for unnecessary blank lines. A blank line is considered +Unnecessary blank lines are not allowed. A blank line is considered unnecessary if it appears at the end of the file, or if more than one blank line occurs in sequence. @item ^x^XTRA_PARENS^ @emph{Check extra parentheses.} -Check for the use of an unnecessary extra level of parentheses (C-style) +Unnecessary extra level of parentheses (C-style) are not allowed around conditions in @code{if} statements, @code{while} statements and @code{exit} statements. +@item ^y^ALL_BUILTIN^ +@emph{Set all standard style check options} +This is equivalent to @code{gnaty3aAbcefhiklmnprst}, that is all checking +options enabled with the exception of @option{-gnatyo}, +@option{-gnatyd}, @option{-gnatyu}, and @option{-gnatyx}. + +@ifclear vms +@item - +@emph{Remove style check options} +This causes any subsequent options in the string to act as canceling the +corresponding style check option. + +@item + +This causes any subsequent options in the string to enable the corresponding +style check option. It only has an effect if a previous ^-^REMOVE^ has been +encountered. +@end ifclear + +@ifset vms +@item NOxxx +@emph{Removing style check options} +If the name of a style check is preceded by @option{NO} then the corresponding +style check is turned off. For example @option{NOCOMMENTS} turns off style +checking for comments. +@end ifset @end table @noindent @@ -6074,10 +6143,10 @@ including style messages, as fatal errors. The switch @ifclear vms @option{-gnaty} on its own (that is not -followed by any letters or digits), -is equivalent to @code{gnaty3aAbcefhiklmnprst}, that is all checking -options enabled with the exception of @option{-gnatyo}, -@option{-gnatyd}, @option{-gnatyu}, and @option{-gnatyx}. +followed by any letters or digits), then the effect is equivalent +to the use of @option{-gnatyy}, as described above, that is all +built-in standard style check options are enabled. + @end ifclear @ifset vms /STYLE_CHECKS=ALL_BUILTIN enables all checking options with @@ -6197,12 +6266,12 @@ generate IEEE NaN and infinite values on overflow or invalid operations (such as dividing 0.0 by 0.0). The reason that we distinguish overflow checking from other kinds of -range constraint checking is that a failure of an overflow check can -generate an incorrect value, but cannot cause erroneous behavior. This -is unlike the situation with a constraint check on an array subscript, -where failure to perform the check can result in random memory description, -or the range check on a case statement, where failure to perform the check -can cause a wild jump. +range constraint checking is that a failure of an overflow check, unlike +for example the failure of a range check, can result in an incorrect +value, but cannot cause random memory destruction (like an out of range +subscript), or a wild jump (from an out of range case value). Overflow +checking is also quite expensive in time and space, since in general it +requires the use of double length arithmetic. Note again that @option{-gnato} is off by default, so overflow checking is not performed in default mode. This means that out of the box, with the @@ -6646,7 +6715,7 @@ The format of the output is very similar to standard Ada source, and is easily understood by an Ada programmer. The following special syntactic additions correspond to low level features used in the generated code that do not have any exact analogies in pure Ada source form. The following -is a partial list of these special constructions. See the specification +is a partial list of these special constructions. See the spec of package @code{Sprint} in file @file{sprint.ads} for a full list. If the switch @option{-gnatL} is used in conjunction with @@ -6916,7 +6985,7 @@ for completeness and for possible use by other tools. A mapping file is a sequence of sets of three lines. In each set, the first line is the unit name, in lower case, with ``@code{%s}'' appended for -specifications and ``@code{%b}'' appended for bodies; the second line is the +specs and ``@code{%b}'' appended for bodies; the second line is the file name; and the third line is the path name. Example: @@ -8387,10 +8456,10 @@ $ ^gnatlink my_prog -Wl,-Map,MAPFILE^GNAT LINK my_prog.ali /MAP^ Using @var{linker options} it is possible to set the program stack and heap size. -@ifclear vms +@ifset unw See @ref{Setting Stack Size from gnatlink} and @ref{Setting Heap Size from gnatlink}. -@end ifclear +@end ifset @command{gnatlink} determines the list of objects required by the Ada program and prepends them to the list of objects passed to the linker. @@ -8994,7 +9063,9 @@ Normally, when using Project Files, only sources that are part of a Project File may be compile. When this switch is used, a source outside of all Project Files may be compiled. The ALI file and the object file will be put in the object directory of the main Project. The compilation switches used will only -be those specified on the command line. +be those specified on the command line. Even when +@option{^-x^/NON_PROJECT_UNIT_COMPILATION^} is used, mains specified on the +command line need to be sources of a project file. @item ^-X^/EXTERNAL_REFERENCE=^@var{name=value} Indicate that external variable @var{name} has the value @var{value}. @@ -9325,6 +9396,7 @@ driver (see @ref{The GNAT Driver and Project Files}). @ifnottex @menu * Performance Considerations:: +* Text_IO Suggestions:: * Reducing Size of Ada Executables with gnatelim:: * Reducing Size of Executables with unused subprogram/data elimination:: @end menu @@ -9470,6 +9542,23 @@ possibility of an immediate abort at any point. @subsection Optimization Levels @cindex @option{^-O^/OPTIMIZE^} (@command{gcc}) +@noindent +Without any optimization ^option,^qualifier,^ +the compiler's goal is to reduce the cost of +compilation and to make debugging produce the expected results. +Statements are independent: if you stop the program with a breakpoint between +statements, you can then assign a new value to any variable or change +the program counter to any other statement in the subprogram and get exactly +the results you would expect from the source code. + +Turning on optimization makes the compiler attempt to improve the +performance and/or code size at the expense of compilation time and +possibly the ability to debug the program. + +If you use multiple +^-O options, with or without level numbers,^/OPTIMIZE qualifiers,^ +the last such option is the one that is effective. + @noindent The default is optimization off. This results in the fastest compile times, but GNAT makes absolutely no attempt to optimize, and the @@ -9491,7 +9580,7 @@ generates unoptimized code but has the fastest compilation time. Note that many other compilers do fairly extensive optimization -even if "no optimization" is specified. When using gcc, it is +even if ``no optimization'' is specified. With gcc, it is very unusual to use ^-O0^/OPTIMIZE=NONE^ for production if execution time is of any concern, since ^-O0^/OPTIMIZE=NONE^ really does mean no optimization at all. This difference between @@ -9528,10 +9617,6 @@ resulting improvement in execution time, both depend on the particular application and the hardware environment. You should experiment to find the best level for your application. -The @option{^-Os^/OPTIMIZE=SPACE^} switch is independent of the time -optimizations, so you can specify both @option{^-Os^/OPTIMIZE=SPACE^} -and a time optimization on the same compile command. - Since the precise set of optimizations done at each level will vary from release to release (and sometime from target to target), it is best to think of the optimization settings in general terms. @@ -9694,18 +9779,15 @@ The optimization level is at least @option{-O1}. @item The called subprogram is suitable for inlining: It must be small enough -and not contain nested subprograms or anything else that @command{gcc} -cannot support in inlined subprograms. - -@item -The call occurs after the definition of the body of the subprogram. +and not contain something that @command{gcc} cannot support in inlined +subprograms. @item @cindex pragma Inline @findex Inline -Either @code{pragma Inline} applies to the subprogram or it is -small and automatic inlining (optimization level @option{-O3}) is -specified. +Either @code{pragma Inline} applies to the subprogram, or it is local +to the unit and called once from within it, or it is small and automatic +inlining (optimization level @option{-O3}) is specified. @end itemize @noindent @@ -9719,8 +9801,8 @@ The optimization level is at least @option{-O1}. @item The called subprogram is suitable for inlining: It must be small enough -and not contain nested subprograms or anything else @command{gcc} cannot -support in inlined subprograms. +and not contain something that @command{gcc} cannot support in inlined +subprograms. @item The call appears in a body (not in a package spec). @@ -9787,6 +9869,15 @@ that no inlining occurs. The extra dependences resulting from @option{-gnatn} will still be active, even if this switch is used to suppress the resulting inlining actions. +@cindex @option{-fno-inline-functions} (@command{gcc}) +Note: The @option{-fno-inline-functions} switch can be used to prevent +automatic inlining of small subprograms if @option{-O3} is used. + +@cindex @option{-fno-inline-functions-called-once} (@command{gcc}) +Note: The @option{-fno-inline-functions-called-once} switch +can be used to prevent inlining of subprograms local to the unit +and called once from within it if @option{-O1} is used. + Note regarding the use of @option{-O3}: There is no difference in inlining behavior between @option{-O2} and @option{-O3} for subprograms with an explicit pragma @code{Inline} assuming the use of @option{-gnatn} @@ -10041,6 +10132,30 @@ the user to determine the distribution of execution time across a program, @pxref{Profiling} for details of usage. @end ifset + +@node Text_IO Suggestions +@section @code{Text_IO} Suggestions +@cindex @code{Text_IO} and performance + +@noindent +The @code{Ada.Text_IO} package has fairly high overheads due in part to +the requirement of maintaining page and line counts. If performance +is critical, a recommendation is to use @code{Stream_IO} instead of +@code{Text_IO} for volume output, since this package has less overhead. + +If @code{Text_IO} must be used, note that by default output to the standard +output and standard error files is unbuffered (this provides better +behavior when output statements are used for debugging, or if the +progress of a program is observed by tracking the output, e.g. by +using the Unix @command{tail -f} command to watch redirected output. + +If you are generating large volumes of output with @code{Text_IO} and +performance is an important factor, use a designated file instead +of the standard output file, or change the standard output file to +be buffered using @code{Interfaces.C_Streams.setvbuf}. + + + @node Reducing Size of Ada Executables with gnatelim @section Reducing Size of Ada Executables with @code{gnatelim} @findex gnatelim @@ -10753,23 +10868,38 @@ recognized by GNAT: Ada_83 Ada_95 Ada_05 + Ada_2005 + Assertion_Policy C_Pass_By_Copy + Check_Name + Check_Policy + Compile_Time_Error + Compile_Time_Warning + Compiler_Unit Component_Alignment + Debug_Policy Detect_Blocking Discard_Names Elaboration_Checks Eliminate Extend_System External_Name_Casing + Fast_Math + Favor_Top_Level Float_Representation + Implicit_Packing Initialize_Scalars Interrupt_State License Locking_Policy Long_Float + No_Run_Time + No_Strict_Aliasing Normalize_Scalars + Optimize_Alignment Persistent_BSS Polling + Priority_Specific_Dispatching Profile Profile_Warnings Propagate_Exceptions @@ -10780,14 +10910,18 @@ recognized by GNAT: Restrictions_Warnings Reviewable Source_File_Name + Source_File_Name_Project Style_Checks Suppress + Suppress_Exception_Locations Task_Dispatching_Policy Universal_Data Unsuppress Use_VADS_Size - Warnings Validity_Checks + Warnings + Wide_Character_Encoding + @end smallexample @menu @@ -11793,7 +11927,7 @@ relaxed in a future release. @noindent In large software systems it is common to have multiple implementations of a common interface; in Ada terms, multiple versions of a -package body for the same specification. For example, one implementation +package body for the same spec. For example, one implementation might be safe for use in tasking programs, while another might only be used in sequential applications. This can be modeled in GNAT using the concept of @emph{project extension}. If one project (the ``child'') @emph{extends} @@ -12874,11 +13008,11 @@ of the child project; see @ref{Project File Syntax}. An inherited source file retains any switches specified in the parent project. -For example if the project @code{Utilities} contains the specification and the +For example if the project @code{Utilities} contains the spec and the body of an Ada package @code{Util_IO}, then the project @code{Modified_Utilities} can contain a new body for package @code{Util_IO}. The original body of @code{Util_IO} will not be considered in program builds. -However, the package specification will still be found in the project +However, the package spec will still be found in the project @code{Utilities}. A child project can have only one parent but it may import any number of other @@ -13525,7 +13659,7 @@ The following switches are used by GNAT tools that support project files: @table @option @item ^-P^/PROJECT_FILE=^@var{project} -@cindex @option{^-P^/PROJECT_FILE^} (any tool supporting project files) +@cindex @option{^-P^/PROJECT_FILE^} (any project-aware tool) Indicates the name of a project file. This project file will be parsed with the verbosity indicated by @option{^-vP^MESSAGE_PROJECT_FILES=^@emph{x}}, if any, and using the external references indicated @@ -13545,7 +13679,7 @@ on the command line are checked, the order of the switches or @option{^-X^/EXTERNAL_REFERENCE^} is not significant. @item ^-X^/EXTERNAL_REFERENCE=^@var{name=value} -@cindex @option{^-X^/EXTERNAL_REFERENCE^} (any tool supporting project files) +@cindex @option{^-X^/EXTERNAL_REFERENCE^} (any project-aware tool) Indicates that external variable @var{name} has the value @var{value}. The Project Manager will use this value for occurrences of @code{external(name)} when parsing the project file. @@ -13570,8 +13704,7 @@ An external variable specified with a @option{^-X^/EXTERNAL_REFERENCE^} switch takes precedence over the value of the same name in the environment. @item ^-vP^/MESSAGES_PROJECT_FILE=^@emph{x} -@cindex @code{^-vP^/MESSAGES_PROJECT_FILE^} (any tool supporting project files) -@c Previous line uses code vs option command, to stay less than 80 chars +@cindex @option{^-vP^/MESSAGES_PROJECT_FILE^} (any project-aware tool) Indicates the verbosity of the parsing of GNAT project files. @ifclear vms @@ -13592,6 +13725,25 @@ project files. If several @option{^-vP^/MESSAGES_PROJECT_FILE=^@emph{x}} switches are present, only the last one is used. +@item ^-aP^/ADD_PROJECT_SEARCH_DIR=^