OSDN Git Service

* gnat_ugn.texi (Conventions): List environment variables and
[pf3gnuchains/gcc-fork.git] / gcc / ada / gnat_ugn.texi
index c75882b..7d369b5 100644 (file)
@@ -1,13 +1,12 @@
 \input texinfo   @c -*-texinfo-*-
 @c %**start of header
-
 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
 @c                                                                            o
 @c                            GNAT DOCUMENTATION                              o
 @c                                                                            o
 @c                             G N A T _ U G N                                o
 @c                                                                            o
-@c          Copyright (C) 1992-2004 Ada Core Technologies, Inc.               o
+@c                     Copyright (C) 1992-2007, AdaCore                       o
 @c                                                                            o
 @c  GNAT is free software;  you can  redistribute it  and/or modify it under  o
 @c  terms of the  GNU General Public License as published  by the Free Soft-  o
@@ -17,8 +16,8 @@
 @c  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License  o
 @c  for  more details.  You should have  received  a copy of the GNU General  o
 @c  Public License  distributed with GNAT;  see file COPYING.  If not, write  o
-@c  to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston,  o
-@c  MA 02111-1307, USA.                                                       o
+@c  to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor,  o
+@c  Boston, MA 02110-1301, USA.                                               o
 @c                                                                            o
 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
 
 @c
 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
 
-@ifset vms
-@setfilename gnat_ugn_vms.info
-@end ifset
+@setfilename gnat_ugn.info
+
+@set NOW January 2007
+@c This flag is used where the text refers to conditions that exist when the
+@c text was entered into the document but which may change over time.
+@c Update the setting for the flag, and (if necessary) the text surrounding,
+@c the references to the flag, on future doc revisions:
+@c search for @value{NOW}.
+
+@set FSFEDITION
+@set EDITION GNAT
+@set DEFAULTLANGUAGEVERSION Ada 2005
+@set NONDEFAULTLANGUAGEVERSION Ada 95
 
 @ifset unw
 @setfilename gnat_ugn_unw.info
 @end ifset
 
+@ifset unw
+@set PLATFORM
+@set FILE gnat_ugn_unw
+@end ifset
+
 @ifset vms
-@settitle GNAT User's Guide for Native Platforms / OpenVMS Alpha
-@dircategory GNU Ada tools
-@direntry
-* GNAT User's Guide (gnat_ugn_vms) for Native Platforms / OpenVMS Alpha
-@end direntry
+@set PLATFORM OpenVMS
+@set FILE gnat_ugn_vms
 @end ifset
 
-@ifset unw
-@settitle GNAT User's Guide for Native Platforms / Unix and Windows
+@settitle @value{EDITION} User's Guide @value{PLATFORM}
+@dircategory GNU Ada tools
 @direntry
-* GNAT User's Guide (gnat_ugn_unw) for Native Platforms / Unix and Windows
+* @value{EDITION} User's Guide (@value{FILE}) @value{PLATFORM}
 @end direntry
-@end ifset
 
 @include gcc-common.texi
 
 @c %**end of header
 
 @copying
-Copyright @copyright{} 1995-2004, Free Software Foundation
+Copyright @copyright{} 1995-2005, 2006, 2007, 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
 or any later version published by the Free Software Foundation;
 with the Invariant Sections being ``GNU Free Documentation License'', with the
 Front-Cover Texts being
-@ifset vms
-``GNAT User's Guide for Native Platforms / OpenVMS Alpha'',
-@end ifset
-@ifset unw
-``GNAT User's Guide for Native Platforms / Unix and Windows'',
-@end ifset
+``@value{EDITION} User's Guide'',
 and with no Back-Cover Texts.
 A copy of the license is included in the section entitled
 ``GNU Free Documentation License''.
 @end copying
 
 @titlepage
-
-@title GNAT User's Guide
-@center @titlefont{for Native Platforms}
+@title @value{EDITION} User's Guide
+@ifset vms
 @sp 1
-
 @flushright
-@ifset unw
-@titlefont{@i{Unix and Windows}}
-@end ifset
-@ifset vms
-@titlefont{@i{OpenVMS Alpha}}
-@end ifset
+@titlefont{@i{@value{PLATFORM}}}
 @end flushright
-@sp 2
+@end ifset
 
-@subtitle GNAT, The GNU Ada 95 Compiler
-@subtitle GCC version @value{version-GCC}
+@sp 2
 
-@author Ada Core Technologies, Inc.
+@subtitle GNAT, The GNU Ada Compiler
+@versionsubtitle
+@author AdaCore
 
 @page
 @vskip 0pt plus 1filll
@@ -153,27 +153,19 @@ A copy of the license is included in the section entitled
 
 @end titlepage
 
-
 @ifnottex
 @node Top, About This Guide, (dir), (dir)
-@top GNAT User's Guide
-
-@ifset vms
-@noindent
-GNAT User's Guide for Native Platforms / OpenVMS Alpha
-@end ifset
+@top @value{EDITION} User's Guide
 
-@ifset unw
 @noindent
-GNAT User's Guide for Native Platforms / Unix and Windows
-@end ifset
+@value{EDITION} User's Guide @value{PLATFORM}
 
 @noindent
-GNAT, The GNU Ada 95 Compiler@*
+GNAT, The GNU Ada Compiler@*
 GCC version @value{version-GCC}@*
 
 @noindent
-Ada Core Technologies, Inc.@*
+AdaCore@*
 
 @menu
 * About This Guide::
@@ -190,6 +182,7 @@ Ada Core Technologies, Inc.@*
 * GNAT Project Manager::
 * The Cross-Referencing Tools gnatxref and gnatfind::
 * The GNAT Pretty-Printer gnatpp::
+* The GNAT Metric Tool gnatmetric::
 * File Name Krunching Using gnatkr::
 * Preprocessing Using gnatprep::
 @ifset vms
@@ -201,16 +194,19 @@ Ada Core Technologies, Inc.@*
 * GNAT and Libraries::
 * Using the GNU make Utility::
 @end ifclear
-* Finding Memory Problems::
+* Memory Management Issues::
+* Stack Related Facilities::
+* Verifying Properties Using gnatcheck::
 * Creating Sample Bodies Using gnatstub::
 * Other Utility Programs::
 * Running and Debugging Ada Programs::
 @ifset vms
-* Compatibility with DEC Ada::
+* Compatibility with HP Ada::
 @end ifset
 * Platform-Specific Information for the Run-Time Libraries::
 * Example of Binder Output File::
 * Elaboration Order Handling in GNAT::
+* Conditional Compilation::
 * Inline Assembler::
 * Compatibility and Porting Guide::
 @ifset unw
@@ -239,7 +235,6 @@ Getting Started with GNAT
 @end ifset
 @ifclear vms
 * Introduction to GPS::
-* Introduction to Glide and GVD::
 @end ifclear
 
 The GNAT Compilation Model
@@ -254,8 +249,10 @@ The GNAT Compilation Model
 * The Ada Library Information Files::
 * Binding an Ada Program::
 * Mixed Language Programming::
+@ifclear vms
 * Building Mixed Ada & C++ Programs::
 * Comparison between GNAT and C/C++ Compilation Models::
+@end ifclear
 * Comparison between GNAT and Conventional Ada Library Models::
 @ifset vms
 * Placement of temporary files::
@@ -280,13 +277,12 @@ Switches for gcc
 * Output and Error Message Control::
 * Warning Message Control::
 * Debugging and Assertion Control::
-* Run-Time Checks::
-* Stack Overflow Checking::
 * Validity Checking::
 * Style Checking::
+* Run-Time Checks::
 * Using gcc for Syntax Checking::
 * Using gcc for Semantic Checking::
-* Compiling Ada 83 Programs::
+* Compiling Different Versions of Ada::
 * Character Set Control::
 * File Naming Control::
 * Subprogram Inlining Control::
@@ -320,8 +316,6 @@ Linking Using gnatlink
 
 * Running gnatlink::
 * Switches for gnatlink::
-* Setting Stack Size from gnatlink::
-* Setting Heap Size from gnatlink::
 
 The GNAT Make Program gnatmake
 
@@ -332,10 +326,10 @@ The GNAT Make Program gnatmake
 * How gnatmake Works::
 * Examples of gnatmake Usage::
 
-
 Improving Performance
 * Performance Considerations::
-* Reducing the Size of Ada Executables with gnatelim::
+* Reducing Size of Ada Executables with gnatelim::
+* Reducing Size of Executables with unused subprogram/data elimination::
 
 Performance Considerations
 * Controlling Run-Time Checks::
@@ -343,18 +337,23 @@ Performance Considerations
 * Optimization Levels::
 * Debugging Optimized Code::
 * Inlining of Subprograms::
+* Other Optimization Switches::
 * Optimization and Strict Aliasing::
 @ifset vms
 * 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 Size of Executables with unused subprogram/data elimination
+* About unused subprogram/data elimination::
+* Compilation options::
+
 Renaming Files Using gnatchop
 
 * Handling Files with Multiple Units::
@@ -383,19 +382,18 @@ GNAT Project Manager
 * Objects and Sources in Project Files::
 * Importing Projects::
 * Project Extension::
+* Project Hierarchy Extension::
 * External References in Project Files::
 * Packages in Project Files::
 * Variables from Imported Projects::
 * Naming Schemes::
 * Library Projects::
-* Using Third-Party Libraries through Projects::
 * Stand-alone Library Projects::
 * Switches Related to Project Files::
 * Tools Supporting Project Files::
 * An Extended Example::
 * Project File Complete Syntax::
 
-
 The Cross-Referencing Tools gnatxref and gnatfind
 
 * gnatxref Switches::
@@ -405,12 +403,14 @@ The Cross-Referencing Tools gnatxref and gnatfind
 * Examples of gnatxref Usage::
 * Examples of gnatfind Usage::
 
-
 The GNAT Pretty-Printer gnatpp
 
 * Switches for gnatpp::
 * Formatting Rules::
 
+The GNAT Metrics Tool gnatmetric
+
+* Switches for gnatmetric::
 
 File Name Krunching Using gnatkr
 
@@ -420,7 +420,6 @@ File Name Krunching Using gnatkr
 * Examples of gnatkr Usage::
 
 Preprocessing Using gnatprep
-
 * Using gnatprep::
 * Switches for gnatprep::
 * Form of Definitions File::
@@ -444,7 +443,7 @@ Cleaning Up Using gnatclean
 
 * Running gnatclean::
 * Switches for gnatclean::
-* Examples of gnatclean Usage::
+@c * Examples of gnatclean Usage::
 
 @ifclear vms
 
@@ -463,12 +462,23 @@ Using the GNU make Utility
 * Overcoming Command Line Length Limits::
 @end ifclear
 
-Finding Memory Problems
+Memory Management Issues
 
+* Some Useful Memory Pools::
+* The GNAT Debug Pool Facility::
 @ifclear vms
 * The gnatmem Tool::
 @end ifclear
-* The GNAT Debug Pool Facility::
+
+Stack Related Facilities
+
+* Stack Overflow Checking::
+* Static Stack Usage Analysis::
+* Dynamic Stack Usage Analysis::
+
+Some Useful Memory Pools
+
+The GNAT Debug Pool Facility
 
 @ifclear vms
 The gnatmem Tool
@@ -478,9 +488,16 @@ The gnatmem Tool
 * Example of gnatmem Usage::
 @end ifclear
 
-The GNAT Debug Pool Facility
+Verifying Properties Using gnatcheck
+
+* Format of the Report File::
+* General gnatcheck Switches::
+* gnatcheck Rule Options::
+* Adding the Results of Compiler Checks to gnatcheck Output::
+* Project-Wide Checks::
+* Predefined Rules::
 
-Creating Sample Bodies Using gnatstub
+Sample Bodies Using gnatstub
 
 * Running gnatstub::
 * Switches for gnatstub::
@@ -489,9 +506,6 @@ Other Utility Programs
 
 * Using Other Utility Programs with GNAT::
 * The External Symbol Naming Scheme of GNAT::
-@ifclear vms
-* Ada Mode for Glide::
-@end ifclear
 * Converting Ada Files to html with gnathtml::
 
 Running and Debugging Ada Programs
@@ -515,15 +529,14 @@ Running and Debugging Ada Programs
 @end ifset
 
 @ifset vms
-Compatibility with DEC Ada
+Compatibility with HP Ada
 
-* Ada 95 Compatibility::
+* Ada Language Compatibility::
 * Differences in the Definition of Package System::
 * Language-Related Features::
 * The Package STANDARD::
 * The Package SYSTEM::
 * Tasking and Task-Related Features::
-* Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems::
 * Pragmas and Pragma-Related Features::
 * Library of Predefined Units::
 * Bindings::
@@ -533,7 +546,7 @@ Compatibility with DEC Ada
 * Program Compilation and Library Management::
 * Input-Output::
 * Implementation Limits::
-* Tools::
+* Tools and Utilities::
 
 Language-Related Features
 
@@ -545,8 +558,9 @@ Language-Related Features
 * Address Clauses::
 * Other Representation Clauses::
 
-Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems
+Tasking and Task-Related Features
 
+* Implementation of Tasks in HP Ada for OpenVMS Alpha Systems::
 * Assigning Task IDs::
 * Task IDs and Delays::
 * Task-Related Pragmas::
@@ -574,10 +588,8 @@ Platform-Specific Information for the Run-Time Libraries
 
 * Summary of Run-Time Configurations::
 * Specifying a Run-Time Library::
-* Choosing between Native and FSU Threads Libraries::
 * Choosing the Scheduling Policy::
 * Solaris-Specific Considerations::
-* IRIX-Specific Considerations::
 * Linux-Specific Considerations::
 * AIX-Specific Considerations::
 
@@ -585,9 +597,9 @@ Example of Binder Output File
 
 Elaboration Order Handling in GNAT
 
-* Elaboration Code in Ada 95::
-* Checking the Elaboration Order in Ada 95::
-* Controlling the Elaboration Order in Ada 95::
+* Elaboration Code::
+* Checking the Elaboration Order::
+* Controlling the Elaboration Order::
 * Controlling Elaboration in GNAT - Internal Calls::
 * Controlling Elaboration in GNAT - External Calls::
 * Default Behavior in GNAT - Ensuring Safety::
@@ -599,6 +611,13 @@ Elaboration Order Handling in GNAT
 * Summary of Procedures for Elaboration Control::
 * Other Elaboration Order Considerations::
 
+Conditional Compilation
+* Use of Boolean Constants::
+* Debugging - A Special Case::
+* Conditionalizing Declarations::
+* Use of Alternative Implementations::
+* Preprocessing::
+
 Inline Assembler
 
 * Basic Assembler Syntax::
@@ -607,15 +626,22 @@ Inline Assembler
 * Input Variables in Inline Assembler::
 * Inlining Inline Assembler Code::
 * Other Asm Functionality::
-* A Complete Example::
 
 Compatibility and Porting Guide
 
 * Compatibility with Ada 83::
+* Compatibility between Ada 95 and Ada 2005::
 * Implementation-dependent characteristics::
-* Compatibility with DEC Ada 83::
-* Compatibility with Other Ada 95 Systems::
+@ifclear vms
+@c This brief section is only in the non-VMS version
+@c The complete chapter on HP Ada issues is in the VMS version
+* Compatibility with HP Ada 83::
+@end ifclear
+* Compatibility with Other Ada Systems::
 * Representation Clauses::
+@ifset vms
+* Transitioning to 64-Bit GNAT for OpenVMS::
+@end ifset
 
 @ifset unw
 Microsoft Windows Topics
@@ -630,10 +656,10 @@ Microsoft Windows Topics
 * Building DLLs with GNAT::
 * GNAT and Windows Resources::
 * Debugging a DLL::
-* GNAT and COM/DCOM Objects::
+* Setting Stack Size from gnatlink::
+* Setting Heap Size from gnatlink::
 @end ifset
 
-
 * Index::
 @end menu
 @end ifnottex
@@ -643,15 +669,36 @@ Microsoft Windows Topics
 
 @noindent
 @ifset vms
-This guide describes the use of of GNAT, a full language compiler for the Ada
-95 programming language, implemented on HP OpenVMS Alpha platforms.
+This guide describes the use of @value{EDITION},
+a compiler and software development toolset for the full Ada
+programming language, implemented on OpenVMS for HP's Alpha and
+Integrity server (I64) platforms.
 @end ifset
 @ifclear vms
-This guide describes the use of GNAT, a compiler and software development
-toolset for the full Ada 95 programming language.
+This guide describes the use of @value{EDITION},
+a compiler and software development
+toolset for the full Ada programming language.
 @end ifclear
-It describes the features of the compiler and tools, and details
-how to use them to build Ada 95 applications.
+It documents the features of the compiler and tools, and explains
+how to use them to build Ada applications.
+
+@value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
+Ada 83 compatibility mode.
+By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
+but you can override with a compiler switch
+(@pxref{Compiling Different Versions of Ada})
+to explicitly specify the language version.
+Throughout this manual, references to ``Ada'' without a year suffix
+apply to both the Ada 95 and Ada 2005 versions of the language.
+
+
+@ifclear FSFEDITION
+For ease of exposition, ``@value{EDITION}'' will be referred to simply as
+``GNAT'' in the remainder of this document.
+@end ifclear
+
+
+
 
 @menu
 * What This Guide Contains::
@@ -676,7 +723,7 @@ by GNAT.
 
 @item
 @ref{Compiling Using gcc}, describes how to compile
-Ada programs with @code{gcc}, the Ada compiler.
+Ada programs with @command{gcc}, the Ada compiler.
 
 @item
 @ref{Binding Using gnatbind}, describes how to
@@ -685,13 +732,13 @@ utility.
 
 @item
 @ref{Linking Using gnatlink},
-describes @code{gnatlink}, a
+describes @command{gnatlink}, a
 program that provides for linking using the GNAT run-time library to
-construct a program. @code{gnatlink} can also incorporate foreign language
+construct a program. @command{gnatlink} can also incorporate foreign language
 object units into the executable.
 
 @item
-@ref{The GNAT Make Program gnatmake}, describes @code{gnatmake}, a
+@ref{The GNAT Make Program gnatmake}, describes @command{gnatmake}, a
 utility that automatically determines the set of sources
 needed by an Ada compilation unit, and executes the necessary compilations
 binding and link.
@@ -700,7 +747,8 @@ binding and link.
 @ref{Improving Performance}, shows various techniques for making your
 Ada program run faster or take less space.
 It discusses the effect of the compiler's optimization switch and
-also describes the @command{gnatelim} tool.
+also describes the @command{gnatelim} tool and unused subprogram/data
+elimination.
 
 @item
 @ref{Renaming Files Using gnatchop}, describes
@@ -731,6 +779,10 @@ way to navigate through sources.
 version of an Ada source file with control over casing, indentation,
 comment placement, and other elements of program presentation style.
 
+@item
+@ref{The GNAT Metric Tool gnatmetric}, shows how to compute various
+metrics for an Ada source file, such as the number of types and subprograms,
+and assorted complexity measures.
 
 @item
 @ref{File Name Krunching Using gnatkr}, describes the @code{gnatkr}
@@ -740,7 +792,7 @@ file names on operating systems with a limit on the length of names.
 @item
 @ref{Preprocessing Using gnatprep}, describes @code{gnatprep}, a
 preprocessor utility that allows a single source file to be used to
-generate multiple or parameterized source files, by means of macro
+generate multiple or parameterized source files by means of macro
 substitution.
 
 @ifset vms
@@ -771,12 +823,21 @@ the GNAT toolset in Makefiles.
 @end ifclear
 
 @item
-@ref{Finding Memory Problems}, describes
+@ref{Memory Management Issues}, describes some useful predefined storage pools
+and in particular the GNAT Debug Pool facility, which helps detect incorrect
+memory references.
 @ifclear vms
-@command{gnatmem}, a utility that monitors dynamic allocation and deallocation
-and helps detect ``memory leaks'', and
+It also describes @command{gnatmem}, a utility that monitors dynamic
+allocation and deallocation and helps detect ``memory leaks''.
 @end ifclear
-the GNAT Debug Pool facility, which helps detect incorrect memory references.
+
+@item
+@ref{Stack Related Facilities}, describes some useful tools associated with
+stack checking and analysis.
+
+@item
+@ref{Verifying Properties Using gnatcheck}, discusses @code{gnatcheck},
+a utility that checks Ada code against a set of rules.
 
 @item
 @ref{Creating Sample Bodies Using gnatstub}, discusses @code{gnatstub},
@@ -792,10 +853,14 @@ Ada programs.
 
 @ifset vms
 @item
-@ref{Compatibility with DEC Ada}, details the compatibility of GNAT with
-DEC Ada 83 @footnote{``DEC Ada'' refers to the legacy product originally
+@ref{Compatibility with HP Ada}, details the compatibility of GNAT with
+HP Ada 83 @footnote{``HP Ada'' refers to the legacy product originally
 developed by Digital Equipment Corporation and currently supported by HP.}
-for OpenVMS Alpha.
+for OpenVMS Alpha. This product was formerly known as DEC Ada,
+@cindex DEC Ada
+and for
+historical compatibility reasons, the relevant libraries still use the
+DEC prefix.
 @end ifset
 
 @item
@@ -813,13 +878,17 @@ output file for a sample program.
 you deal with elaboration order issues.
 
 @item
+@ref{Conditional Compilation}, describes how to model conditional compilation,
+both with Ada in general and with GNAT facilities in particular.
+
+@item
 @ref{Inline Assembler}, shows how to use the inline assembly facility
 in an Ada program.
 
 @item
-@ref{Compatibility and Porting Guide}, includes sections on compatibility
-of GNAT with other Ada 83 and Ada 95 compilation systems, to assist
-in porting code from other environments.
+@ref{Compatibility and Porting Guide}, contains sections on compatibility
+of GNAT with other Ada development environments (including Ada 83 systems),
+to assist in porting code from those environments.
 
 @ifset unw
 @item
@@ -828,17 +897,22 @@ Microsoft Windows platform.
 @end ifset
 @end itemize
 
-
 @c *************************************************
 @node What You Should Know before Reading This Guide
 @c *************************************************
 @unnumberedsec What You Should Know before Reading This Guide
 
 @cindex Ada 95 Language Reference Manual
+@cindex Ada 2005 Language Reference Manual
 @noindent
-This user's guide assumes that you are familiar with Ada 95 language, as
+This guide assumes a basic familiarity with the Ada 95 language, as
 described in the International Standard ANSI/ISO/IEC-8652:1995, January
 1995.
+It does not require knowledge of the new features introduced by Ada 2005,
+(officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
+and Amendment 1).
+Both reference manuals are included in the GNAT documentation
+package.
 
 @node Related Information
 @unnumberedsec Related Information
@@ -850,23 +924,27 @@ documents:
 @itemize @bullet
 @item
 @cite{GNAT Reference Manual}, which contains all reference
-material for the GNAT implementation of Ada 95.
+material for the GNAT implementation of Ada.
 
 @ifset unw
 @item
-@cite{Using the GNAT Programming System}, which describes the GPS
-integrated development environment.
+@cite{Using the GNAT Programming Studio}, which describes the GPS
+Integrated Development Environment.
 
 @item
-@cite{GNAT Programming System Tutorial}, which introduces the
+@cite{GNAT Programming Studio Tutorial}, which introduces the
 main GPS features through examples.
 @end ifset
 
 @item
-@cite{Ada 95 Language Reference Manual}, which contains all reference
+@cite{Ada 95 Reference Manual}, which contains reference
 material for the Ada 95 programming language.
 
 @item
+@cite{Ada 2005 Reference Manual}, which contains reference
+material for the Ada 2005 programming language.
+
+@item
 @cite{Debugging with GDB}
 @ifset vms
 , located in the GNU:[DOCS] directory,
@@ -895,17 +973,18 @@ in this guide:
 
 @itemize @bullet
 @item
-@code{Functions}, @code{utility program names}, @code{standard names},
+@code{Functions}, @command{utility program names}, @code{standard names},
 and @code{classes}.
 
 @item
-@samp{Option flags}
+@option{Option flags}
 
 @item
-@file{File Names}, @file{button names}, and @file{field names}.
+@file{File names}, @samp{button names}, and @samp{field names}.
 
 @item
-@var{Variables}.
+@code{Variables}, @env{environment variables}, and @var{metasyntactic
+variables}.
 
 @item
 @emph{Emphasis}.
@@ -935,8 +1014,6 @@ If you are using GNAT on a Windows platform, please note that
 the ``@code{\}'' character should be used instead.
 @end ifset
 
-
-
 @c ****************************
 @node Getting Started with GNAT
 @chapter Getting Started with GNAT
@@ -947,15 +1024,14 @@ executable Ada programs.
 @ifset unw
 @ref{Running GNAT}, through @ref{Using the gnatmake Utility},
 show how to use the command line environment.
-@ref{Introduction to Glide and GVD}, provides a brief
-introduction to the visually-oriented IDE for GNAT.
-Supplementing Glide on some platforms is GPS, the
-GNAT Programming System, which offers a richer graphical
-``look and feel'', enhanced configurability, support for
-development in other programming language, comprehensive
-browsing features, and many other capabilities.
+@ref{Introduction to GPS}, provides a brief
+introduction to the GNAT Programming Studio, a visually-oriented
+Integrated Development Environment for GNAT.
+GPS offers a graphical ``look and feel'', support for development in
+other programming languages, comprehensive browsing features, and
+many other capabilities.
 For information on GPS please refer to
-@cite{Using the GNAT Programming System}.
+@cite{Using the GNAT Programming Studio}.
 @end ifset
 
 @menu
@@ -968,7 +1044,6 @@ For information on GPS please refer to
 @end ifset
 @ifclear vms
 * Introduction to GPS::
-* Introduction to Glide and GVD::
 @end ifclear
 @end menu
 
@@ -989,22 +1064,19 @@ All appropriate object files must be linked to produce an executable.
 @end enumerate
 
 @noindent
-All three steps are most commonly handled by using the @code{gnatmake}
+All three steps are most commonly handled by using the @command{gnatmake}
 utility program that, given the name of the main program, automatically
 performs the necessary compilation, binding and linking steps.
 
-
 @node Running a Simple Ada Program
 @section Running a Simple Ada Program
 
 @noindent
 Any text editor may be used to prepare an Ada program.
-@ifclear vms
-If @code{Glide} is
-used, the optional Ada mode may be helpful in laying out the program.
-@end ifclear
+(If @code{Emacs} is
+used, the optional Ada mode may be helpful in laying out the program.)
 The
-program text is a normal text file. We will suppose in our initial
+program text is a normal text file. We will assume in our initial
 example that you have used your editor to prepare the following
 standard format text file:
 
@@ -1043,8 +1115,8 @@ $ gcc -c hello.adb
 @end smallexample
 
 @noindent
-@code{gcc} is the command used to run the compiler. This compiler is
-capable of compiling programs in several languages, including Ada 95 and
+@command{gcc} is the command used to run the compiler. This compiler is
+capable of compiling programs in several languages, including Ada and
 C. It assumes that you have given it an Ada program if the file extension is
 either @file{.ads} or @file{.adb}, and it will then call
 the GNAT compiler to compile the specified file.
@@ -1064,8 +1136,8 @@ which contains additional information used to check
 that an Ada program is consistent.
 To build an executable file,
 use @code{gnatbind} to bind the program
-and @code{gnatlink} to link it. The
-argument to both @code{gnatbind} and @code{gnatlink} is the name of the
+and @command{gnatlink} to link it. The
+argument to both @code{gnatbind} and @command{gnatlink} is the name of the
 @file{ALI} file, but the default extension of @file{.ali} can
 be omitted. This means that in the most common case, the argument
 is simply the name of the main program:
@@ -1093,13 +1165,8 @@ $ gnatmake hello.adb
 The result is an executable program called @file{hello}, which can be
 run by entering:
 
-@c The following should be removed (BMB 2001-01-23)
-@c @smallexample
-@c $ ^./hello^$ RUN HELLO^
-@c @end smallexample
-
 @smallexample
-$ hello
+$ ^hello^RUN HELLO^
 @end smallexample
 
 @noindent
@@ -1116,7 +1183,6 @@ Hello WORLD!
 @noindent
 appear in response to this command.
 
-
 @c ****************************************
 @node Running a Program with Multiple Units
 @section Running a Program with Multiple Units
@@ -1201,7 +1267,7 @@ $ gcc -c greetings.ads -gnatc
 @noindent
 Although the compilation can be done in separate steps as in the
 above example, in practice it is almost always more convenient
-to use the @code{gnatmake} tool. All you need to know in this case
+to use the @command{gnatmake} tool. All you need to know in this case
 is the name of the main program's source file. The effect of the above four
 commands can be achieved with a single one:
 
@@ -1210,7 +1276,7 @@ $ gnatmake gmain.adb
 @end smallexample
 
 @noindent
-In the next section we discuss the advantages of using @code{gnatmake} in
+In the next section we discuss the advantages of using @command{gnatmake} in
 more detail.
 
 @c *****************************
@@ -1219,7 +1285,7 @@ more detail.
 
 @noindent
 If you work on a program by compiling single components at a time using
-@code{gcc}, you typically keep track of the units you modify. In order to
+@command{gcc}, you typically keep track of the units you modify. In order to
 build a consistent system, you compile not only these units, but also any
 units that depend on the units you have modified.
 For example, in the preceding case,
@@ -1238,7 +1304,7 @@ if the dependencies change as you change the program, you must make
 sure that the makefile is kept up-to-date manually, which is also an
 error-prone process.
 
-The @code{gnatmake} utility takes care of these details automatically.
+The @command{gnatmake} utility takes care of these details automatically.
 Invoke it using either one of the following forms:
 
 @smallexample
@@ -1248,22 +1314,22 @@ $ gnatmake ^gmain^GMAIN^
 
 @noindent
 The argument is the name of the file containing the main program;
-you may omit the extension. @code{gnatmake}
+you may omit the extension. @command{gnatmake}
 examines the environment, automatically recompiles any files that need
 recompiling, and binds and links the resulting set of object files,
 generating the executable file, @file{^gmain^GMAIN.EXE^}.
 In a large program, it
-can be extremely helpful to use @code{gnatmake}, because working out by hand
+can be extremely helpful to use @command{gnatmake}, because working out by hand
 what needs to be recompiled can be difficult.
 
-Note that @code{gnatmake}
-takes into account all the Ada 95 rules that
+Note that @command{gnatmake}
+takes into account all the Ada rules that
 establish dependencies among units. These include dependencies that result
 from inlining subprogram bodies, and from
 generic instantiation. Unlike some other
-Ada make tools, @code{gnatmake} does not rely on the dependencies that were
+Ada make tools, @command{gnatmake} does not rely on the dependencies that were
 found by the compiler on a previous compilation, which may possibly
-be wrong when sources change. @code{gnatmake} determines the exact set of
+be wrong when sources change. @command{gnatmake} determines the exact set of
 dependencies from scratch each time it is run.
 
 @ifset vms
@@ -1298,14 +1364,14 @@ environment and shell for the sophisticated user.
 @ifclear vms
 @node Introduction to GPS
 @section Introduction to GPS
-@cindex GPS (GNAT Programming System)
-@cindex GNAT Programming System (GPS)
+@cindex GPS (GNAT Programming Studio)
+@cindex GNAT Programming Studio (GPS)
 @noindent
 Although the command line interface (@command{gnatmake}, etc.) alone
 is sufficient, a graphical Interactive Development
 Environment can make it easier for you to compose, navigate, and debug
 programs.  This section describes the main features of GPS
-(``GNAT Programming System''), the GNAT graphical IDE.
+(``GNAT Programming Studio''), the GNAT graphical IDE.
 You will see how to use GPS to build and debug an executable, and
 you will also learn some of the basics of the GNAT ``project'' facility.
 
@@ -1324,7 +1390,6 @@ startup menu).
 * Simple Debugging with GPS::
 @end menu
 
-
 @node Building a New Program with GPS
 @subsection Building a New Program with GPS
 @noindent
@@ -1333,7 +1398,7 @@ contained in a @emph{project} (also known as a @emph{project file}):
 a collection of properties such
 as source directories, identities of main subprograms, tool switches, etc.,
 and their associated values.
-(See @ref{GNAT Project Manager}, for details.)
+See @ref{GNAT Project Manager} for details.
 In order to run GPS, you will need to either create a new project
 or else open an existing one.
 
@@ -1431,7 +1496,6 @@ Select @code{File}, then @code{Save As}, and enter the source file name
 The file will be saved in the same directory you specified as the
 location of the default project file.
 
-
 @item @emph{Updating the project file}
 
 You need to add the new source file to the project.
@@ -1465,8 +1529,6 @@ Close the GPS window (or select @code{File}, then @code{Exit}) to
 terminate this GPS session.
 @end enumerate
 
-
-
 @node Simple Debugging with GPS
 @subsection Simple Debugging with GPS
 @noindent
@@ -1574,7 +1636,6 @@ Right click on @code{N}, select @code{Debug}, then select @code{Display N}.
 You will see information about @code{N} appear in the @code{Debugger Data}
 pane, showing the value as 5.
 
-
 @item @emph{Assigning a new value to a variable}
 
 Right click on the @code{N} in the @code{Debugger Data} pane, and
@@ -1609,262 +1670,6 @@ The value of @code{N} will be 0, and the program will terminate.
 The console window will disappear.
 @end enumerate
 @end enumerate
-
-
-@node Introduction to Glide and GVD
-@section Introduction to Glide and GVD
-@cindex Glide
-@cindex GVD
-@noindent
-This section describes the main features of Glide,
-a GNAT graphical IDE, and also shows how to use the basic commands in GVD,
-the GNU Visual Debugger.
-These tools may be present in addition to, or in place of, GPS on some
-platforms.
-Additional information on Glide and GVD may be found
-in the on-line help for these tools.
-
-@menu
-* Building a New Program with Glide::
-* Simple Debugging with GVD::
-* Other Glide Features::
-@end menu
-
-@node Building a New Program with Glide
-@subsection Building a New Program with Glide
-@noindent
-The simplest way to invoke Glide is to enter @command{glide}
-at the command prompt.  It will generally be useful to issue this
-as a background command, thus allowing you to continue using
-your command window for other purposes while Glide is running:
-
-@smallexample
-$ glide&
-@end smallexample
-
-@noindent
-Glide will start up with an initial screen displaying the top-level menu items
-as well as some other information.  The menu selections are as follows
-@itemize @bullet
-@item @code{Buffers}
-@item @code{Files}
-@item @code{Tools}
-@item @code{Edit}
-@item @code{Search}
-@item @code{Mule}
-@item @code{Glide}
-@item @code{Help}
-@end itemize
-
-@noindent
-For this introductory example, you will need to create a new Ada source file.
-First, select the @code{Files} menu.  This will pop open a menu with around
-a dozen or so items.  To create a file, select the @code{Open file...} choice.
-Depending on the platform, you may see a pop-up window where you can browse
-to an appropriate directory and then enter the file name, or else simply
-see a line at the bottom of the Glide window where you can likewise enter
-the file name.  Note that in Glide, when you attempt to open a non-existent
-file, the effect is to create a file with that name.  For this example enter
-@file{hello.adb} as the name of the file.
-
-A new buffer will now appear, occupying the entire Glide window,
-with the file name at the top.  The menu selections are slightly different
-from the ones you saw on the opening screen; there is an @code{Entities} item,
-and in place of @code{Glide} there is now an @code{Ada} item.  Glide uses
-the file extension to identify the source language, so @file{adb} indicates
-an Ada source file.
-
-You will enter some of the source program lines explicitly,
-and use the syntax-oriented template mechanism to enter other lines.
-First, type the following text:
-@smallexample
-with Ada.Text_IO; use Ada.Text_IO;
-procedure Hello is
-begin
-@end smallexample
-
-@noindent
-Observe that Glide uses different colors to distinguish reserved words from
-identifiers.  Also, after the @code{procedure Hello is} line, the cursor is
-automatically indented in anticipation of declarations.  When you enter
-@code{begin}, Glide recognizes that there are no declarations and thus places
-@code{begin} flush left.  But after the @code{begin} line the cursor is again
-indented, where the statement(s) will be placed.
-
-The main part of the program will be a @code{for} loop.  Instead of entering
-the text explicitly, however, use a statement template.  Select the @code{Ada}
-item on the top menu bar, move the mouse to the @code{Statements} item,
-and you will see a large selection of alternatives.  Choose @code{for loop}.
-You will be prompted (at the bottom of the buffer) for a loop name;
-simply press the @key{Enter} key since a loop name is not needed.
-You should see the beginning of a @code{for} loop appear in the source
-program window.  You will now be prompted for the name of the loop variable;
-enter a line with the identifier @code{ind} (lower case).  Note that,
-by default, Glide capitalizes the name (you can override such behavior
-if you wish, although this is outside the scope of this introduction).
-Next, Glide prompts you for the loop range; enter a line containing
-@code{1..5} and you will see this also appear in the source program,
-together with the remaining elements of the @code{for} loop syntax.
-
-Next enter the statement (with an intentional error, a missing semicolon)
-that will form the body of the loop:
-@smallexample
-Put_Line("Hello, World" & Integer'Image(I))
-@end smallexample
-
-@noindent
-Finally, type @code{end Hello;} as the last line in the program.
-Now save the file: choose the @code{File} menu item, and then the
-@code{Save buffer} selection.  You will see a message at the bottom
-of the buffer confirming that the file has been saved.
-
-You are now ready to attempt to build the program.  Select the @code{Ada}
-item from the top menu bar.  Although we could choose simply to compile
-the file, we will instead attempt to do a build (which invokes
-@command{gnatmake}) since, if the compile is successful, we want to build
-an executable.  Thus select @code{Ada build}.  This will fail because of the
-compilation error, and you will notice that the Glide window has been split:
-the top window contains the source file, and the bottom window contains the
-output from the GNAT tools. Glide allows you to navigate from a compilation
-error to the source file position corresponding to the error: click the
-middle mouse button (or simultaneously press the left and right buttons,
-on a two-button mouse) on the diagnostic line in the tool window.  The
-focus will shift to the source window, and the cursor will be positioned
-on the character at which the error was detected.
-
-Correct the error: type in a semicolon to terminate the statement.
-Although you can again save the file explicitly, you can also simply invoke
-@code{Ada} @result{} @code{Build} and you will be prompted to save the file.
-This time the build will succeed; the tool output window shows you the
-options that are supplied by default.  The GNAT tools' output (e.g.
-object and ALI files, executable) will go in the directory from which
-Glide was launched.
-
-To execute the program, choose @code{Ada} and then @code{Run}.
-You should see the program's output displayed in the bottom window:
-
-@smallexample
-Hello, world 1
-Hello, world 2
-Hello, world 3
-Hello, world 4
-Hello, world 5
-@end smallexample
-
-@node Simple Debugging with GVD
-@subsection Simple Debugging with GVD
-
-@noindent
-This section describes how to set breakpoints, examine/modify variables,
-and step through execution.
-
-In order to enable debugging, you need to pass the @option{-g} switch
-to both the compiler and to @command{gnatlink}.  If you are using
-the command line, passing @option{-g} to @command{gnatmake} will have
-this effect.  You can then launch GVD, e.g. on the @code{hello} program,
-by issuing the command:
-
-@smallexample
-$ gvd hello
-@end smallexample
-
-@noindent
-If you are using Glide, then @option{-g} is passed to the relevant tools
-by default when you do a build.  Start the debugger by selecting the
-@code{Ada} menu item, and then @code{Debug}.
-
-GVD comes up in a multi-part window.  One pane shows the names of files
-comprising your executable; another pane shows the source code of the current
-unit (initially your main subprogram), another pane shows the debugger output
-and user interactions, and the fourth pane (the data canvas at the top
-of the window) displays data objects that you have selected.
-
-To the left of the source file pane, you will notice green dots adjacent
-to some lines.  These are lines for which object code exists and where
-breakpoints can thus be set.  You set/reset a breakpoint by clicking
-the green dot.  When a breakpoint is set, the dot is replaced by an @code{X}
-in a red circle.  Clicking the circle toggles the breakpoint off,
-and the red circle is replaced by the green dot.
-
-For this example, set a breakpoint at the statement where @code{Put_Line}
-is invoked.
-
-Start program execution by selecting the @code{Run} button on the top menu bar.
-(The @code{Start} button will also start your program, but it will
-cause program execution to break at the entry to your main subprogram.)
-Evidence of reaching the breakpoint will appear: the source file line will be
-highlighted, and the debugger interactions pane will display
-a relevant message.
-
-You can examine the values of variables in several ways.  Move the mouse
-over an occurrence of @code{Ind} in the @code{for} loop, and you will see
-the value (now @code{1}) displayed.  Alternatively, right-click on @code{Ind}
-and select @code{Display Ind}; a box showing the variable's name and value
-will appear in the data canvas.
-
-Although a loop index is a constant with respect to Ada semantics,
-you can change its value in the debugger.  Right-click in the box
-for @code{Ind}, and select the @code{Set Value of Ind} item.
-Enter @code{2} as the new value, and press @command{OK}.
-The box for @code{Ind} shows the update.
-
-Press the @code{Step} button on the top menu bar; this will step through
-one line of program text (the invocation of @code{Put_Line}), and you can
-observe the effect of having modified @code{Ind} since the value displayed
-is @code{2}.
-
-Remove the breakpoint, and resume execution by selecting the @code{Cont}
-button.  You will see the remaining output lines displayed in the debugger
-interaction window, along with a message confirming normal program
-termination.
-
-@node Other Glide Features
-@subsection Other Glide Features
-
-@noindent
-You may have observed that some of the menu selections contain abbreviations;
-e.g., @code{(C-x C-f)} for @code{Open file...} in the @code{Files} menu.
-These are @emph{shortcut keys} that you can use instead of selecting
-menu items.  The @key{C} stands for @key{Ctrl}; thus @code{(C-x C-f)} means
-@key{Ctrl-x} followed by @key{Ctrl-f}, and this sequence can be used instead
-of selecting @code{Files} and then @code{Open file...}.
-
-To abort a Glide command, type @key{Ctrl-g}.
-
-If you want Glide to start with an existing source file, you can either
-launch Glide as above and then open the file via @code{Files} @result{}
-@code{Open file...}, or else simply pass the name of the source file
-on the command line:
-
-@smallexample
-$ glide hello.adb&
-@end smallexample
-
-@noindent
-While you are using Glide, a number of @emph{buffers} exist.
-You create some explicitly; e.g., when you open/create a file.
-Others arise as an effect of the commands that you issue; e.g., the buffer
-containing the output of the tools invoked during a build.  If a buffer
-is hidden, you can bring it into a visible window by first opening
-the @code{Buffers} menu and then selecting the desired entry.
-
-If a buffer occupies only part of the Glide screen and you want to expand it
-to fill the entire screen, then click in the buffer and then select
-@code{Files} @result{} @code{One Window}.
-
-If a window is occupied by one buffer and you want to split the window
-to bring up a second buffer, perform the following steps:
-@itemize @bullet
-@item Select @code{Files} @result{} @code{Split Window};
-this will produce two windows each of which holds the original buffer
-(these are not copies, but rather different views of the same buffer contents)
-
-@item With the focus in one of the windows,
-select the desired buffer from the @code{Buffers} menu
-@end itemize
-
-@noindent
-To exit from Glide, choose @code{Files} @result{} @code{Exit}.
 @end ifclear
 
 @node The GNAT Compilation Model
@@ -1883,8 +1688,10 @@ To exit from Glide, choose @code{Files} @result{} @code{Exit}.
 * The Ada Library Information Files::
 * Binding an Ada Program::
 * Mixed Language Programming::
+@ifclear vms
 * Building Mixed Ada & C++ Programs::
 * Comparison between GNAT and C/C++ Compilation Models::
+@end ifclear
 * Comparison between GNAT and Conventional Ada Library Models::
 @ifset vms
 * Placement of temporary files::
@@ -1939,7 +1746,7 @@ Form feed, @code{16#0C#}
 
 @noindent
 Source files are in standard text file format. In addition, GNAT will
-recognize a wide variety of stream formats, in which the end of physical
+recognize a wide variety of stream formats, in which the end of
 physical lines is marked by any of the following sequences:
 @code{LF}, @code{CR}, @code{CR-LF}, or @code{LF-CR}. This is useful
 in accommodating files that are imported from other operating systems.
@@ -1964,7 +1771,7 @@ you will place each subunit or child unit in a separate file.
 @section Foreign Language Representation
 
 @noindent
-GNAT supports the standard character sets defined in Ada 95 as well as
+GNAT supports the standard character sets defined in Ada as well as
 several other non-standard character sets for use in localized versions
 of the compiler (@pxref{Character Set Control}).
 @menu
@@ -1980,7 +1787,7 @@ of the compiler (@pxref{Character Set Control}).
 @noindent
 The basic character set is Latin-1. This character set is defined by ISO
 standard 8859, part 1. The lower half (character codes @code{16#00#}
-... @code{16#7F#)} is identical to standard ASCII coding, but the upper half
+@dots{} @code{16#7F#)} is identical to standard ASCII coding, but the upper half
 is used to represent additional characters. These include extended letters
 used by European languages, such as French accents, the vowels with umlauts
 used in German, and the extra letter A-ring used in Swedish.
@@ -2163,7 +1970,7 @@ ACVC (Ada Compiler Validation Capability) test suite distributions.
 
 @noindent
 Note: Some of these coding schemes do not permit the full use of the
-Ada 95 character set. For example, neither Shift JIS, nor EUC allow the
+Ada character set. For example, neither Shift JIS, nor EUC allow the
 use of the upper half of the Latin-1 set.
 
 @node File Naming Rules
@@ -2284,7 +2091,7 @@ normally it will be placed in the @file{gnat.adc}
 file used to hold configuration
 pragmas that apply to a complete compilation environment.
 For more details on how the @file{gnat.adc} file is created and used
-@pxref{Handling of Configuration Pragmas}
+see @ref{Handling of Configuration Pragmas}.
 @cindex @file{gnat.adc}
 
 @ifclear vms
@@ -2292,7 +2099,7 @@ GNAT allows completely arbitrary file names to be specified using the
 source file name pragma. However, if the file name specified has an
 extension other than @file{.ads} or @file{.adb} it is necessary to use
 a special syntax when compiling the file. The name in this case must be
-preceded by the special sequence @code{-x} followed by a space and the name
+preceded by the special sequence @option{-x} followed by a space and the name
 of the language, here @code{ada}, as in:
 
 @smallexample
@@ -2301,10 +2108,11 @@ $ gcc -c -x ada peculiar_file_name.sim
 @end ifclear
 
 @noindent
-@code{gnatmake} handles non-standard file names in the usual manner (the
+@command{gnatmake} handles non-standard file names in the usual manner (the
 non-standard file name for the main program is simply used as the
 argument to gnatmake). Note that if the extension is also non-standard,
-then it must be included in the gnatmake command, it may not be omitted.
+then it must be included in the @command{gnatmake} command, it may not
+be omitted.
 
 @node Alternative File Naming Schemes
 @section Alternative File Naming Schemes
@@ -2559,10 +2367,10 @@ Note that
 to specify both options.
 
 @item
-If an object file O  depends on the proper body of a subunit through inlining
-or instantiation, it depends on the parent unit of the subunit. This means that
-any modification of the parent unit or one of its subunits affects the
-compilation of O.
+If an object file @file{O} depends on the proper body of a subunit through
+inlining or instantiation, it depends on the parent unit of the subunit.
+This means that any modification of the parent unit or one of its subunits
+affects the compilation of @file{O}.
 
 @item
 The object file for a parent unit depends on all its subunit body files.
@@ -2578,9 +2386,10 @@ unit @code{B}, whose elaboration calls an inlined procedure in package
 @code{C}, in file @file{c.adb}.
 
 The set of dependent files described by these rules includes all the
-files on which the unit is semantically dependent, as described in the
-Ada 95 Language Reference Manual. However, it is a superset of what the
-ARM describes, because it includes generic, inline, and subunit dependencies.
+files on which the unit is semantically dependent, as dictated by the
+Ada language standard. However, it is a superset of what the
+standard describes, because it includes generic, inline, and subunit
+dependencies.
 
 An object file must be recreated by recompiling the corresponding source
 file if any of the source files on which it depends are modified. For
@@ -2588,7 +2397,7 @@ example, if the @code{make} utility is used to control compilation,
 the rule for an Ada object file must mention all the source files on
 which the object file depends, according to the above definition.
 The determination of the necessary
-recompilations is done automatically when one uses @code{gnatmake}.
+recompilations is done automatically when one uses @command{gnatmake}.
 @end itemize
 
 @node The Ada Library Information Files
@@ -2614,7 +2423,7 @@ Main program information (including priority and time slice settings,
 as well as the wide character encoding used during compilation).
 
 @item
-List of arguments used in the @code{gcc} command for the compilation
+List of arguments used in the @command{gcc} command for the compilation
 
 @item
 Attributes of the unit, including configuration pragmas used, an indication
@@ -2710,9 +2519,9 @@ specifically one that comprises units in both Ada and C.
 Interfacing Ada with a foreign language such as C involves using
 compiler directives to import and/or export entity definitions in each
 language---using @code{extern} statements in C, for instance, and the
-@code{Import}, @code{Export}, and @code{Convention} pragmas in Ada.  For
-a full treatment of these topics, read Appendix B, section 1 of the Ada
-95 Language Reference Manual.
+@code{Import}, @code{Export}, and @code{Convention} pragmas in Ada.
+A full treatment of these topics is provided in Appendix B, section 1
+of the Ada Reference Manual.
 
 There are two ways to build a program using GNAT that contains some Ada
 sources and some foreign language sources, depending on whether or not
@@ -2768,8 +2577,8 @@ end My_Main;
 To build this example, first compile the foreign language files to
 generate object files:
 @smallexample
-gcc -c file1.c
-gcc -c file2.c
+^gcc -c file1.c^gcc -c FILE1.C^
+^gcc -c file2.c^gcc -c FILE2.C^
 @end smallexample
 
 @item
@@ -2871,7 +2680,7 @@ The build procedure for this application is similar to the last
 example's.  First, compile the foreign language files to generate object
 files:
 @smallexample
-gcc -c main.c
+^gcc -c main.c^gcc -c main.c^
 @end smallexample
 
 @item
@@ -2899,6 +2708,12 @@ gnatlink unit2.ali main.o -o exec_file
 This procedure yields a binary executable called @file{exec_file}.
 @end enumerate
 
+@noindent
+Depending on the circumstances (for example when your non-Ada main object
+does not provide symbol @code{main}), you may also need to instruct the
+GNAT linker not to include the standard startup objects by passing the
+@option{^-nostartfiles^/NOSTART_FILES^} switch to @command{gnatlink}.
+
 @node Calling Conventions
 @subsection Calling Conventions
 @cindex Foreign Languages
@@ -2925,7 +2740,7 @@ involving variant records, access parameters, tasks, or protected types,
 are unlikely to be able to be passed.
 
 Note that in the case of GNAT running
-on a platform that supports DEC Ada 83, a higher degree of compatibility
+on a platform that supports HP Ada 83, a higher degree of compatibility
 can be guaranteed, and in particular records are layed out in an identical
 manner in the two compilers. Note also that if output from two different
 compilers is mixed, the program is responsible for dealing with elaboration
@@ -2936,8 +2751,8 @@ elaboration of the GNAT components. Consult the documentation of the other
 Ada compiler for further details on elaboration.
 
 However, it is not possible to mix the tasking run time of GNAT and
-DEC Ada 83, All the tasking operations must either be entirely within
-GNAT compiled sections of the program, or entirely within DEC Ada 83
+HP Ada 83, All the tasking operations must either be entirely within
+GNAT compiled sections of the program, or entirely within HP Ada 83
 compiled sections of the program.
 
 @cindex Interfacing to Assembly
@@ -2957,19 +2772,22 @@ Equivalent to Assembler.
 @findex COBOL
 @item COBOL
 Data will be passed according to the conventions described
-in section B.4 of the Ada 95 Reference Manual.
+in section B.4 of the Ada Reference Manual.
 
 @findex C
 @cindex Interfacing to C
 @cindex Convention C
 @item C
 Data will be passed according to the conventions described
-in section B.3 of the Ada 95 Reference Manual.
+in section B.3 of the Ada Reference Manual.
 
+A note on interfacing to a C ``varargs'' function:
 @findex C varargs function
-@cindex Intefacing to C varargs function
-@cindex varargs function intefacs
-@item C varargs function
+@cindex Interfacing to C varargs function
+@cindex varargs function interfaces
+
+@itemize @bullet
+@item
 In C, @code{varargs} allows a function to take a variable number of
 arguments. There is no direct equivalent in this to Ada. One
 approach that can be used is to create a C wrapper for each
@@ -2978,15 +2796,17 @@ example, to print an @code{int} value using @code{printf},
 create a C function @code{printfi} that takes two arguments, a
 pointer to a string and an int, and calls @code{printf}.
 Then in the Ada program, use pragma @code{Import} to
-interface to printfi.
+interface to @code{printfi}.
 
+@item
 It may work on some platforms to directly interface to
 a @code{varargs} function by providing a specific Ada profile
-for a particular call. However, this does not work on
+for a particular call. However, this does not work on
 all platforms, since there is no guarantee that the
 calling sequence for a two argument normal C function
 is the same as for calling a @code{varargs} C function with
 the same two arguments.
+@end itemize
 
 @cindex Convention Default
 @findex Default
@@ -2998,24 +2818,26 @@ Equivalent to C.
 @item External
 Equivalent to C.
 
+@ifclear vms
 @findex C++
 @cindex Interfacing to C++
 @cindex Convention C++
-@item CPP
+@item C_Plus_Plus (or CPP)
 This stands for C++. For most purposes this is identical to C.
 See the separate description of the specialized GNAT pragmas relating to
 C++ interfacing for further details.
+@end ifclear
 
 @findex Fortran
 @cindex Interfacing to Fortran
 @cindex Convention Fortran
 @item Fortran
 Data will be passed according to the conventions described
-in section B.5 of the Ada 95 Reference Manual.
+in section B.5 of the Ada Reference Manual.
 
 @item Intrinsic
-This applies to an intrinsic operation, as defined in the Ada 95
-Reference Manual. If a pragma Import (Intrinsic) applies to a subprogram,
+This applies to an intrinsic operation, as defined in the Ada
+Reference Manual. If a pragma Import (Intrinsic) applies to a subprogram,
 this means that the body of the subprogram is provided by the compiler itself,
 usually by means of an efficient code sequence, and that the user does not
 supply an explicit body for it. In an application program, the pragma can
@@ -3024,8 +2846,8 @@ recognizes.
 
 @itemize @bullet
 @item
-Rotate_Left, Rotate_Right, Shift_Left, Shift_Right, Shift_Right_-
-Arithmetic.  The corresponding subprogram declaration must have
+Rotate_Left, Rotate_Right, Shift_Left, Shift_Right,
+Shift_Right_Arithmetic.  The corresponding subprogram declaration must have
 two formal parameters. The
 first one must be a signed integer type or a modular type with a binary
 modulus, and the second parameter must be of type Natural.
@@ -3058,19 +2880,21 @@ implemented as a single machine instruction.
 @findex Stdcall
 @cindex Convention Stdcall
 @item Stdcall
-This is relevant only to NT/Win95 implementations of GNAT,
-and specifies that the Stdcall calling sequence will be used, as defined
-by the NT API.
+This is relevant only to Windows XP/2000/NT implementations of GNAT,
+and specifies that the @code{Stdcall} calling sequence will be used,
+as defined by the NT API. Nevertheless, to ease building
+cross-platform bindings this convention will be handled as a @code{C} calling
+convention on non Windows platforms.
 
 @findex DLL
 @cindex Convention DLL
 @item DLL
-This is equivalent to Stdcall.
+This is equivalent to @code{Stdcall}.
 
 @findex Win32
 @cindex Convention Win32
 @item Win32
-This is equivalent to Stdcall.
+This is equivalent to @code{Stdcall}.
 @end ifset
 
 @findex Stubbed
@@ -3096,44 +2920,44 @@ And from now on the identifier Fortran77 may be used as a convention
 identifier (for example in an @code{Import} pragma) with the same
 meaning as Fortran.
 
+@ifclear vms
 @node Building Mixed Ada & C++ Programs
-@section Building Mixed Ada & C++ Programs
+@section Building Mixed Ada and C++ Programs
 
 @noindent
 A programmer inexperienced with mixed-language development may find that
 building an application containing both Ada and C++ code can be a
-challenge. As a matter of fact, interfacing with C++ has not been
-standardized in the Ada 95 Reference Manual due to the immaturity of --
-and lack of standards for -- C++ at the time. This section gives a few
+challenge.  This section gives a few
 hints that should make this task easier. The first section addresses
-the differences regarding interfacing with C. The second section
+the differences between interfacing with C and interfacing with C++.
+The second section
 looks into the delicate problem of linking the complete application from
 its Ada and C++ parts. The last section gives some hints on how the GNAT
-run time can be adapted in order to allow inter-language dispatching
+run-time library can be adapted in order to allow inter-language dispatching
 with a new C++ compiler.
 
 @menu
 * Interfacing to C++::
 * Linking a Mixed C++ & Ada Program::
 * A Simple Example::
-* Adapting the Run Time to a New C++ Compiler::
+* Interfacing with C++ at the Class Level::
 @end menu
 
 @node Interfacing to C++
 @subsection Interfacing to C++
 
 @noindent
-GNAT supports interfacing with C++ compilers generating code that is
-compatible with the standard Application Binary Interface of the given
-platform.
+GNAT supports interfacing with the G++ compiler (or any C++ compiler
+generating code that is compatible with the G++ Application Binary
+Interface ---see http://www.codesourcery.com/archives/cxx-abi).
 
 @noindent
 Interfacing can be done at 3 levels: simple data, subprograms, and
-classes. In the first two cases, GNAT offers a specific @var{Convention
-CPP} that behaves exactly like @var{Convention C}. Usually, C++ mangles
-the names of subprograms, and currently, GNAT does not provide any help
-to solve the demangling problem. This problem can be addressed in two
-ways:
+classes. In the first two cases, GNAT offers a specific @code{Convention
+C_Plus_Plus} (or @code{CPP}) that behaves exactly like @code{Convention C}.
+Usually, C++ mangles the names of subprograms, and currently, GNAT does
+not provide any help to solve the demangling problem. This problem can be
+addressed in two ways:
 @itemize @bullet
 @item
 by modifying the C++ code in order to force a C convention using
@@ -3146,8 +2970,8 @@ the pragma import.
 
 @noindent
 Interfacing at the class level can be achieved by using the GNAT specific
-pragmas such as @code{CPP_Class} and @code{CPP_Virtual}. See the GNAT
-Reference Manual for additional information.
+pragmas such as @code{CPP_Constructor}. See the GNAT Reference Manual for
+additional information.
 
 @node Linking a Mixed C++ & Ada Program
 @subsection Linking a Mixed C++ & Ada Program
@@ -3177,16 +3001,17 @@ $ gnatmake ada_unit -largs file1.o file2.o --LINK=c++
 
 @item
 Using GNAT and G++ from two different GCC installations: If both
-compilers are on the PATH, the previous method may be used. It is
-important to note that environment variables such as C_INCLUDE_PATH,
-GCC_EXEC_PREFIX, BINUTILS_ROOT, and GCC_ROOT will affect both compilers
+compilers are on the @env{PATH}, the previous method may be used. It is
+important to note that environment variables such as
+@env{C_INCLUDE_PATH}, @env{GCC_EXEC_PREFIX}, @env{BINUTILS_ROOT}, and
+@env{GCC_ROOT} will affect both compilers
 at the same time and may make one of the two compilers operate
 improperly if set during invocation of the wrong compiler.  It is also
 very important that the linker uses the proper @file{libgcc.a} GCC
 library -- that is, the one from the C++ compiler installation. The
-implicit link command as suggested in the gnatmake command from the
-former example can be replaced by an explicit link command with the
-full-verbosity option in order to verify which library is used:
+implicit link command as suggested in the @command{gnatmake} command
+from the former example can be replaced by an explicit link command with
+the full-verbosity option in order to verify which library is used:
 @smallexample
 $ gnatbind ada_unit
 $ gnatlink -v -v ada_unit file1.o file2.o --LINK=c++
@@ -3208,18 +3033,39 @@ $ gnatlink -v -v ada_unit file1.o file2.o --LINK=./my_script
 @item
 Using a non-GNU C++ compiler: The commands previously described can be
 used to insure that the C++ linker is used. Nonetheless, you need to add
-the path to libgcc explicitly, since some libraries needed by GNAT are
-located in this directory:
+a few more parameters to the link command line, depending on the exception
+mechanism used.
+
+If the @code{setjmp/longjmp} exception mechanism is used, only the paths
+to the libgcc libraries are required:
 
 @smallexample
 $ cat ./my_script
 #!/bin/sh
-CC $* `gcc -print-libgcc-file-name`
+CC $* `gcc -print-file-name=libgcc.a` `gcc -print-file-name=libgcc_eh.a`
 $ gnatlink ada_unit file1.o file2.o --LINK=./my_script
 @end smallexample
 
 Where CC is the name of the non-GNU C++ compiler.
 
+If the @code{zero cost} exception mechanism is used, and the platform
+supports automatic registration of exception tables (e.g. Solaris or IRIX),
+paths to more objects are required:
+
+@smallexample
+$ cat ./my_script
+#!/bin/sh
+CC `gcc -print-file-name=crtbegin.o` $* \
+`gcc -print-file-name=libgcc.a` `gcc -print-file-name=libgcc_eh.a` \
+`gcc -print-file-name=crtend.o`
+$ gnatlink ada_unit file1.o file2.o --LINK=./my_script
+@end smallexample
+
+If the @code{zero cost} exception mechanism is used, and the platform
+doesn't support automatic registration of exception tables (e.g. HP-UX,
+Tru64 or AIX), the simple approach described above will not work and
+a pre-linking phase using GNAT will be necessary.
+
 @end enumerate
 
 @node A Simple Example
@@ -3282,7 +3128,7 @@ class Origin @{
 class A : public Origin @{
  public:
   void method1 (void);
-  virtual void method2 (int v);
+  void method2 (int v);
   A();
   int   a_value;
 @};
@@ -3313,51 +3159,273 @@ A::A(void)
    a_value = 1010;
   printf ("in A::A, a_value = %d \n",a_value);
 @}
+@end smallexample
 
+@smallexample @c ada
 -- Ada sources
-@b{package} @b{body} Simple_Cpp_Interface @b{is}
+package body Simple_Cpp_Interface is
 
-   @b{procedure} Ada_Method2 (This : @b{in} @b{out} A; V : Integer) @b{is}
-   @b{begin}
+   procedure Ada_Method2 (This : in out A; V : Integer) is
+   begin
       Method1 (This);
       This.A_Value := V;
-   @b{end} Ada_Method2;
+   end Ada_Method2;
 
-@b{end} Simple_Cpp_Interface;
+end Simple_Cpp_Interface;
 
-@b{package} Simple_Cpp_Interface @b{is}
-   @b{type} A @b{is} @b{limited}
-      @b{record}
+with System;
+package Simple_Cpp_Interface is
+   type A is limited
+      record
+         Vptr    : System.Address;
          O_Value : Integer;
          A_Value : Integer;
-      @b{end} @b{record};
-   @b{pragma} Convention (C, A);
+      end record;
+   pragma Convention (C, A);
 
-   @b{procedure} Method1 (This : @b{in} @b{out} A);
-   @b{pragma} Import (C, Method1);
+   procedure Method1 (This : in out A);
+   pragma Import (C, Method1);
 
-   @b{procedure} Ada_Method2 (This : @b{in} @b{out} A; V : Integer);
-   @b{pragma} Export (C, Ada_Method2);
+   procedure Ada_Method2 (This : in out A; V : Integer);
+   pragma Export (C, Ada_Method2);
 
-@b{end} Simple_Cpp_Interface;
+end Simple_Cpp_Interface;
 @end smallexample
 
-@node Adapting the Run Time to a New C++ Compiler
-@subsection Adapting the Run Time to a New C++ Compiler
+@node Interfacing with C++ at the Class Level
+@subsection Interfacing with C++ at the Class Level
 @noindent
-GNAT offers the capability to derive Ada 95 tagged types directly from
-preexisting C++ classes and . See ``Interfacing with C++'' in the
-@cite{GNAT Reference Manual}. The mechanism used by GNAT for achieving
-such a goal
-has been made user configurable through a GNAT library unit
-@code{Interfaces.CPP}. The default version of this file is adapted to
-the GNU C++ compiler. Internal knowledge of the virtual
-table layout used by the new C++ compiler is needed to configure
-properly this unit. The Interface of this unit is known by the compiler
-and cannot be changed except for the value of the constants defining the
-characteristics of the virtual table: CPP_DT_Prologue_Size, CPP_DT_Entry_Size,
-CPP_TSD_Prologue_Size, CPP_TSD_Entry_Size. Read comments in the source
-of this unit for more details.
+In this section we demonstrate the GNAT features for interfacing with
+C++ by means of an example making use of Ada 2005 abstract interface
+types. This example consists of a classification of animals; classes
+have been used to model our main classification of animals, and
+interfaces provide support for the management of secondary
+classifications. We first demonstrate a case in which the types and
+constructors are defined on the C++ side and imported from the Ada
+side, and latter the reverse case.
+
+The root of our derivation will be the @code{Animal} class, with a
+single private attribute (the @code{Age} of the animal) and two public
+primitives to set and get the value of this attribute.
+
+@smallexample
+@b{class} Animal @{
+ @b{public}:
+   @b{virtual} void Set_Age (int New_Age);
+   @b{virtual} int Age ();
+ @b{private}:
+   int Age_Count;
+@};
+@end smallexample
+
+Abstract interface types are defined in C++ by means of classes with pure
+virtual functions and no data members. In our example we will use two
+interfaces that provide support for the common management of @code{Carnivore}
+and @code{Domestic} animals:
+
+@smallexample
+@b{class} Carnivore @{
+@b{public}:
+   @b{virtual} int Number_Of_Teeth () = 0;
+@};
+
+@b{class} Domestic @{
+@b{public}:
+   @b{virtual void} Set_Owner (char* Name) = 0;
+@};
+@end smallexample
+
+Using these declarations, we can now say that a @code{Dog} is an animal that is
+both Carnivore and Domestic, that is:
+
+@smallexample
+@b{class} Dog : Animal, Carnivore, Domestic @{
+ @b{public}:
+   @b{virtual} int  Number_Of_Teeth ();
+   @b{virtual} void Set_Owner (char* Name);
+
+   Dog(); // Constructor
+ @b{private}:
+   int  Tooth_Count;
+   char *Owner;
+@};
+@end smallexample
+
+In the following examples we will assume that the previous declarations are
+located in a file named @code{animals.h}. The following package demonstrates
+how to import these C++ declarations from the Ada side:
+
+@smallexample @c ada
+with Interfaces.C.Strings; use Interfaces.C.Strings;
+package Animals is
+  type Carnivore is interface;
+  pragma Convention (C_Plus_Plus, Carnivore);
+  function Number_Of_Teeth (X : Carnivore)
+     return Natural is abstract;
+
+  type Domestic is interface;
+  pragma Convention (C_Plus_Plus, Set_Owner);
+  procedure Set_Owner
+    (X    : in out Domestic;
+     Name : Chars_Ptr) is abstract;
+
+  type Animal is tagged record
+    Age : Natural := 0;
+  end record;
+  pragma Import (C_Plus_Plus, Animal);
+
+  procedure Set_Age (X : in out Animal; Age : Integer);
+  pragma Import (C_Plus_Plus, Set_Age);
+
+  function Age (X : Animal) return Integer;
+  pragma Import (C_Plus_Plus, Age);
+
+  type Dog is new Animal and Carnivore and Domestic with record
+    Tooth_Count : Natural;
+    Owner       : String (1 .. 30);
+  end record;
+  pragma Import (C_Plus_Plus, Dog);
+
+  function Number_Of_Teeth (A : Dog) return Integer;
+  pragma Import (C_Plus_Plus, Number_Of_Teeth);
+
+  procedure Set_Owner (A : in out Dog; Name : Chars_Ptr);
+  pragma Import (C_Plus_Plus, Set_Owner);
+
+  function New_Dog return Dog'Class;
+  pragma CPP_Constructor (New_Dog);
+  pragma Import (CPP, New_Dog, "_ZN3DogC2Ev");
+end Animals;
+@end smallexample
+
+Thanks to the compatibility between GNAT run-time structures and the C++ ABI,
+interfacing with these C++ classes is easy. The only requirement is that all
+the primitives and components must be declared exactly in the same order in
+the two languages.
+
+Regarding the abstract interfaces, we must indicate to the GNAT compiler by
+means of a @code{pragma Convention (C_Plus_Plus)}, the convention used to pass
+the arguments to the called primitives will be the same as for C++. For the
+imported classes we use @code{pragma Import} with convention @code{C_Plus_Plus}
+to indicate that they have been defined on the C++ side; this is required
+because the dispatch table associated with these tagged types will be built
+in the C++ side and therefore will not contain the predefined Ada primitives
+which Ada would otherwise expect.
+
+As the reader can see there is no need to indicate the C++ mangled names
+associated with each subprogram because it is assumed that all the calls to
+these primitives will be dispatching calls. The only exception is the
+constructor, which must be registered with the compiler by means of
+@code{pragma CPP_Constructor} and needs to provide its associated C++
+mangled name because the Ada compiler generates direct calls to it.
+
+With the above packages we can now declare objects of type Dog on the Ada side
+and dispatch calls to the corresponding subprograms on the C++ side. We can
+also extend the tagged type Dog with further fields and primitives, and
+override some of its C++ primitives on the Ada side. For example, here we have
+a type derivation defined on the Ada side that inherits all the dispatching
+primitives of the ancestor from the C++ side.
+
+@smallexample
+@b{with} Animals; @b{use} Animals;
+@b{package} Vaccinated_Animals @b{is}
+  @b{type} Vaccinated_Dog @b{is new} Dog @b{with null record};
+  @b{function} Vaccination_Expired (A : Vaccinated_Dog) @b{return} Boolean;
+@b{end} Vaccinated_Animals;
+@end smallexample
+
+It is important to note that, because of the ABI compatibility, the programmer
+does not need to add any further information to indicate either the object
+layout or the dispatch table entry associated with each dispatching operation.
+
+Now let us define all the types and constructors on the Ada side and export
+them to C++, using the same hierarchy of our previous example:
+
+@smallexample @c ada
+with Interfaces.C.Strings;
+use Interfaces.C.Strings;
+package Animals is
+  type Carnivore is interface;
+  pragma Convention (C_Plus_Plus, Carnivore);
+  function Number_Of_Teeth (X : Carnivore)
+     return Natural is abstract;
+
+  type Domestic is interface;
+  pragma Convention (C_Plus_Plus, Set_Owner);
+  procedure Set_Owner
+    (X    : in out Domestic;
+     Name : Chars_Ptr) is abstract;
+
+  type Animal is tagged record
+    Age : Natural := 0;
+  end record;
+  pragma Convention (C_Plus_Plus, Animal);
+
+  procedure Set_Age (X : in out Animal; Age : Integer);
+  pragma Export (C_Plus_Plus, Set_Age);
+
+  function Age (X : Animal) return Integer;
+  pragma Export (C_Plus_Plus, Age);
+
+  type Dog is new Animal and Carnivore and Domestic with record
+    Tooth_Count : Natural;
+    Owner       : String (1 .. 30);
+  end record;
+  pragma Convention (C_Plus_Plus, Dog);
+
+  function Number_Of_Teeth (A : Dog) return Integer;
+  pragma Export (C_Plus_Plus, Number_Of_Teeth);
+
+  procedure Set_Owner (A : in out Dog; Name : Chars_Ptr);
+  pragma Export (C_Plus_Plus, Set_Owner);
+
+  function New_Dog return Dog'Class;
+  pragma Export (C_Plus_Plus, New_Dog);
+end Animals;
+@end smallexample
+
+Compared with our previous example the only difference is the use of
+@code{pragma Export} to indicate to the GNAT compiler that the primitives will
+be available to C++. Thanks to the ABI compatibility, on the C++ side there is
+nothing else to be done; as explained above, the only requirement is that all
+the primitives and components are declared in exactly the same order.
+
+For completeness, let us see a brief C++ main program that uses the
+declarations available in @code{animals.h} (presented in our first example) to
+import and use the declarations from the Ada side, properly initializing and
+finalizing the Ada run-time system along the way:
+
+@smallexample
+@b{#include} "animals.h"
+@b{#include} <iostream>
+@b{using namespace} std;
+
+void Check_Carnivore (Carnivore *obj) @{@dots{}@}
+void Check_Domestic (Domestic *obj)   @{@dots{}@}
+void Check_Animal (Animal *obj)       @{@dots{}@}
+void Check_Dog (Dog *obj)             @{@dots{}@}
+
+@b{extern} "C" @{
+  void adainit (void);
+  void adafinal (void);
+  Dog* new_dog ();
+@}
+
+void test ()
+@{
+  Dog *obj = new_dog();  // Ada constructor
+  Check_Carnivore (obj); // Check secondary DT
+  Check_Domestic (obj);  // Check secondary DT
+  Check_Animal (obj);    // Check primary DT
+  Check_Dog (obj);       // Check primary DT
+@}
+
+int main ()
+@{
+  adainit ();  test();  adafinal ();
+  return 0;
+@}
+@end smallexample
 
 @node Comparison between GNAT and C/C++ Compilation Models
 @section Comparison between GNAT and C/C++ Compilation Models
@@ -3390,18 +3458,18 @@ simpler to use, but the C++ programmer has no control over elaboration.
 Where @code{gnatbind} might complain there was no valid order of
 elaboration, a C++ compiler would simply construct a program that
 malfunctioned at run time.
+@end ifclear
 
 @node Comparison between GNAT and Conventional Ada Library Models
 @section Comparison between GNAT and Conventional Ada Library Models
 
 @noindent
-This section is intended to be useful to Ada programmers who have
-previously used an Ada compiler implementing the traditional Ada library
-model, as described in the Ada 95 Language Reference Manual. If you
-have not used such a system, please go on to the next section.
+This section is intended for Ada programmers who have
+used an Ada compiler implementing the traditional Ada library
+model, as described in the Ada Reference Manual.
 
 @cindex GNAT library
-In GNAT, there is no @dfn{library} in the normal sense. Instead, the set of
+In GNAT, there is no ``library'' in the normal sense. Instead, the set of
 source files themselves acts as the library. Compiling Ada programs does
 not generate any centralized information, but rather an object file and
 a ALI file, which are of interest only to the binder and linker.
@@ -3485,13 +3553,12 @@ directory designated by the logical name @code{SYS$SCRATCH:}
 GNAT uses the current directory for temporary files.
 @end ifset
 
-
 @c *************************
 @node Compiling Using gcc
-@chapter Compiling Using @code{gcc}
+@chapter Compiling Using @command{gcc}
 
 @noindent
-This chapter discusses how to compile Ada programs using the @code{gcc}
+This chapter discusses how to compile Ada programs using the @command{gcc}
 command. It also describes the set of switches
 that can be used to control the behavior of the compiler.
 @menu
@@ -3507,7 +3574,7 @@ that can be used to control the behavior of the compiler.
 
 @noindent
 The first step in creating an executable program is to compile the units
-of the program using the @code{gcc} command. You must compile the
+of the program using the @command{gcc} command. You must compile the
 following files:
 
 @itemize @bullet
@@ -3545,7 +3612,7 @@ compiled.
 
 @cindex cannot generate code
 If you attempt to compile any of these files, you will get one of the
-following error messages (where fff is the name of the file you compiled):
+following error messages (where @var{fff} is the name of the file you compiled):
 
 @smallexample
 cannot generate code for file @var{fff} (package spec)
@@ -3578,7 +3645,7 @@ having an extension
 @file{.ads} for a spec or @file{.adb} for a body).
 @ifclear vms
 You specify the
-@option{-c} switch to tell @code{gcc} to compile, but not link, the file.
+@option{-c} switch to tell @command{gcc} to compile, but not link, the file.
 @end ifclear
 The result of a successful compilation is an object file, which has the
 same name as the source file but an extension of @file{.o} and an Ada
@@ -3589,17 +3656,17 @@ file in any directory using an absolute or relative path specification
 containing the directory information.
 
 @findex gnat1
-@code{gcc} is actually a driver program that looks at the extensions of
+@command{gcc} is actually a driver program that looks at the extensions of
 the file arguments and loads the appropriate compiler. For example, the
 GNU C compiler is @file{cc1}, and the Ada compiler is @file{gnat1}.
 These programs are in directories known to the driver program (in some
 configurations via environment variables you set), but need not be in
-your path. The @code{gcc} driver also calls the assembler and any other
+your path. The @command{gcc} driver also calls the assembler and any other
 utilities needed to complete the generation of the required object
 files.
 
-It is possible to supply several file names on the same @code{gcc}
-command. This causes @code{gcc} to call the appropriate compiler for
+It is possible to supply several file names on the same @command{gcc}
+command. This causes @command{gcc} to call the appropriate compiler for
 each file. For example, the following command lists three separate
 files to be compiled:
 
@@ -3619,25 +3686,30 @@ except for
 @end ifclear
 
 @node Switches for gcc
-@section Switches for @code{gcc}
+@section Switches for @command{gcc}
 
 @noindent
-The @code{gcc} command accepts switches that control the
+The @command{gcc} command accepts switches that control the
 compilation process. These switches are fully described in this section.
 First we briefly list all the switches, in alphabetical order, then we
 describe the switches in more detail in functionally grouped sections.
 
+More switches exist for GCC than those documented here, especially
+for specific targets. However, their use is not recommended as
+they may change code generation in ways that are incompatible with
+the Ada run-time library, or can cause inconsistencies between
+compilation units.
+
 @menu
 * Output and Error Message Control::
 * Warning Message Control::
 * Debugging and Assertion Control::
-* Run-Time Checks::
-* Stack Overflow Checking::
 * Validity Checking::
 * Style Checking::
+* Run-Time Checks::
 * Using gcc for Syntax Checking::
 * Using gcc for Semantic Checking::
-* Compiling Ada 83 Programs::
+* Compiling Different Versions of Ada::
 * Character Set Control::
 * File Naming Control::
 * Subprogram Inlining Control::
@@ -3655,82 +3727,104 @@ describe the switches in more detail in functionally grouped sections.
 @table @option
 @c !sort!
 @ifclear vms
-@cindex @option{-b} (@code{gcc})
+@cindex @option{-b} (@command{gcc})
 @item -b @var{target}
 Compile your program to run on @var{target}, which is the name of a
 system configuration. You must have a GNAT cross-compiler built if
 @var{target} is not the same as your host system.
 
 @item -B@var{dir}
-@cindex @option{-B} (@code{gcc})
+@cindex @option{-B} (@command{gcc})
 Load compiler executables (for example, @code{gnat1}, the Ada compiler)
 from @var{dir} instead of the default location. Only use this switch
 when multiple versions of the GNAT compiler are available. See the
-@code{gcc} manual page for further details. You would normally use the
+@command{gcc} manual page for further details. You would normally use the
 @option{-b} or @option{-V} switch instead.
 
 @item -c
-@cindex @option{-c} (@code{gcc})
+@cindex @option{-c} (@command{gcc})
 Compile. Always use this switch when compiling Ada programs.
 
-Note: for some other languages when using @code{gcc}, notably in
+Note: for some other languages when using @command{gcc}, notably in
 the case of C and C++, it is possible to use
-use @code{gcc} without a @option{-c} switch to
+use @command{gcc} without a @option{-c} switch to
 compile and link in one step. In the case of GNAT, you
 cannot use this approach, because the binder must be run
-and @code{gcc} cannot be used to run the GNAT binder.
+and @command{gcc} cannot be used to run the GNAT binder.
 @end ifclear
 
 @item -fno-inline
-@cindex @option{-fno-inline} (@code{gcc})
+@cindex @option{-fno-inline} (@command{gcc})
 Suppresses all back-end inlining, even if other optimization or inlining
 switches are set.
 This includes suppression of inlining that results
 from the use of the pragma @code{Inline_Always}.
-See also @option{-gnatn} and @option{-gnatN}.
+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-strict-aliasing
-@cindex @option{-fno-strict-aliasing} (@code{gcc})
+@cindex @option{-fno-strict-aliasing} (@command{gcc})
 Causes the compiler to avoid assumptions regarding non-aliasing
-of objects of different types. See section
-@pxref{Optimization and Strict Aliasing} for details.
+of objects of different types. See
+@ref{Optimization and Strict Aliasing} for details.
 
 @item -fstack-check
-@cindex @option{-fstack-check} (@code{gcc})
+@cindex @option{-fstack-check} (@command{gcc})
 Activates stack checking.
-See @ref{Stack Overflow Checking} for details of the use of this option.
+See @ref{Stack Overflow Checking} for details.
+
+@item -fstack-usage
+@cindex @option{-fstack-usage} (@command{gcc})
+Makes the compiler output stack usage information for the program, on a
+per-function basis. See @ref{Static Stack Usage Analysis} for details.
+
+@item -fcallgraph-info[=su]
+@cindex @option{-fcallgraph-info} (@command{gcc})
+Makes the compiler output callgraph information for the program, on a
+per-file basis.  The information is generated in the VCG format.  It can
+be decorated with stack-usage per-node information.
 
 @item ^-g^/DEBUG^
-@cindex @option{^-g^/DEBUG^} (@code{gcc})
+@cindex @option{^-g^/DEBUG^} (@command{gcc})
 Generate debugging information. This information is stored in the object
 file and copied from there to the final executable file by the linker,
 where it can be read by the debugger. You must use the
 @option{^-g^/DEBUG^} switch if you plan on using the debugger.
 
 @item -gnat83
-@cindex @option{-gnat83} (@code{gcc})
+@cindex @option{-gnat83} (@command{gcc})
 Enforce Ada 83 restrictions.
 
+@item -gnat95
+@cindex @option{-gnat95} (@command{gcc})
+Enforce Ada 95 restrictions.
+
+@item -gnat05
+@cindex @option{-gnat05} (@command{gcc})
+Allow full Ada 2005 features.
+
 @item -gnata
-@cindex @option{-gnata} (@code{gcc})
+@cindex @option{-gnata} (@command{gcc})
 Assertions enabled. @code{Pragma Assert} and @code{pragma Debug} to be
-activated.
+activated. Note that these pragmas can also be controlled using the
+configuration pragmas @code{Assertion_Policy} and @code{Debug_Policy}.
 
 @item -gnatA
-@cindex @option{-gnatA} (@code{gcc})
-Avoid processing @file{gnat.adc}. If a gnat.adc file is present,
+@cindex @option{-gnatA} (@command{gcc})
+Avoid processing @file{gnat.adc}. If a @file{gnat.adc} file is present,
 it will be ignored.
 
 @item -gnatb
-@cindex @option{-gnatb} (@code{gcc})
+@cindex @option{-gnatb} (@command{gcc})
 Generate brief messages to @file{stderr} even if verbose mode set.
 
 @item -gnatc
-@cindex @option{-gnatc} (@code{gcc})
+@cindex @option{-gnatc} (@command{gcc})
 Check syntax and semantics only (no code generation attempted).
 
 @item -gnatd
-@cindex @option{-gnatd} (@code{gcc})
+@cindex @option{-gnatd} (@command{gcc})
 Specify debug options for the compiler. The string of characters after
 the @option{-gnatd} specify the specific debug options. The possible
 characters are 0-9, a-z, A-Z, optionally preceded by a dot. See
@@ -3740,112 +3834,126 @@ programmers, and these are documented at appropriate points in this
 users guide.
 
 @item -gnatD
-@cindex @option{-gnatD} (@code{gcc})
+@cindex @option{-gnatD} (@command{gcc})
 Create expanded source files for source level debugging. This switch
 also suppress generation of cross-reference information
 (see @option{-gnatx}).
 
 @item -gnatec=@var{path}
-@cindex @option{-gnatec} (@code{gcc})
+@cindex @option{-gnatec} (@command{gcc})
 Specify a configuration pragma file
 @ifclear vms
 (the equal sign is optional)
 @end ifclear
-(see @ref{The Configuration Pragmas Files}).
+(@pxref{The Configuration Pragmas Files}).
 
 @item ^-gnateD^/DATA_PREPROCESSING=^symbol[=value]
-@cindex @option{-gnateD} (@code{gcc})
+@cindex @option{-gnateD} (@command{gcc})
 Defines a symbol, associated with value, for preprocessing.
-(see @ref{Integrated Preprocessing})
+(@pxref{Integrated Preprocessing}).
 
 @item -gnatef
-@cindex @option{-gnatef} (@code{gcc})
+@cindex @option{-gnatef} (@command{gcc})
 Display full source path name in brief error messages.
 
 @item -gnatem=@var{path}
-@cindex @option{-gnatem} (@code{gcc})
+@cindex @option{-gnatem} (@command{gcc})
 Specify a mapping file
 @ifclear vms
 (the equal sign is optional)
 @end ifclear
-(see @ref{Units to Sources Mapping Files}).
+(@pxref{Units to Sources Mapping Files}).
 
 @item -gnatep=@var{file}
-@cindex @option{-gnatep} (@code{gcc})
+@cindex @option{-gnatep} (@command{gcc})
 Specify a preprocessing data file
 @ifclear vms
 (the equal sign is optional)
 @end ifclear
-(see @ref{Integrated Preprocessing}).
+(@pxref{Integrated Preprocessing}).
 
 @item -gnatE
-@cindex @option{-gnatE} (@code{gcc})
+@cindex @option{-gnatE} (@command{gcc})
 Full dynamic elaboration checks.
 
 @item -gnatf
-@cindex @option{-gnatf} (@code{gcc})
+@cindex @option{-gnatf} (@command{gcc})
 Full errors. Multiple errors per line, all undefined references, do not
 attempt to suppress cascaded errors.
 
 @item -gnatF
-@cindex @option{-gnatF} (@code{gcc})
+@cindex @option{-gnatF} (@command{gcc})
 Externals names are folded to all uppercase.
 
-@item -gnatg
-@cindex @option{-gnatg} (@code{gcc})
+@item ^-gnatg^/GNAT_INTERNAL^
+@cindex @option{^-gnatg^/GNAT_INTERNAL^} (@command{gcc})
 Internal GNAT implementation mode. This should not be used for
 applications programs, it is intended only for use by the compiler
 and its run-time library. For documentation, see the GNAT sources.
-Note that @option{-gnatg} implies @option{-gnatwu} so that warnings
-are generated on unreferenced entities, and all warnings are treated
-as errors.
+Note that @option{^-gnatg^/GNAT_INTERNAL^} implies
+@option{^-gnatwae^/WARNINGS=ALL,ERRORS^} and
+@option{^-gnatyg^/STYLE_CHECKS=GNAT^}
+so that all standard warnings and all standard style options are turned on.
+All warnings and style error messages are treated as errors.
 
 @item -gnatG
-@cindex @option{-gnatG} (@code{gcc})
+@cindex @option{-gnatG} (@command{gcc})
 List generated expanded code in source form.
 
 @item ^-gnath^/HELP^
-@cindex @option{^-gnath^/HELP^} (@code{gcc})
+@cindex @option{^-gnath^/HELP^} (@command{gcc})
 Output usage information. The output is written to @file{stdout}.
 
 @item ^-gnati^/IDENTIFIER_CHARACTER_SET=^@var{c}
-@cindex @option{^-gnati^/IDENTIFIER_CHARACTER_SET^} (@code{gcc})
+@cindex @option{^-gnati^/IDENTIFIER_CHARACTER_SET^} (@command{gcc})
 Identifier character set
 @ifclear vms
 (@var{c}=1/2/3/4/8/9/p/f/n/w).
 @end ifclear
-@ifset vms
 For details of the possible selections for @var{c},
-see @xref{Character Set Control}.
-@end ifset
+see @ref{Character Set Control}.
+
+@item ^-gnatI^/IGNORE_REP_CLAUSES^
+@cindex @option{^-gnatI^IGNORE_REP_CLAUSES^} (@command{gcc})
+Ignore representation clauses. When this switch is used, all
+representation clauses are treated as comments. This is useful
+when initially porting code where you want to ignore rep clause
+problems, and also for compiling foreign code (particularly
+for use with ASIS).
+
+@item -gnatjnn
+@cindex @option{-gnatjnn} (@command{gcc})
+Reformat error messages to fit on nn character lines
 
 @item -gnatk=@var{n}
-@cindex @option{-gnatk} (@code{gcc})
+@cindex @option{-gnatk} (@command{gcc})
 Limit file names to @var{n} (1-999) characters ^(@code{k} = krunch)^^.
 
 @item -gnatl
-@cindex @option{-gnatl} (@code{gcc})
+@cindex @option{-gnatl} (@command{gcc})
 Output full source listing with embedded error messages.
 
 @item -gnatL
-@cindex @option{-gnatL} (@code{gcc})
-Use the longjmp/setjmp method for exception handling
+@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} (@code{gcc})
+@cindex @option{-gnatm} (@command{gcc})
 Limit number of detected error or warning messages to @var{n}
 where @var{n} is in the range 1..999_999. The default setting if
 no switch is given is 9999. Compilation is terminated if this
-limit is exceeded.
+limit is exceeded. The equal sign here is optional.
 
 @item -gnatn
-@cindex @option{-gnatn} (@code{gcc})
+@cindex @option{-gnatn} (@command{gcc})
 Activate inlining for subprograms for which
 pragma @code{inline} is specified. This inlining is performed
 by the GCC back-end.
 
 @item -gnatN
-@cindex @option{-gnatN} (@code{gcc})
+@cindex @option{-gnatN} (@command{gcc})
 Activate front end inlining for subprograms for which
 pragma @code{Inline} is specified. This inlining is performed
 by the front end and will be visible in the
@@ -3860,76 +3968,76 @@ to specify both options. There are a few cases that the back-end inlining
 catches that cannot be dealt with in the front-end.
 
 @item -gnato
-@cindex @option{-gnato} (@code{gcc})
+@cindex @option{-gnato} (@command{gcc})
 Enable numeric overflow checking (which is not normally enabled by
 default). Not that division by zero is a separate check that is not
 controlled by this switch (division by zero checking is on by default).
 
 @item -gnatp
-@cindex @option{-gnatp} (@code{gcc})
+@cindex @option{-gnatp} (@command{gcc})
 Suppress all checks.
 
 @item -gnatP
-@cindex @option{-gnatP} (@code{gcc})
+@cindex @option{-gnatP} (@command{gcc})
 Enable polling. This is required on some systems (notably Windows NT) to
 obtain asynchronous abort and asynchronous transfer of control capability.
 See the description of pragma Polling in the GNAT Reference Manual for
 full details.
 
 @item -gnatq
-@cindex @option{-gnatq} (@code{gcc})
+@cindex @option{-gnatq} (@command{gcc})
 Don't quit; try semantics, even if parse errors.
 
 @item -gnatQ
-@cindex @option{-gnatQ} (@code{gcc})
+@cindex @option{-gnatQ} (@command{gcc})
 Don't quit; generate @file{ALI} and tree files even if illegalities.
 
 @item ^-gnatR[0/1/2/3[s]]^/REPRESENTATION_INFO^
-@cindex @option{-gnatR} (@code{gcc})
+@cindex @option{-gnatR} (@command{gcc})
 Output representation information for declared types and objects.
 
 @item -gnats
-@cindex @option{-gnats} (@code{gcc})
+@cindex @option{-gnats} (@command{gcc})
 Syntax check only.
 
 @item -gnatS
-@cindex @option{-gnatS} (@code{gcc})
+@cindex @option{-gnatS} (@command{gcc})
 Print package Standard.
 
 @item -gnatt
-@cindex @option{-gnatt} (@code{gcc})
+@cindex @option{-gnatt} (@command{gcc})
 Generate tree output file.
 
 @item ^-gnatT^/TABLE_MULTIPLIER=^@var{nnn}
-@cindex @option{^-gnatT^/TABLE_MULTIPLIER^} (@code{gcc})
+@cindex @option{^-gnatT^/TABLE_MULTIPLIER^} (@command{gcc})
 All compiler tables start at @var{nnn} times usual starting size.
 
 @item -gnatu
-@cindex @option{-gnatu} (@code{gcc})
+@cindex @option{-gnatu} (@command{gcc})
 List units for this compilation.
 
 @item -gnatU
-@cindex @option{-gnatU} (@code{gcc})
+@cindex @option{-gnatU} (@command{gcc})
 Tag all error messages with the unique string ``error:''
 
 @item -gnatv
-@cindex @option{-gnatv} (@code{gcc})
+@cindex @option{-gnatv} (@command{gcc})
 Verbose mode. Full error output with source lines to @file{stdout}.
 
 @item -gnatV
-@cindex @option{-gnatV} (@code{gcc})
+@cindex @option{-gnatV} (@command{gcc})
 Control level of validity checking. See separate section describing
 this feature.
 
-@item ^-gnatw@var{xxx}^/WARNINGS=(@var{option}[,...])^
-@cindex @option{^-gnatw^/WARNINGS^} (@code{gcc})
+@item ^-gnatw@var{xxx}^/WARNINGS=(@var{option}[,@dots{}])^
+@cindex @option{^-gnatw^/WARNINGS^} (@command{gcc})
 Warning mode where
 ^@var{xxx} is a string of option letters that^the list of options^ denotes
 the exact warnings that
-are enabled or disabled. (see @ref{Warning Message Control})
+are enabled or disabled (@pxref{Warning Message Control}).
 
 @item ^-gnatW^/WIDE_CHARACTER_ENCODING=^@var{e}
-@cindex @option{^-gnatW^/WIDE_CHARACTER_ENCODING^} (@code{gcc})
+@cindex @option{^-gnatW^/WIDE_CHARACTER_ENCODING^} (@command{gcc})
 Wide character encoding method
 @ifclear vms
 (@var{e}=n/h/u/s/e/8).
@@ -3939,15 +4047,15 @@ Wide character encoding method
 @end ifset
 
 @item -gnatx
-@cindex @option{-gnatx} (@code{gcc})
+@cindex @option{-gnatx} (@command{gcc})
 Suppress generation of cross-reference information.
 
-@item ^-gnaty^/STYLE_CHECKS=(option,option..)^
-@cindex @option{^-gnaty^/STYLE_CHECKS^} (@code{gcc})
-Enable built-in style checks. (see @ref{Style Checking})
+@item ^-gnaty^/STYLE_CHECKS=(option,option@dots{})^
+@cindex @option{^-gnaty^/STYLE_CHECKS^} (@command{gcc})
+Enable built-in style checks (@pxref{Style Checking}).
 
 @item ^-gnatz^/DISTRIBUTION_STUBS=^@var{m}
-@cindex @option{^-gnatz^/DISTRIBUTION_STUBS^} (@code{gcc})
+@cindex @option{^-gnatz^/DISTRIBUTION_STUBS^} (@command{gcc})
 Distribution stub generation and compilation
 @ifclear vms
 (@var{m}=r/c for receiver/caller stubs).
@@ -3957,18 +4065,15 @@ Distribution stub generation and compilation
 to be generated and compiled).
 @end ifset
 
-@item -gnatZ
-Use the zero cost method for exception handling
-
 @item ^-I^/SEARCH=^@var{dir}
-@cindex @option{^-I^/SEARCH^} (@code{gcc})
+@cindex @option{^-I^/SEARCH^} (@command{gcc})
 @cindex RTL
 Direct GNAT to search the @var{dir} directory for source files needed by
 the current compilation
 (@pxref{Search Paths and the Run-Time Library (RTL)}).
 
 @item ^-I-^/NOCURRENT_DIRECTORY^
-@cindex @option{^-I-^/NOCURRENT_DIRECTORY^} (@code{gcc})
+@cindex @option{^-I-^/NOCURRENT_DIRECTORY^} (@command{gcc})
 @cindex RTL
 Except for the source file named in the command line, do not look for source
 files in the directory containing the source file named in the command line
@@ -3986,8 +4091,8 @@ This may result in less efficient code, but is sometimes necessary
 in order to compile large and/or nested @code{case} statements.
 
 @item -o @var{file}
-@cindex @option{-o} (@code{gcc})
-This switch is used in @code{gcc} to redirect the generated object file
+@cindex @option{-o} (@command{gcc})
+This switch is used in @command{gcc} to redirect the generated object file
 and its associated ALI file. Beware of this switch with GNAT, because it may
 cause the object file and ALI file to have different names which in turn
 may confuse the binder and the linker.
@@ -4005,7 +4110,7 @@ Library (RTL) ALI files.
 
 @ifclear vms
 @item -O[@var{n}]
-@cindex @option{-O} (@code{gcc})
+@cindex @option{-O} (@command{gcc})
 @var{n} controls the optimization level.
 
 @table @asis
@@ -4014,27 +4119,33 @@ No optimization, the default setting if no @option{-O} appears
 
 @item n = 1
 Normal optimization, the default if you specify @option{-O} without
-an operand.
+an operand. A good compromise between code quality and compilation
+time.
 
 @item n = 2
-Extensive optimization
+Extensive optimization, may improve execution time, possibly at the cost of
+substantially increased compilation time.
 
 @item n = 3
-Extensive optimization with automatic inlining of subprograms not
-specified by pragma @code{Inline}. This applies only to
-inlining within a unit. For details on control of inlining
-see @xref{Subprogram Inlining Control}.
+Same as @option{-O2}, and also includes inline expansion for small subprograms
+in the same unit.
+
+@item n = s
+Optimize space usage
 @end table
+
+@noindent
+See also @ref{Optimization Levels}.
 @end ifclear
 
 @ifset vms
 @item  /NOOPTIMIZE
 @cindex @option{/NOOPTIMIZE} (@code{GNAT COMPILE})
 Equivalent to @option{/OPTIMIZE=NONE}.
-This is the default behavior in the absence of an @option{/OPTMIZE}
+This is the default behavior in the absence of an @option{/OPTIMIZE}
 qualifier.
 
-@item /OPTIMIZE[=(keyword[,...])]
+@item /OPTIMIZE[=(keyword[,@dots{}])]
 @cindex @option{/OPTIMIZE} (@code{GNAT COMPILE})
 Selects the level of optimization for your program. The supported
 keywords are as follows:
@@ -4042,7 +4153,7 @@ keywords are as follows:
 @item   ALL
 Perform most optimizations, including those that
 are expensive.
-This is the default if the @option{/OPTMIZE} qualifier is supplied
+This is the default if the @option{/OPTIMIZE} qualifier is supplied
 without keyword options.
 
 @item   NONE
@@ -4054,54 +4165,73 @@ Perform some optimizations, but omit ones that are costly.
 @item   DEVELOPMENT
 Same as @code{SOME}.
 
-@item   INLINING
-Full optimization, and also attempt automatic inlining of small
-subprograms within a unit even when pragma @code{Inline}
-is not specified (@pxref{Inlining of Subprograms}).
+@item INLINING
+Full optimization as in @option{/OPTIMIZE=ALL}, and also attempts
+automatic inlining of small subprograms within a unit
 
 @item   UNROLL_LOOPS
 Try to unroll loops. This keyword may be specified together with
 any keyword above other than @code{NONE}. Loop unrolling
 usually, but not always, improves the performance of programs.
+
+@item SPACE
+Optimize space usage
 @end table
+
+@noindent
+See also @ref{Optimization Levels}.
 @end ifset
 
 @ifclear vms
 @item -pass-exit-codes
-@cindex @option{-pass-exit-codes} (@code{gcc})
+@cindex @option{-pass-exit-codes} (@command{gcc})
 Catch exit codes from the compiler and use the most meaningful as
 exit status.
 @end ifclear
 
 @item --RTS=@var{rts-path}
-@cindex @option{--RTS} (@code{gcc})
+@cindex @option{--RTS} (@command{gcc})
 Specifies the default location of the runtime library. Same meaning as the
-equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}).
+equivalent @command{gnatmake} flag (@pxref{Switches for gnatmake}).
 
 @item ^-S^/ASM^
-@cindex @option{^-S^/ASM^} (@code{gcc})
+@cindex @option{^-S^/ASM^} (@command{gcc})
 ^Used in place of @option{-c} to^Used to^
 cause the assembler source file to be
 generated, using @file{^.s^.S^} as the extension,
 instead of the object file.
 This may be useful if you need to examine the generated assembly code.
 
+@item ^-fverbose-asm^/VERBOSE_ASM^
+@cindex @option{^-fverbose-asm^/VERBOSE_ASM^} (@command{gcc})
+^Used in conjunction with @option{-S}^Used in place of @option{/ASM}^
+to cause the generated assembly code file to be annotated with variable
+names, making it significantly easier to follow.
+
 @item ^-v^/VERBOSE^
-@cindex @option{^-v^/VERBOSE^} (@code{gcc})
-Show commands generated by the @code{gcc} driver. Normally used only for
+@cindex @option{^-v^/VERBOSE^} (@command{gcc})
+Show commands generated by the @command{gcc} driver. Normally used only for
 debugging purposes or if you need to be sure what version of the
 compiler you are executing.
 
 @ifclear vms
 @item -V @var{ver}
-@cindex @option{-V} (@code{gcc})
-Execute @var{ver} version of the compiler. This is the @code{gcc}
+@cindex @option{-V} (@command{gcc})
+Execute @var{ver} version of the compiler. This is the @command{gcc}
 version, not the GNAT version.
 @end ifclear
 
+@item ^-w^/NO_BACK_END_WARNINGS^
+@cindex @option{-w} (@command{gcc})
+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.
+
 @end table
 
 @ifclear vms
+@c Combining qualifiers does not work on VMS
 You may combine a sequence of GNAT switches into a single switch. For
 example, the combined switch
 
@@ -4118,9 +4248,6 @@ is equivalent to specifying the following sequence of switches:
 @end smallexample
 @end ifclear
 
-
-@c NEED TO CHECK THIS FOR VMS
-
 @noindent
 The following restrictions apply to the combination of switches
 in this manner:
@@ -4162,7 +4289,6 @@ as validity checking options (see description of @option{-gnatV}).
 @end ifclear
 @end itemize
 
-
 @node Output and Error Message Control
 @subsection Output and Error Message Control
 @findex stderr
@@ -4180,15 +4306,17 @@ e.adb:4:20: ";" should be "is"
 @noindent
 The first integer after the file name is the line number in the file,
 and the second integer is the column number within the line.
-@code{glide} can parse the error messages
+@ifclear vms
+@code{GPS} can parse the error messages
 and point to the referenced character.
+@end ifclear
 The following switches provide control over the error message
 format:
 
 @table @option
 @c !sort!
 @item -gnatv
-@cindex @option{-gnatv} (@code{gcc})
+@cindex @option{-gnatv} (@command{gcc})
 @findex stdout
 @ifclear vms
 The v stands for verbose.
@@ -4215,29 +4343,52 @@ prefix can be used to search for error messages. When this switch is
 used the only source lines output are those with errors.
 
 @item -gnatl
-@cindex @option{-gnatl} (@code{gcc})
+@cindex @option{-gnatl} (@command{gcc})
 @ifclear vms
 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
 
@@ -4248,15 +4399,25 @@ standard output is redirected, a brief summary is written to
 @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 @option{-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} (@code{gcc})
+@cindex @option{-gnatU} (@command{gcc})
 This switch forces all error messages to be preceded by the unique
 string ``error:''. This means that error messages take a few more
 characters in space, but allows easy searching for and identification
 of error messages.
 
 @item -gnatb
-@cindex @option{-gnatb} (@code{gcc})
+@cindex @option{-gnatb} (@command{gcc})
 @ifclear vms
 The @code{b} stands for brief.
 @end ifclear
@@ -4266,8 +4427,8 @@ file) as well as the verbose
 format message or full listing (which as usual is written to
 @file{stdout} (the standard output file).
 
-@item -gnatm^^=^@var{n}
-@cindex @option{-gnatm} (@code{gcc})
+@item -gnatm=@var{n}
+@cindex @option{-gnatm} (@command{gcc})
 @ifclear vms
 The @code{m} stands for maximum.
 @end ifclear
@@ -4282,8 +4443,12 @@ fatal error: maximum errors reached
 compilation abandoned
 @end smallexample
 
+@noindent
+Note that the equal sign is optional, so the switches
+@option{-gnatm2} and @option{-gnatm=2} are equivalent.
+
 @item -gnatf
-@cindex @option{-gnatf} (@code{gcc})
+@cindex @option{-gnatf} (@command{gcc})
 @cindex Error messages, suppressing
 @ifclear vms
 The @code{f} stands for full.
@@ -4326,9 +4491,21 @@ List possible interpretations for ambiguous calls
 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} (@code{gcc})
+@cindex @option{-gnatq} (@command{gcc})
 @ifclear vms
 The @code{q} stands for quit (really ``don't quit'').
 @end ifclear
@@ -4342,7 +4519,7 @@ the other hand, the semantic analyzer is more likely to encounter some
 internal fatal error when given a syntactically invalid tree.
 
 @item -gnatQ
-@cindex @option{-gnatQ} (@code{gcc})
+@cindex @option{-gnatQ} (@command{gcc})
 In normal operation mode, the @file{ALI} file is not generated if any
 illegalities are detected in the program. The use of @option{-gnatQ} forces
 generation of the @file{ALI} file. This file is marked as being in
@@ -4362,7 +4539,7 @@ causes the tree to be badly malformed, then ASIS may crash during the
 analysis.
 
 When @option{-gnatQ} is used and the generated @file{ALI} file is marked as
-being in error, @code{gnatmake} will attempt to recompile the source when it
+being in error, @command{gnatmake} will attempt to recompile the source when it
 finds such an @file{ALI} file, including with switch @option{-gnatc}.
 
 Note that @option{-gnatQ} has no effect if @option{-gnats} is specified,
@@ -4370,13 +4547,12 @@ since ALI files are never generated if @option{-gnats} is set.
 
 @end table
 
-
 @node Warning Message Control
 @subsection Warning Message Control
 @cindex Warning messages
 @noindent
 In addition to error messages, which correspond to illegalities as defined
-in the Ada 95 Reference Manual, the compiler detects two kinds of warning
+in the Ada Reference Manual, the compiler detects two kinds of warning
 situations.
 
 First, the compiler considers some constructs suspicious and generates a
@@ -4413,12 +4589,22 @@ Out-of-range values being assigned
 Possible order of elaboration problems
 
 @item
+Assertions (pragma Assert) that are sure to fail
+
+@item
 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
+Direct_IO or Sequential_IO instantiated with a type that has access values
+
+@item
 Variables that are never assigned a value
 
 @item
@@ -4460,7 +4646,6 @@ Mismatching bounds in an aggregate
 @item
 Attempt to return local value by reference
 
-
 @item
 Premature instantiation of a generic body
 
@@ -4521,7 +4706,6 @@ Useless exception handlers
 @item
 Accidental hiding of name by child unit
 
-
 @item
 Access before elaboration detected at compile time
 
@@ -4531,33 +4715,74 @@ A range in a @code{for} loop that is known to be null or might be null
 @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 exercise 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!
 @item -gnatwa
 @emph{Activate all optional errors.}
-@cindex @option{-gnatwa} (@code{gcc})
+@cindex @option{-gnatwa} (@command{gcc})
 This switch activates most optional warning messages, see remaining list
 in this section for details on optional warning messages that can be
 individually controlled.  The warnings that are not turned on by this
 switch are
 @option{-gnatwd} (implicit dereferencing),
 @option{-gnatwh} (hiding),
-and @option{-gnatwl} (elaboration warnings).
+@option{-gnatwl} (elaboration warnings),
+@option{-gnatw.o} (warn on values set by out parameters ignored)
+and @option{-gnatwt} (tracking of deleted conditional code).
 All other optional warnings are turned on.
 
 @item -gnatwA
 @emph{Suppress all optional errors.}
-@cindex @option{-gnatwA} (@code{gcc})
+@cindex @option{-gnatwA} (@command{gcc})
 This switch suppresses all optional warning messages, see remaining list
 in this section for details on optional warning messages that can be
 individually controlled.
 
+@item -gnatw.a
+@emph{Activate warnings on failing assertions.}
+@cindex @option{-gnatw.a} (@command{gcc})
+@cindex Assert failures
+This switch activates warnings for assertions where the compiler can tell at
+compile time that the assertion will fail. Note that this warning is given
+even if assertions are disabled. The default is that such warnings are
+generated.
+
+@item -gnatw.A
+@emph{Suppress warnings on failing assertions.}
+@cindex @option{-gnatw.A} (@command{gcc})
+@cindex Assert failures
+This switch suppresses warnings for assertions where the compiler can tell at
+compile time that the assertion will fail.
+
+@item -gnatwb
+@emph{Activate warnings on bad fixed values.}
+@cindex @option{-gnatwb} (@command{gcc})
+@cindex Bad fixed values
+@cindex Fixed-point Small value
+@cindex Small value
+This switch activates warnings for static fixed-point expressions whose
+value is not an exact multiple of Small. Such values are implementation
+dependent, since an implementation is free to choose either of the multiples
+that surround the value. GNAT always chooses the closer one, but this is not
+required behavior, and it is better to specify a value that is an exact
+multiple, ensuring predictable execution. The default is that such warnings
+are not generated.
+
+@item -gnatwB
+@emph{Suppress warnings on bad fixed values.}
+@cindex @option{-gnatwB} (@command{gcc})
+This switch suppresses warnings for static fixed-point expressions whose
+value is not an exact multiple of Small.
+
 @item -gnatwc
 @emph{Activate warnings on conditionals.}
-@cindex @option{-gnatwc} (@code{gcc})
+@cindex @option{-gnatwc} (@command{gcc})
 @cindex Conditionals, constant
 This switch activates warnings for conditional expressions used in
 tests that are known to be True or False at compile time. The default
@@ -4566,18 +4791,49 @@ 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`` <=''.
+If the compiler can tell that only the equality condition is possible,
+then it will warn that the ``>'' or ``<'' part of the test
+is useless and that the operator could be replaced by ``=''.
+An example would be comparing a @code{Natural} variable <= 0.
+
+This warning option also generates warnings if
+one or both tests is optimized away in a membership test for integer
+values if the result can be determined at compile time. Range tests on
+enumeration types are not included, since it is common for such tests
+to include an end point.
+
 This warning can also be turned on using @option{-gnatwa}.
 
 @item -gnatwC
 @emph{Suppress warnings on conditionals.}
-@cindex @option{-gnatwC} (@code{gcc})
+@cindex @option{-gnatwC} (@command{gcc})
 This switch suppresses warnings for conditional expressions used in
 tests that are known to be True or False at compile time.
 
+@item -gnatw.c
+@emph{Activate warnings on missing component clauses.}
+@cindex @option{-gnatw.c} (@command{gcc})
+@cindex Component clause, missing
+This switch activates warnings for record components where a record
+representation clause is present and has component clauses for the
+majority, but not all, of the components. A warning is given for each
+component for which no component clause is present.
+
+This warning can also be turned on using @option{-gnatwa}.
+
+@item -gnatw.C
+@emph{Suppress warnings on missing component clauses.}
+@cindex @option{-gnatwC} (@command{gcc})
+This switch suppresses warnings for record components that are
+missing a component clause in the situation described above.
+
 @item -gnatwd
 @emph{Activate warnings on implicit dereferencing.}
-@cindex @option{-gnatwd} (@code{gcc})
+@cindex @option{-gnatwd} (@command{gcc})
 If this switch is set, then the use of a prefix of an access type
 in an indexed component, slice, or selected component without an
 explicit @code{.all} will generate a warning. With this warning
@@ -4590,7 +4846,7 @@ this warning option.
 
 @item -gnatwD
 @emph{Suppress warnings on implicit dereferencing.}
-@cindex @option{-gnatwD} (@code{gcc})
+@cindex @option{-gnatwD} (@command{gcc})
 @cindex Implicit dereferencing
 @cindex Dereferencing, implicit
 This switch suppresses warnings for implicit dereferences in
@@ -4598,7 +4854,7 @@ indexed components, slices, and selected components.
 
 @item -gnatwe
 @emph{Treat warnings as errors.}
-@cindex @option{-gnatwe} (@code{gcc})
+@cindex @option{-gnatwe} (@command{gcc})
 @cindex Warnings, treat as error
 This switch causes warning messages to be treated as errors.
 The warning string still appears, but the warning messages are counted
@@ -4606,15 +4862,16 @@ as errors, and prevent the generation of an object file.
 
 @item -gnatwf
 @emph{Activate warnings on unreferenced formals.}
-@cindex @option{-gnatwf} (@code{gcc})
+@cindex @option{-gnatwf} (@command{gcc})
 @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.}
-@cindex @option{-gnatwF} (@code{gcc})
+@cindex @option{-gnatwF} (@command{gcc})
 This switch suppresses warnings for unreferenced formal
 parameters. Note that the
 combination @option{-gnatwu} followed by @option{-gnatwF} has the
@@ -4623,7 +4880,7 @@ formals.
 
 @item -gnatwg
 @emph{Activate warnings on unrecognized pragmas.}
-@cindex @option{-gnatwg} (@code{gcc})
+@cindex @option{-gnatwg} (@command{gcc})
 @cindex Pragmas, unrecognized
 This switch causes a warning to be generated if an unrecognized
 pragma is encountered. Apart from issuing this warning, the
@@ -4634,12 +4891,12 @@ Manual requirement that such warnings appear).
 
 @item -gnatwG
 @emph{Suppress warnings on unrecognized pragmas.}
-@cindex @option{-gnatwG} (@code{gcc})
+@cindex @option{-gnatwG} (@command{gcc})
 This switch suppresses warnings for unrecognized pragmas.
 
 @item -gnatwh
 @emph{Activate warnings on hiding.}
-@cindex @option{-gnatwh} (@code{gcc})
+@cindex @option{-gnatwh} (@command{gcc})
 @cindex Hiding of Declarations
 This switch activates warnings on hiding declarations.
 A declaration is considered hiding
@@ -4650,12 +4907,12 @@ Note that @option{-gnatwa} does not affect the setting of this warning option.
 
 @item -gnatwH
 @emph{Suppress warnings on hiding.}
-@cindex @option{-gnatwH} (@code{gcc})
+@cindex @option{-gnatwH} (@command{gcc})
 This switch suppresses warnings on hiding declarations.
 
 @item -gnatwi
 @emph{Activate warnings on implementation units.}
-@cindex @option{-gnatwi} (@code{gcc})
+@cindex @option{-gnatwi} (@command{gcc})
 This switch activates warnings for a @code{with} of an internal GNAT
 implementation unit, defined as any unit from the @code{Ada},
 @code{Interfaces}, @code{GNAT},
@@ -4669,13 +4926,13 @@ This warning can also be turned on using @option{-gnatwa}.
 
 @item -gnatwI
 @emph{Disable warnings on implementation units.}
-@cindex @option{-gnatwI} (@code{gcc})
+@cindex @option{-gnatwI} (@command{gcc})
 This switch disables warnings for a @code{with} of an internal GNAT
 implementation unit.
 
 @item -gnatwj
 @emph{Activate warnings on obsolescent features (Annex J).}
-@cindex @option{-gnatwj} (@code{gcc})
+@cindex @option{-gnatwj} (@command{gcc})
 @cindex Features, obsolescent
 @cindex Obsolescent features
 If this warning option is activated, then warnings are generated for
@@ -4685,32 +4942,46 @@ case of Annex J, not all features are flagged. In particular use
 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
+have been superseded (typically by features in the new Ada standard).
+For example, @code{pragma Ravenscar} will be flagged since its
+function is replaced by @code{pragma Profile(Ravenscar)}.
+
+Note that this warning option functions differently from the
+restriction @code{No_Obsolescent_Features} in two respects.
+First, the restriction applies only to annex J features.
+Second, the restriction does flag uses of package @code{ASCII}.
 
 @item -gnatwJ
 @emph{Suppress warnings on obsolescent features (Annex J).}
-@cindex @option{-gnatwJ} (@code{gcc})
+@cindex @option{-gnatwJ} (@command{gcc})
 This switch disables warnings on use of obsolescent features.
 
 @item -gnatwk
 @emph{Activate warnings on variables that could be constants.}
-@cindex @option{-gnatwk} (@code{gcc})
+@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.}
-@cindex @option{-gnatwK} (@code{gcc})
+@cindex @option{-gnatwK} (@command{gcc})
 This switch disables warnings on variables that could be declared constants.
 
 @item -gnatwl
 @emph{Activate warnings for missing elaboration pragmas.}
-@cindex @option{-gnatwl} (@code{gcc})
+@cindex @option{-gnatwl} (@command{gcc})
 @cindex Elaboration, warnings
 This switch activates warnings on missing
-@code{pragma Elaborate_All} statements.
+@code{Elaborate_All} and @code{Elaborate} pragmas.
 See the section in this guide on elaboration checking for details on
-when such pragma should be used. Warnings are also generated if you
+when such pragmas should be used. 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.
@@ -4718,30 +4989,31 @@ This warning is not automatically turned on by the use of @option{-gnatwa}.
 
 @item -gnatwL
 @emph{Suppress warnings for missing elaboration pragmas.}
-@cindex @option{-gnatwL} (@code{gcc})
-This switch suppresses warnings on missing pragma Elaborate_All statements.
+@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
-when such pragma should be used.
+when such pragmas should be used.
 
 @item -gnatwm
 @emph{Activate warnings on modified but unreferenced variables.}
-@cindex @option{-gnatwm} (@code{gcc})
+@cindex @option{-gnatwm} (@command{gcc})
 This switch activates warnings for variables that are assigned (using
 an initialization value or with one or more assignment statements) but
 whose value is never read. The warning is suppressed for volatile
 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.}
-@cindex @option{-gnatwM} (@code{gcc})
+@cindex @option{-gnatwM} (@command{gcc})
 This switch disables warnings for variables that are assigned or
 initialized, but never read.
 
 @item -gnatwn
 @emph{Set normal warnings mode.}
-@cindex @option{-gnatwn} (@code{gcc})
+@cindex @option{-gnatwn} (@command{gcc})
 This switch sets normal warning mode, in which enabled warnings are
 issued and treated as warnings rather than errors. This is the default
 mode. the switch @option{-gnatwn} can be used to cancel the effect of
@@ -4752,7 +5024,7 @@ use of @option{-gnatg}.
 
 @item -gnatwo
 @emph{Activate warnings on address clause overlays.}
-@cindex @option{-gnatwo} (@code{gcc})
+@cindex @option{-gnatwo} (@command{gcc})
 @cindex Address Clauses, warnings
 This switch activates warnings for possibly unintended initialization
 effects of defining address clauses that cause one variable to overlap
@@ -4761,34 +5033,77 @@ This warning can also be turned on using @option{-gnatwa}.
 
 @item -gnatwO
 @emph{Suppress warnings on address clause overlays.}
-@cindex @option{-gnatwO} (@code{gcc})
+@cindex @option{-gnatwO} (@command{gcc})
 This switch suppresses warnings on possibly unintended initialization
 effects of defining address clauses that cause one variable to overlap
 another.
 
+@item -gnatw.o
+@emph{Activate warnings on modified but unreferenced out parameters.}
+@cindex @option{-gnatw.o} (@command{gcc})
+This switch activates warnings for variables that are modified by using
+them as actuals for a call to a procedure with an out mode formal, where
+the resulting assigned value is never read. It is applicable in the case
+where there is more than one out mode formal. If there is only one out
+mode formal, the warning is issued by default (controlled by -gnatwu).
+The warning is suppressed for volatile
+variables and also for variables that are renamings of other variables
+or for which an address clause is given.
+The default is that these warnings are not given. Note that this warning
+is not included in -gnatwa, it must be activated explicitly.
+
+@item -gnatw.O
+@emph{Disable warnings on modified but unreferenced out parameters.}
+@cindex @option{-gnatw.O} (@command{gcc})
+This switch suppresses warnings for variables that are modified by using
+them as actuals for a call to a procedure with an out mode formal, where
+the resulting assigned value is never read.
+
 @item -gnatwp
 @emph{Activate warnings on ineffective pragma Inlines.}
-@cindex @option{-gnatwp} (@code{gcc})
+@cindex @option{-gnatwp} (@command{gcc})
 @cindex Inlining, warnings
 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}.
+Warnings on ineffective inlining by the gcc back-end can be activated
+separately, using the gcc switch -Winline.
 
 @item -gnatwP
 @emph{Suppress warnings on ineffective pragma Inlines.}
-@cindex @option{-gnatwP} (@code{gcc})
+@cindex @option{-gnatwP} (@command{gcc})
 This switch suppresses warnings on ineffective pragma Inlines. If the
 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 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} (@code{gcc})
+@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
@@ -4808,29 +5123,45 @@ operand) which has no effect.
 Use of the operator abs on an operand that is known at compile time
 to be non-negative
 @item
-Use of an unnecessary extra level of parentheses (C-style) around conditions
-in @code{if} statements, @code{while} statements and @code{exit} statements.
-@item
 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} (@code{gcc})
+@cindex @option{-gnatwR} (@command{gcc})
 This switch suppresses warnings for redundant constructs.
 
 @item -gnatws
 @emph{Suppress all warnings.}
-@cindex @option{-gnatws} (@code{gcc})
+@cindex @option{-gnatws} (@command{gcc})
 This switch completely suppresses the
 output of all warning messages from the GNAT front end.
-Note that it does not suppress warnings from the @code{gcc} back end.
+Note that it does not suppress warnings from the @command{gcc} back end.
 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} (@code{gcc})
+@cindex @option{-gnatwu} (@command{gcc})
 This switch activates warnings to be generated for entities that
 are declared but not referenced, and for units that are @code{with}'ed
 and not
@@ -4847,33 +5178,68 @@ a warning is also generated, noting that the
 @code{with} can be moved to the body. The default is that
 such warnings are not generated.
 This switch also activates warnings on unreferenced formals
-(it is includes the effect of @option{-gnatwf}).
+(it includes the effect of @option{-gnatwf}).
 This warning can also be turned on using @option{-gnatwa}.
 
 @item -gnatwU
 @emph{Suppress warnings on unused entities.}
-@cindex @option{-gnatwU} (@code{gcc})
+@cindex @option{-gnatwU} (@command{gcc})
 This switch suppresses warnings for unused entities and packages.
 It also turns off warnings on unreferenced formals (and thus includes
 the effect of @option{-gnatwF}).
 
 @item -gnatwv
 @emph{Activate warnings on unassigned variables.}
-@cindex @option{-gnatwv} (@code{gcc})
+@cindex @option{-gnatwv} (@command{gcc})
 @cindex Unassigned variable warnings
 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.}
-@cindex @option{-gnatwV} (@code{gcc})
+@cindex @option{-gnatwV} (@command{gcc})
 This switch suppresses warnings for access to variables which
 may not be properly initialized.
+For variables of a composite type, the warning can also be suppressed in
+Ada 2005 by using a default initialization with a box. For example, if
+Table is an array of records whose components are only partially uninitialized,
+then the following code:
+
+@smallexample @c ada
+   Tab : Table := (others => <>);
+@end smallexample
+
+will suppress warnings on subsequent statements that access components
+of variable Tab.
+
+@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}.
+
+@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);
+      @dots{}
+@end smallexample
 
 @item -gnatwx
 @emph{Activate warnings on Export/Import pragmas.}
-@cindex @option{-gnatwx} (@code{gcc})
+@cindex @option{-gnatwx} (@command{gcc})
 @cindex Export/Import pragma warnings
 This switch activates warnings on Export/Import pragmas when
 the compiler detects a possible conflict between the Ada and
@@ -4882,27 +5248,63 @@ default parameters in a convention C procedure is dubious
 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.}
-@cindex @option{-gnatwX} (@code{gcc})
+@cindex @option{-gnatwX} (@command{gcc})
 This switch suppresses warnings on Export/Import pragmas.
 The sense of this is that you are telling the compiler that
 you know what you are doing in writing the pragma, and it
 should not complain at you.
 
+@item -gnatw.x
+@emph{Activate warnings for No_Exception_Propagation mode.}
+@cindex @option{-gnatwm} (@command{gcc})
+This switch activates warnings for exception usage when pragma Restrictions
+(No_Exception_Propagation) is in effect. Warnings are given for implicit or
+explicit exception raises which are not covered by a local handler, and for
+exception handlers which do not cover a local raise. The default is that these
+warnings are not given.
+
+@item -gnatw.X
+@emph{Disable warnings for No_Exception_Propagation mode.}
+This switch disables warnings for exception usage when pragma Restrictions
+(No_Exception_Propagation) is in effect.
+
+@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} (@code{gcc})
+@cindex @option{-gnatwz} (@command{gcc})
 @cindex Unchecked_Conversion warnings
 This switch activates warnings for unchecked conversions
 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.}
-@cindex @option{-gnatwZ} (@code{gcc})
+@cindex @option{-gnatwZ} (@command{gcc})
 This switch suppresses warnings for unchecked conversions
 where the types are known at compile time to have different
 sizes.
@@ -4913,15 +5315,17 @@ 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 tunrning on optimization mode. This causes the flow
+conjunction with turning on optimization mode. This causes the flow
 analysis circuits of the back end optimizer to output additional
 warnings about uninitialized variables.
 
 @item ^-w^/NO_BACK_END_WARNINGS^
 @cindex @option{-w}
-This switch suppresses warnings from the @option{^gcc^GCC^} back end. It may
-be used in conjunction with @option{-gnatws} to ensure that all warnings
-are suppressed during the entire compilation process.
+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.
+The use of this switch also sets the default front end warning mode to
+@option{-gnatws}, that is, front end warnings suppressed as well.
 
 @end table
 
@@ -4962,13 +5366,12 @@ When no switch @option{^-gnatw^/WARNINGS^} is used, this is equivalent to:
 
 @end table
 
-
 @node Debugging and Assertion Control
 @subsection Debugging and Assertion Control
 
 @table @option
 @item -gnata
-@cindex @option{-gnata} (@code{gcc})
+@cindex @option{-gnata} (@command{gcc})
 @findex Assert
 @findex Debug
 @cindex Assertions
@@ -5031,7 +5434,7 @@ file. Note that this doesn't include traceback information.
 @findex Validity Checking
 
 @noindent
-The Ada 95 Reference Manual has specific requirements for checking
+The Ada Reference Manual has specific requirements for checking
 for invalid values. In particular, RM 13.9.1 requires that the
 evaluation of invalid values (for example from unchecked conversions),
 not result in erroneous execution. In GNAT, the result of such an
@@ -5056,12 +5459,11 @@ indicate validity checks that are performed or not performed in addition
 to the default checks described above.
 @end ifset
 
-
 @table @option
 @c !sort!
 @item -gnatVa
 @emph{All validity checks.}
-@cindex @option{-gnatVa} (@code{gcc})
+@cindex @option{-gnatVa} (@command{gcc})
 All validity checks are turned on.
 @ifclear vms
 That is, @option{-gnatVa} is
@@ -5070,13 +5472,13 @@ equivalent to @option{gnatVcdfimorst}.
 
 @item -gnatVc
 @emph{Validity checks for copies.}
-@cindex @option{-gnatVc} (@code{gcc})
+@cindex @option{-gnatVc} (@command{gcc})
 The right hand side of assignments, and the initializing values of
 object declarations are validity checked.
 
 @item -gnatVd
 @emph{Default (RM) validity checks.}
-@cindex @option{-gnatVd} (@code{gcc})
+@cindex @option{-gnatVd} (@command{gcc})
 Some validity checks are done by default following normal Ada semantics
 (RM 13.9.1 (9-11)).
 A check is done in case statements that the expression is within the range
@@ -5091,14 +5493,26 @@ expressions have valid values. If you use this switch and invalid values
 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} (@code{gcc})
+@cindex @option{-gnatVf} (@command{gcc})
 In the absence of this switch, validity checking occurs only for discrete
 values. If @option{-gnatVf} is specified, then validity checking also applies
-for floating-point values, and NaN's and infinities are considered invalid,
+for floating-point values, and NaNs and infinities are considered invalid,
 as well as out of range values for constrained types. Note that this means
-that standard @code{IEEE} infinity mode is not allowed. The exact contexts
+that standard IEEE infinity mode is not allowed. The exact contexts
 in which floating-point values are checked depends on the setting of other
 options. For example,
 @option{^-gnatVif^VALIDITY_CHECKING=(IN_PARAMS,FLOATS)^} or
@@ -5108,13 +5522,13 @@ options. For example,
 
 @item -gnatVi
 @emph{Validity checks for @code{in} mode parameters}
-@cindex @option{-gnatVi} (@code{gcc})
+@cindex @option{-gnatVi} (@command{gcc})
 Arguments for parameters of mode @code{in} are validity checked in function
 and procedure calls at the point of call.
 
 @item -gnatVm
 @emph{Validity checks for @code{in out} mode parameters.}
-@cindex @option{-gnatVm} (@code{gcc})
+@cindex @option{-gnatVm} (@command{gcc})
 Arguments for parameters of mode @code{in out} are validity checked in
 procedure calls at the point of call. The @code{'m'} here stands for
 modify, since this concerns parameters that can be modified by the call.
@@ -5125,7 +5539,7 @@ will be subject to validity checking.
 
 @item -gnatVn
 @emph{No validity checks.}
-@cindex @option{-gnatVn} (@code{gcc})
+@cindex @option{-gnatVn} (@command{gcc})
 This switch turns off all validity checking, including the default checking
 for case statements and left hand side subscripts. Note that the use of
 the switch @option{-gnatp} suppresses all run-time checks, including
@@ -5134,16 +5548,18 @@ is used, it cancels any other @option{-gnatV} previously issued.
 
 @item -gnatVo
 @emph{Validity checks for operator and attribute operands.}
-@cindex @option{-gnatVo} (@code{gcc})
+@cindex @option{-gnatVo} (@command{gcc})
 Arguments for predefined operators and attributes are validity checked.
 This includes all operators in package @code{Standard},
 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.
+on individual component values for composite comparisons, and on the
+expressions in type conversions and qualified expressions. Checks are
+also made on explicit ranges using @samp{..} (e.g. slices, loops etc).
 
 @item -gnatVp
 @emph{Validity checks for parameters.}
-@cindex @option{-gnatVp} (@code{gcc})
+@cindex @option{-gnatVp} (@command{gcc})
 This controls the treatment of parameters within a subprogram (as opposed
 to @option{-gnatVi} and @option{-gnatVm} which control validity testing
 of parameters on a call. If either of these call options is used, then
@@ -5155,20 +5571,20 @@ will be checked (or rechecked) within the subprogram.
 
 @item -gnatVr
 @emph{Validity checks for function returns.}
-@cindex @option{-gnatVr} (@code{gcc})
+@cindex @option{-gnatVr} (@command{gcc})
 The expression in @code{return} statements in functions is validity
 checked.
 
 @item -gnatVs
 @emph{Validity checks for subscripts.}
-@cindex @option{-gnatVs} (@code{gcc})
+@cindex @option{-gnatVs} (@command{gcc})
 All subscripts expressions are checked for validity, whether they appear
 on the right side or left side (in default mode only left side subscripts
 are validity checked).
 
 @item -gnatVt
 @emph{Validity checks for tests.}
-@cindex @option{-gnatVt} (@code{gcc})
+@cindex @option{-gnatVt} (@command{gcc})
 Expressions used as conditions in @code{if}, @code{while} or @code{exit}
 statements are checked, as well as guard expressions in entry calls.
 
@@ -5220,14 +5636,13 @@ See also the pragma @code{Validity_Checks} which allows modification of
 the validity checking mode at the program source level, and also allows for
 temporary disabling of validity checks.
 
-
 @node Style Checking
 @subsection Style Checking
 @findex Style checking
 
 @noindent
-The @option{-gnaty^x^(option,option,...)^} switch
-@cindex @option{-gnaty} (@code{gcc})
+The @option{-gnaty^x^(option,option,@dots{})^} switch
+@cindex @option{-gnaty} (@command{gcc})
 causes the compiler to
 enforce specified style rules. A limited set of style rules has been used
 in writing the GNAT sources themselves. This switch allows user programs
@@ -5235,7 +5650,7 @@ to activate all or some of these checks. If the source program fails a
 specified style check, an appropriate warning message is given, preceded by
 the character sequence ``(style)''.
 @ifset vms
-@code{(option,option,...)} is a sequence of keywords
+@code{(option,option,@dots{})} is a sequence of keywords
 @end ifset
 @ifclear vms
 The string @var{x} is a sequence of letters or digits
@@ -5254,7 +5669,9 @@ indentation level required.
 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
-the alignment level.
+the alignment level, or they may be aligned the same way as the following
+non-blank line (this is useful when full line comments appear in the middle
+of a statement.
 
 @item ^a^ATTRIBUTE^
 @emph{Check attribute casing.}
@@ -5264,6 +5681,13 @@ 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,
+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
@@ -5302,7 +5726,7 @@ including @command{gnatprep} (where ``@code{--!}'' is used) and the SPARK
 annotation
 language (where ``@code{--#}'' is used). For the purposes of this rule, a
 special character is defined as being in one of the ASCII ranges
-@code{16#21#..16#2F#} or @code{16#3A#..16#3F#}.
+@code{16#21#@dots{}16#2F#} or @code{16#3A#@dots{}16#3F#}.
 Note that this usage is not permitted
 in GNAT implementation units (i.e. when @option{-gnatg} is used).
 
@@ -5312,7 +5736,7 @@ permitted. This allows the construction of box comments where lines of minus
 signs are used to form the top and bottom of the box.
 
 @item
-If a comment starts and ends with ``@code{--}'' is permitted as long as at
+A comment that starts and ends with ``@code{--}'' is permitted as long as at
 least one blank follows the initial ``@code{--}''. Together with the preceding
 rule, this allows the construction of box comments, as shown in the following
 example:
@@ -5324,6 +5748,13 @@ example:
 @end smallexample
 @end itemize
 
+@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
+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
@@ -5333,9 +5764,16 @@ optional labels on @code{end} statements ending subprograms and on
 @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 not 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.
+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
@@ -5352,6 +5790,13 @@ 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
+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
@@ -5372,7 +5817,8 @@ option are more liberal than those in the Ada Reference Manual. First
 in the case of record declarations, it is permissible to put the
 @code{record} keyword on the same line as the @code{type} keyword, and
 then the @code{end} in @code{end record} must line up under @code{type}.
-For example, either of the following two layouts is acceptable:
+This is also permitted when the type declaration is split on two lines.
+For example, any of the following three layouts is acceptable:
 
 @smallexample @c ada
 @cartouche
@@ -5386,6 +5832,13 @@ type q is
       a : integer;
       b : integer;
    end record;
+
+type q is
+   record
+      a : integer;
+      b : integer;
+end record;
+
 @end cartouche
 @end smallexample
 
@@ -5429,22 +5882,30 @@ Clear :
 @end cartouche
 @end smallexample
 
+@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.
+
 @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
 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 raw
+treatment of 80 character lines. Note that this count is of
 characters in the source text. This means that a tab character counts
-as one character in this count and a wide character sequence counts as
-several characters (however many are needed in the encoding).
+as one character in this count but a wide character sequence counts as
+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.
+given value. The maximum value that can be specified is 32767.
 
 @item ^n^STANDARD_CASING^
 @emph{Check casing of entities in Standard.}
@@ -5478,6 +5939,14 @@ 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
+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
@@ -5537,6 +6006,20 @@ A unary plus or minus may not be followed by a space.
 A vertical bar must be surrounded by spaces.
 @end itemize
 
+@item ^u^UNNECESSARY_BLANK_LINES^
+@emph{Check unnecessary blank lines.}
+Check for unnecessary blank lines. 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)
+around conditions in @code{if} statements, @code{while} statements and
+@code{exit} statements.
+
+@end table
+
 @noindent
 In the above rules, appearing in column one is always permitted, that is,
 counts as meeting either a requirement for a required preceding space,
@@ -5546,8 +6029,6 @@ Appearing at the end of a line is also always permitted, that is, counts
 as meeting either a requirement for a following space, or as meeting
 a requirement for no following space.
 
-@end table
-
 @noindent
 If any of these style rules is violated, a message is generated giving
 details on the violation. The initial characters of such messages are
@@ -5560,14 +6041,16 @@ The switch
 @ifclear vms
 @option{-gnaty} on its own (that is not
 followed by any letters or digits),
-is equivalent to @code{gnaty3abcefhiklmprst}, that is all checking
-options enabled with the exception of -gnatyo,
+is equivalent to @code{gnaty3aAbcefhiklmnprst}, that is all checking
+options enabled with the exception of @option{-gnatyo},
+@option{-gnatyd}, @option{-gnatyu}, and @option{-gnatyx}.
 @end ifclear
 @ifset vms
 /STYLE_CHECKS=ALL_BUILTIN enables all checking options with
-the exception of ORDERED_SUBPROGRAMS,
+the exception of ORDERED_SUBPROGRAMS, UNNECESSARY_BLANK_LINES,
+XTRA_PARENS, and DOS_LINE_ENDINGS. In addition
 @end ifset
-with an indentation level of 3. This is the standard
+an indentation level of 3 is set. This is similar to the standard
 checking option that is used for the GNAT sources.
 
 The switch
@@ -5585,20 +6068,22 @@ clears any previously set style checks.
 @cindex Access before elaboration
 @cindex Checks, division by zero
 @cindex Checks, access before elaboration
+@cindex Checks, stack overflow checking
 
 @noindent
 If you compile with the default options, GNAT will insert many run-time
 checks into the compiled code, including code that performs range
 checking against constraints, but not arithmetic overflow checking for
-integer operations (including division by zero) or checks for access
-before elaboration on subprogram calls. All other run-time checks, as
-required by the Ada 95 Reference Manual, are generated by default.
-The following @code{gcc} switches refine this default behavior:
+integer operations (including division by zero), checks for access
+before elaboration on subprogram calls, or stack overflow checking. All
+other run-time checks, as required by the Ada Reference Manual, are
+generated by default. The following @command{gcc} switches refine this
+default behavior:
 
 @table @option
 @c !sort!
 @item -gnatp
-@cindex @option{-gnatp} (@code{gcc})
+@cindex @option{-gnatp} (@command{gcc})
 @cindex Suppressing checks
 @cindex Checks, suppressing
 @findex Suppress
@@ -5610,7 +6095,7 @@ of the code at the expense of safety in the presence of invalid data or
 program bugs.
 
 @item -gnato
-@cindex @option{-gnato} (@code{gcc})
+@cindex @option{-gnato} (@command{gcc})
 @cindex Overflow checks
 @cindex Check, overflow
 Enables overflow checking for integer operations.
@@ -5627,7 +6112,7 @@ X2 : Integer range 1 .. 5 := 5;
 X3 : Integer := Integer'Last;
 X4 : Integer range 1 .. 5 := 5;
 F  : Float := 2.0E+20;
-...
+@dots{}
 X1 := X1 + 1;
 X2 := X2 + 1;
 X3 := Integer (F);
@@ -5690,17 +6175,24 @@ not performed in default mode. This means that out of the box, with the
 default settings, GNAT does not do all the checks expected from the
 language description in the Ada Reference Manual. If you want all constraint
 checks to be performed, as described in this Manual, then you must
-explicitly use the -gnato switch either on the @code{gnatmake} or
-@code{gcc} command.
+explicitly use the -gnato switch either on the @command{gnatmake} or
+@command{gcc} command.
 
 @item -gnatE
-@cindex @option{-gnatE} (@code{gcc})
+@cindex @option{-gnatE} (@command{gcc})
 @cindex Elaboration checks
 @cindex Check, elaboration
 Enables dynamic checks for access-before-elaboration
 on subprogram calls and generic instantiations.
 For full details of the effect and use of this switch,
 @xref{Compiling Using gcc}.
+
+@item -fstack-check
+@cindex @option{-fstack-check} (@command{gcc})
+@cindex Stack Overflow Checking
+@cindex Checks, stack overflow checking
+Activates stack overflow checking. For full details of the effect and use of
+this switch see @ref{Stack Overflow Checking}.
 @end table
 
 @findex Unsuppress
@@ -5710,68 +6202,11 @@ checks. You may modify them using either @code{Suppress} (to remove
 checks) or @code{Unsuppress} (to add back suppressed checks) pragmas in
 the program source.
 
-@node Stack Overflow Checking
-@subsection Stack Overflow Checking
-@cindex Stack Overflow Checking
-@cindex -fstack-check
-
-@noindent
-For most operating systems, @code{gcc} does not perform stack overflow
-checking by default. This means that if the main environment task or
-some other task exceeds the available stack space, then unpredictable
-behavior will occur.
-
-To activate stack checking, compile all units with the gcc option
-@option{-fstack-check}. For example:
-
-@smallexample
-gcc -c -fstack-check package1.adb
-@end smallexample
-
-@noindent
-Units compiled with this option will generate extra instructions to check
-that any use of the stack (for procedure calls or for declaring local
-variables in declare blocks) do not exceed the available stack space.
-If the space is exceeded, then a @code{Storage_Error} exception is raised.
-
-For declared tasks, the stack size is always controlled by the size
-given in an applicable @code{Storage_Size} pragma (or is set to
-the default size if no pragma is used.
-
-For the environment task, the stack size depends on
-system defaults and is unknown to the compiler. The stack
-may even dynamically grow on some systems, precluding the
-normal Ada semantics for stack overflow. In the worst case,
-unbounded stack usage, causes unbounded stack expansion
-resulting in the system running out of virtual memory.
-
-The stack checking may still work correctly if a fixed
-size stack is allocated, but this cannot be guaranteed.
-To ensure that a clean exception is signalled for stack
-overflow, set the environment variable
-@code{GNAT_STACK_LIMIT} to indicate the maximum
-stack area that can be used, as in:
-@cindex GNAT_STACK_LIMIT
-
-@smallexample
-SET GNAT_STACK_LIMIT 1600
-@end smallexample
-
-@noindent
-The limit is given in kilobytes, so the above declaration would
-set the stack limit of the environment task to 1.6 megabytes.
-Note that the only purpose of this usage is to limit the amount
-of stack used by the environment task. If it is necessary to
-increase the amount of stack for the environment task, then this
-is an operating systems issue, and must be addressed with the
-appropriate operating systems commands.
-
-
 @node Using gcc for Syntax Checking
-@subsection Using @code{gcc} for Syntax Checking
+@subsection Using @command{gcc} for Syntax Checking
 @table @option
 @item -gnats
-@cindex @option{-gnats} (@code{gcc})
+@cindex @option{-gnats} (@command{gcc})
 @ifclear vms
 
 @noindent
@@ -5822,12 +6257,11 @@ together. This is primarily used by the @code{gnatchop} utility
 (@pxref{Renaming Files Using gnatchop}).
 @end table
 
-
 @node Using gcc for Semantic Checking
-@subsection Using @code{gcc} for Semantic Checking
+@subsection Using @command{gcc} for Semantic Checking
 @table @option
 @item -gnatc
-@cindex @option{-gnatc} (@code{gcc})
+@cindex @option{-gnatc} (@command{gcc})
 
 @ifclear vms
 @noindent
@@ -5835,7 +6269,7 @@ The @code{c} stands for ``check''.
 @end ifclear
 Causes the compiler to operate in semantic check mode,
 with full checking for all illegalities specified in the
-Ada 95 Reference Manual, but without generation of any object code
+Ada Reference Manual, but without generation of any object code
 (no object file is generated).
 
 Because dependent files must be accessed, you must follow the GNAT
@@ -5858,56 +6292,102 @@ generated. An @file{ALI} file is generated for use in the context of
 cross-reference tools, but this file is marked as not being suitable
 for binding (since no object file is generated).
 The checking corresponds exactly to the notion of
-legality in the Ada 95 Reference Manual.
+legality in the Ada Reference Manual.
 
 Any unit can be compiled in semantics-checking-only mode, including
 units that would not normally be compiled (subunits,
 and specifications where a separate body is present).
 @end table
 
-@node Compiling Ada 83 Programs
-@subsection Compiling Ada 83 Programs
+@node Compiling Different Versions of Ada
+@subsection Compiling Different Versions of Ada
+
+@noindent
+The switches described in this section allow you to explicitly specify
+the version of the Ada language that your programs are written in.
+By default @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
+but you can also specify @value{NONDEFAULTLANGUAGEVERSION} or
+indicate Ada 83 compatibility mode.
+
 @table @option
-@cindex Ada 83 compatibility
-@item -gnat83
-@cindex @option{-gnat83} (@code{gcc})
+@cindex Compatibility with Ada 83
+
+@item -gnat83 (Ada 83 Compatibility Mode)
+@cindex @option{-gnat83} (@command{gcc})
 @cindex ACVC, Ada 83 tests
+@cindex Ada 83 mode
 
 @noindent
-Although GNAT is primarily an Ada 95 compiler, it accepts this switch to
-specify that an Ada 83 program is to be compiled in Ada 83 mode. If you specify
-this switch, GNAT rejects most Ada 95 extensions and applies Ada 83 semantics
-where this can be done easily.
+Although GNAT is primarily an Ada 95 / Ada 2005 compiler, this switch
+specifies that the program is to be compiled in Ada 83 mode. With
+@option{-gnat83}, GNAT rejects most post-Ada 83 extensions and applies Ada 83
+semantics where this can be done easily.
 It is not possible to guarantee this switch does a perfect
-job; for example, some subtle tests, such as are
+job; some subtle tests, such as are
 found in earlier ACVC tests (and that have been removed from the ACATS suite
 for Ada 95), might not compile correctly.
 Nevertheless, this switch may be useful in some circumstances, for example
-where, due to contractual reasons, legacy code needs to be maintained
+where, due to contractual reasons, existing code needs to be maintained
 using only Ada 83 features.
 
 With few exceptions (most notably the need to use @code{<>} on
 @cindex Generic formal parameters
-unconstrained generic formal parameters, the use of the new Ada 95
+unconstrained generic formal parameters, the use of the new Ada 95 / Ada 2005
 reserved words, and the use of packages
-with optional bodies), it is not necessary to use the
+with optional bodies), it is not necessary to specify the
 @option{-gnat83} switch when compiling Ada 83 programs, because, with rare
-exceptions, Ada 95 is upwardly compatible with Ada 83. This
-means that a correct Ada 83 program is usually also a correct Ada 95
-program.
+exceptions, Ada 95 and Ada 2005 are upwardly compatible with Ada 83. Thus
+a correct Ada 83 program is usually also a correct program
+in these later versions of the language standard.
 For further information, please refer to @ref{Compatibility and Porting Guide}.
 
+@item -gnat95 (Ada 95 mode)
+@cindex @option{-gnat95} (@command{gcc})
+@cindex Ada 95 mode
+
+@noindent
+This switch directs the compiler to implement the Ada 95 version of the
+language.
+Since Ada 95 is almost completely upwards
+compatible with Ada 83, Ada 83 programs may generally be compiled using
+this switch (see the description of the @option{-gnat83} switch for further
+information about Ada 83 mode).
+If an Ada 2005 program is compiled in Ada 95 mode,
+uses of the new Ada 2005 features will cause error
+messages or warnings.
+
+This switch 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})
+@cindex Ada 2005 mode
+
+@noindent
+This switch directs the compiler to implement the Ada 2005 version of the
+language.
+Since Ada 2005 is almost completely upwards
+compatible with Ada 95 (and thus also with Ada 83), Ada 83 and Ada 95 programs
+may generally be compiled using this switch (see the description of the
+@option{-gnat83} and @option{-gnat95} switches for further
+information).
+
+For information about the approved ``Ada Issues'' that have been incorporated
+into Ada 2005, see @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs}.
+Included with GNAT releases is a file @file{features-ada0y} that describes
+the set of implemented Ada 2005 features.
 @end table
 
+
 @node Character Set Control
 @subsection Character Set Control
 @table @option
 @item ^-gnati^/IDENTIFIER_CHARACTER_SET=^@var{c}
-@cindex @option{^-gnati^/IDENTIFIER_CHARACTER_SET^} (@code{gcc})
+@cindex @option{^-gnati^/IDENTIFIER_CHARACTER_SET^} (@command{gcc})
 
 @noindent
 Normally GNAT recognizes the Latin-1 character set in source program
-identifiers, as described in the Ada 95 Reference Manual.
+identifiers, as described in the Ada Reference Manual.
 This switch causes
 GNAT to recognize alternate character sets in identifiers. @var{c} is a
 single character ^^or word^ indicating the character set, as follows:
@@ -5952,7 +6432,7 @@ allowed in identifiers
 implementation of these character sets.
 
 @item ^-gnatW^/WIDE_CHARACTER_ENCODING=^@var{e}
-@cindex @option{^-gnatW^/WIDE_CHARACTER_ENCODING^} (@code{gcc})
+@cindex @option{^-gnatW^/WIDE_CHARACTER_ENCODING^} (@command{gcc})
 Specify the method of encoding for wide characters.
 @var{e} is one of the following:
 
@@ -5976,19 +6456,24 @@ UTF-8 encoding (brackets encoding also recognized)
 @item ^b^BRACKETS^
 Brackets encoding only (default value)
 @end table
-For full details on the these encoding
-methods see @xref{Wide Character Encodings}.
+For full details on these encoding
+methods see @ref{Wide Character Encodings}.
 Note that brackets coding is always accepted, even if one of the other
 options is specified, so for example @option{-gnatW8} specifies that both
-brackets and @code{UTF-8} encodings will be recognized. The units that are
+brackets and UTF-8 encodings will be recognized. The units that are
 with'ed directly or indirectly will be scanned using the specified
 representation scheme, and so if one of the non-brackets scheme is
 used, it must be used consistently throughout the program. However,
 since brackets encoding is always recognized, it may be conveniently
 used in standard libraries, allowing these libraries to be used with
 any of the available coding schemes.
-scheme. If no @option{-gnatW?} parameter is present, then the default
-representation is Brackets encoding only.
+scheme.
+
+If no @option{-gnatW?} parameter is present, then the default
+representation is normally Brackets encoding only. However, if the
+first three characters of the file are 16#EF# 16#BB# 16#BF# (the standard
+byte order mark or BOM for UTF-8), then these three characters are
+skipped and the default representation for the file is set to UTF-8.
 
 Note that the wide character representation that is specified (explicitly
 or by default) for the main program also acts as the default encoding used
@@ -6001,7 +6486,7 @@ parameter.
 
 @table @option
 @item ^-gnatk^/FILE_NAME_MAX_LENGTH=^@var{n}
-@cindex @option{-gnatk} (@code{gcc})
+@cindex @option{-gnatk} (@command{gcc})
 Activates file name ``krunching''. @var{n}, a decimal integer in the range
 1-999, indicates the maximum allowable length of a file name (not
 including the @file{.ads} or @file{.adb} extension). The default is not
@@ -6010,14 +6495,13 @@ to enable file name krunching.
 For the source file naming rules, @xref{File Naming Rules}.
 @end table
 
-
 @node Subprogram Inlining Control
 @subsection Subprogram Inlining Control
 
 @table @option
 @c !sort!
 @item -gnatn
-@cindex @option{-gnatn} (@code{gcc})
+@cindex @option{-gnatn} (@command{gcc})
 @ifclear vms
 The @code{n} here is intended to suggest the first syllable of the
 word ``inline''.
@@ -6035,10 +6519,10 @@ If you specify this switch the compiler will access these bodies,
 creating an extra source dependency for the resulting object file, and
 where possible, the call will be inlined.
 For further details on when inlining is possible
-see @xref{Inlining of Subprograms}.
+see @ref{Inlining of Subprograms}.
 
 @item -gnatN
-@cindex @option{-gnatN} (@code{gcc})
+@cindex @option{-gnatN} (@command{gcc})
 The front end inlining activated by this switch is generally more extensive,
 and quite often more effective than the standard @option{-gnatn} inlining mode.
 It will also generate additional dependencies.
@@ -6052,7 +6536,7 @@ to specify both options.
 
 @table @option
 @item -gnatt
-@cindex @option{-gnatt} (@code{gcc})
+@cindex @option{-gnatt} (@command{gcc})
 @cindex Writing internal trees
 @cindex Internal trees, writing to file
 Causes GNAT to write the internal tree for a unit to a file (with the
@@ -6063,19 +6547,19 @@ these tools do the necessary compilations automatically, so you should
 not have to specify this switch in normal operation.
 
 @item -gnatu
-@cindex @option{-gnatu} (@code{gcc})
+@cindex @option{-gnatu} (@command{gcc})
 Print a list of units required by this compilation on @file{stdout}.
 The listing includes all units on which the unit being compiled depends
 either directly or indirectly.
 
 @ifclear vms
 @item -pass-exit-codes
-@cindex @option{-pass-exit-codes} (@code{gcc})
-If this switch is not used, the exit code returned by @code{gcc} when
+@cindex @option{-pass-exit-codes} (@command{gcc})
+If this switch is not used, the exit code returned by @command{gcc} when
 compiling multiple files indicates whether all source files have
 been successfully used to generate object files or not.
 
-When @option{-pass-exit-codes} is used, @code{gcc} exits with an extended
+When @option{-pass-exit-codes} is used, @command{gcc} exits with an extended
 exit status and allows an integrated development environment to better
 react to a compilation failure. Those exit status are:
 
@@ -6100,7 +6584,7 @@ An object file has been generated for every source file.
 @cindex Debugging options
 @ifclear vms
 @item -gnatd@var{x}
-@cindex @option{-gnatd} (@code{gcc})
+@cindex @option{-gnatd} (@command{gcc})
 Activate internal debugging switches. @var{x} is a letter or digit, or
 string of letters or digits, which specifies the type of debugging
 outputs desired. Normally these are used only for internal development
@@ -6110,7 +6594,7 @@ file @file{debug.adb}.
 @end ifclear
 
 @item -gnatG
-@cindex @option{-gnatG} (@code{gcc})
+@cindex @option{-gnatG} (@command{gcc})
 This switch causes the compiler to generate auxiliary output containing
 a pseudo-source listing of the generated expanded code. Like most Ada
 compilers, GNAT works by first transforming the high level Ada code into
@@ -6131,6 +6615,11 @@ do not have any exact analogies in pure Ada source form. The following
 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.
@@ -6161,8 +6650,12 @@ integers without any kind of scaling.
 @item free @var{expr} [storage_pool = @var{xxx}]
 Shows the storage pool associated with a @code{free} statement.
 
-@item freeze @var{typename} [@var{actions}]
-Shows the point at which @var{typename} is frozen, with possible
+@item [subtype or type declaration]
+Used to list an equivalent declaration for an internally generated
+type that is referenced elsewhere in the listing.
+
+@item freeze @var{type-name} [@var{actions}]
+Shows the point at which @var{type-name} is frozen, with possible
 associated actions to be performed at the freeze point.
 
 @item reference @var{itype}
@@ -6171,10 +6664,15 @@ Reference (and hence definition) to internal type @var{itype}.
 @item @var{function-name}! (@var{arg}, @var{arg}, @var{arg})
 Intrinsic function call.
 
-@item @var{labelname} : label
+@item @var{label-name} : label
 Declaration of label @var{labelname}.
 
-@item @var{expr} && @var{expr} && @var{expr} ... && @var{expr}
+@item #$ @var{subprogram-name}
+An implicit call to a run-time support routine
+(to meet the requirement of H.3.1(9) in a
+convenient manner).
+
+@item @var{expr} && @var{expr} && @var{expr} @dots{} && @var{expr}
 A multiple concatenation (same effect as @var{expr} & @var{expr} &
 @var{expr}, but handled more efficiently).
 
@@ -6194,15 +6692,15 @@ evaluation of the expression 1.0/27.0).
 @end table
 
 @item -gnatD
-@cindex @option{-gnatD} (@code{gcc})
+@cindex @option{-gnatD} (@command{gcc})
 When used in conjunction with @option{-gnatG}, this switch causes
 the expanded source, as described above for
 @option{-gnatG} to be written to files with names
 @file{^xxx.dg^XXX_DG^}, where @file{xxx} is the normal file name,
-instead of to the standard ooutput file. For
+instead of to the standard output file. For
 example, if the source file name is @file{hello.adb}, then a file
 @file{^hello.adb.dg^HELLO.ADB_DG^} will be written.  The debugging
-information generated by the @code{gcc} @option{^-g^/DEBUG^} switch
+information generated by the @command{gcc} @option{^-g^/DEBUG^} switch
 will refer to the generated @file{^xxx.dg^XXX_DG^} file. This allows
 you to do source level debugging using the generated code which is
 sometimes useful for complex code, for example to find out exactly
@@ -6216,9 +6714,14 @@ Note that @option{-gnatD} actually implies @option{-gnatG}
 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} (@code{gcc})
+@cindex @option{-gnatR} (@command{gcc})
 This switch controls output from the compiler of a listing showing
 representation information for declared types and objects. For
 @option{-gnatR0}, no information is output (equivalent to omitting
@@ -6226,7 +6729,8 @@ the @option{-gnatR} switch). For @option{-gnatR1} (which is the default,
 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
+declared types and objects. Finally @option{-gnatR3} includes symbolic
+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
@@ -6237,7 +6741,7 @@ file is the name of the corresponding source file.
 @end ifclear
 @ifset vms
 @item /REPRESENTATION_INFO
-@cindex @option{/REPRESENTATION_INFO} (@code{gcc})
+@cindex @option{/REPRESENTATION_INFO} (@command{gcc})
 This qualifier controls output from the compiler of a listing showing
 representation information for declared types and objects. For
 @option{/REPRESENTATION_INFO=NONE}, no information is output
@@ -6258,9 +6762,18 @@ If _FILE is added at the end of an option
 then the output is to a file with the name @file{file_REP} where
 file is the name of the corresponding source file.
 @end ifset
+Note that it is possible for record components to have zero size. In
+this case, the component clause uses an obvious extension of permitted
+Ada syntax, for example @code{at 0 range 0 .. -1}.
+
+Representation information requires that code be generated (since it is the
+code generator that lays out complex data structures). If an attempt is made
+to output representation information when no code is generated, for example
+when a subunit is compiled on its own, then no information can be generated
+and the compiler outputs a message to this effect.
 
 @item -gnatS
-@cindex @option{-gnatS} (@code{gcc})
+@cindex @option{-gnatS} (@command{gcc})
 The use of the switch @option{-gnatS} for an
 Ada compilation will cause the compiler to output a
 representation of package Standard in a form very
@@ -6273,7 +6786,7 @@ determine the characteristics of target dependent
 types in package Standard.
 
 @item -gnatx
-@cindex @option{-gnatx} (@code{gcc})
+@cindex @option{-gnatx} (@command{gcc})
 Normally the compiler generates full cross-referencing information in
 the @file{ALI} file. This information is used by a number of tools,
 including @code{gnatfind} and @code{gnatxref}. The @option{-gnatx} switch
@@ -6286,7 +6799,7 @@ speed up compilation, but means that these tools cannot be used.
 
 @noindent
 GNAT uses two methods for handling exceptions at run-time. The
-@code{longjmp/setjmp} method saves the context when entering
+@code{setjmp/longjmp} method saves the context when entering
 a frame with an exception handler. Then when an exception is
 raised, the context can be restored immediately, without the
 need for tracing stack frames. This method provides very fast
@@ -6301,56 +6814,48 @@ raised, the tables are used to control a back trace of the
 subprogram invocation stack to locate the required exception
 handler. This method has considerably poorer performance for
 the propagation of exceptions, but there is no overhead for
-exception handlers if no exception is raised.
+exception handlers if no exception is raised. Note that in this
+mode and in the context of mixed Ada and C/C++ programming,
+to propagate an exception through a C/C++ code, the C/C++ code
+must be compiled with the @option{-funwind-tables} GCC's
+option.
 
-The following switches can be used to control which of the
+The following switches may be used to control which of the
 two exception handling methods is used.
 
 @table @option
 @c !sort!
 
-@item -gnatL
-@cindex @option{-gnatL} (@code{gcc})
-This switch causes the longjmp/setjmp approach to be used
-for exception handling. If this is the default mechanism for the
-target (see below), then this has no effect. If the default
+@item --RTS=sjlj
+@cindex @option{--RTS=sjlj} (@command{gnatmake})
+This switch causes the setjmp/longjmp run-time (when available) to be used
+for exception handling. If the default
 mechanism for the target is zero cost exceptions, then
-this switch 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
-@option{-a} and @option{-f} switches for @code{gnatmake}.
+this switch can be used to modify this default, and must be
+used for all units in the partition.
 This option is rarely used. One case in which it may be
 advantageous is if you have an application where exception
 raising is common and the overall performance of the
 application is improved by favoring exception propagation.
 
-@item -gnatZ
-@cindex @option{-gnatZ} (@code{gcc})
+@item --RTS=zcx
+@cindex @option{--RTS=zcx} (@command{gnatmake})
 @cindex Zero Cost Exceptions
-This switch causes the zero cost approach to be sed
+This switch causes the zero cost approach to be used
 for exception handling. If this is the default mechanism for the
-target (see below), then this has no effect. If the default
-mechanism for the target is longjmp/setjmp exceptions, then
-this switch 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
-@option{-a} and @option{-f} switches for @code{gnatmake}.
+target (see below), then this switch is unneeded. If the default
+mechanism for the target is setjmp/longjmp exceptions, then
+this switch can be used to modify this default, and must be
+used for all units in the partition.
 This option can only be used if the zero cost approach
-is available for the target in use (see below).
+is available for the target in use, otherwise it will generate an error.
 @end table
 
 @noindent
-The @code{longjmp/setjmp} approach is available on all targets, but
-the @code{zero cost} approach is only available on selected targets.
-To determine whether zero cost exceptions can be used for a
-particular target, look at the private part of the file system.ads.
-Either @code{GCC_ZCX_Support} or @code{Front_End_ZCX_Support} must
-be True to use the zero cost approach. If both of these switches
-are set to False, this means that zero cost exception handling
-is not yet available for that target. The switch
-@code{ZCX_By_Default} indicates the default approach. If this
-switch is set to True, then the @code{zero cost} approach is
-used by default.
+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.
 
 @node Units to Sources Mapping Files
 @subsection Units to Sources Mapping Files
@@ -6358,7 +6863,7 @@ used by default.
 @table @option
 
 @item -gnatem^^=^@var{path}
-@cindex @option{-gnatem} (@code{gcc})
+@cindex @option{-gnatem} (@command{gcc})
 A mapping file is a way to communicate to the compiler two mappings:
 from unit names to file names (without any directory information) and from
 file names to path names (with full directory information). These mappings
@@ -6370,7 +6875,7 @@ sources are read over a slow network connection. In normal operation,
 you need not be concerned with the format or use of mapping files,
 and the @option{-gnatem} switch is not a switch that you would use
 explicitly. it is intended only for use by automatic tools such as
-@code{gnatmake} running under the project file facility. The
+@command{gnatmake} running under the project file facility. The
 description here of the format of mapping files is provided
 for completeness and for possible use by other tools.
 
@@ -6395,17 +6900,17 @@ will be created.
 Several @option{-gnatem} switches may be specified; however, only the last
 one on the command line will be taken into account.
 
-When using a project file, @code{gnatmake} create a temporary mapping file
+When using a project file, @command{gnatmake} create a temporary mapping file
 and communicates it to the compiler using this switch.
 
 @end table
 
-
 @node Integrated Preprocessing
 @subsection Integrated Preprocessing
 
 @noindent
-GNAT sources may be preprocessed immediately before compilation; the actual
+GNAT sources may be preprocessed immediately before compilation.
+In this case, the actual
 text of the source is not the text of the source file, but is derived from it
 through a process called preprocessing. Integrated preprocessing is specified
 through switches @option{-gnatep} and/or @option{-gnateD}. @option{-gnatep}
@@ -6413,15 +6918,22 @@ indicates, through a text file, the preprocessing data to be used.
 @option{-gnateD} specifies or modifies the values of preprocessing symbol.
 
 @noindent
-It is recommended that @code{gnatmake} switch ^-s^/SWITCH_CHECK^ should be
+Note that when integrated preprocessing is used, the output from the
+preprocessor is not written to any external file. Instead it is passed
+internally to the compiler. If you need to preserve the result of
+preprocessing in a file, then you should use @command{gnatprep}
+to perform the desired preprocessing in stand-alone mode.
+
+@noindent
+It is recommended that @command{gnatmake} switch ^-s^/SWITCH_CHECK^ should be
 used when Integrated Preprocessing is used. The reason is that preprocessing
 with another Preprocessing Data file without changing the sources will
 not trigger recompilation without this switch.
 
 @noindent
-Note that @code{gnatmake} switch ^-m^/MINIMAL_RECOMPILATION^ will almost
+Note that @command{gnatmake} switch ^-m^/MINIMAL_RECOMPILATION^ will almost
 always trigger recompilation for sources that are preprocessed,
-because @code{gnatmake} cannot compute the checksum of the source after
+because @command{gnatmake} cannot compute the checksum of the source after
 preprocessing.
 
 @noindent
@@ -6432,7 +6944,7 @@ preprocessing is triggered and parameterized.
 @table @code
 
 @item -gnatep=@var{file}
-@cindex @option{-gnatep} (@code{gcc})
+@cindex @option{-gnatep} (@command{gcc})
 This switch indicates to the compiler the file name (without directory
 information) of the preprocessor data file to use. The preprocessor data file
 should be found in the source directories.
@@ -6453,8 +6965,8 @@ lines starting with the character '*'.
 
 @noindent
 After the file name or the character '*', another optional literal string
-indicating the file name of the definition file to be used for preprocessing.
-(see @ref{Form of Definitions File}. The definition files are found by the
+indicating the file name of the definition file to be used for preprocessing
+(@pxref{Form of Definitions File}). The definition files are found by the
 compiler in one of the source directories. In some cases, when compiling
 a source in a directory other than the current directory, if the definition
 file is in the current directory, it may be necessary to add the current
@@ -6516,7 +7028,7 @@ Examples of valid lines in a preprocessor data file:
 @end smallexample
 
 @item ^-gnateD^/DATA_PREPROCESSING=^symbol[=value]
-@cindex @option{-gnateD} (@code{gcc})
+@cindex @option{-gnateD} (@command{gcc})
 Define or redefine a preprocessing symbol, associated with value. If no value
 is given on the command line, then the value of the symbol is @code{True}.
 A symbol is an identifier, following normal Ada (case-insensitive)
@@ -6549,7 +7061,7 @@ for optimal arrangement of instructions (e.g. different members of
 the x86 family). The list of available @option{-m} switches may be
 found in the GCC documentation.
 
-Use of the these @option{-m} switches may in some cases result in improved
+Use of these @option{-m} switches may in some cases result in improved
 code performance.
 
 The GNAT Pro technology is tested and qualified without any
@@ -6574,10 +7086,11 @@ unless you actually see a performance improvement.
 On VMS, GNAT compiled programs return POSIX-style codes by default,
 e.g. @option{/RETURN_CODES=POSIX}.
 
-To enable VMS style return codes, GNAT LINK with the option
+To enable VMS style return codes, use GNAT BIND and LINK with the option
 @option{/RETURN_CODES=VMS}. For example:
 
 @smallexample
+GNAT BIND MYMAIN.ALI /RETURN_CODES=VMS
 GNAT LINK MYMAIN.ALI /RETURN_CODES=VMS
 @end smallexample
 
@@ -6588,7 +7101,6 @@ are suitable for spawning with appropriate GNAT RTL routines.
 
 @end ifset
 
-
 @node Search Paths and the Run-Time Library (RTL)
 @section Search Paths and the Run-Time Library (RTL)
 
@@ -6610,15 +7122,25 @@ The directory containing the source file of the main unit being compiled
 
 @item
 Each directory named by an @option{^-I^/SOURCE_SEARCH^} switch given on the
-@code{gcc} command line, in the order given.
+@command{gcc} command line, in the order given.
+
+@item
+@findex ADA_PRJ_INCLUDE_FILE
+Each of the directories listed in the text file whose name is given
+by the @env{ADA_PRJ_INCLUDE_FILE} ^environment variable^logical name^.
+
+@noindent
+@env{ADA_PRJ_INCLUDE_FILE} is normally set by gnatmake or by the ^gnat^GNAT^
+driver when project files are used. It should not normally be set
+by other means.
 
 @item
 @findex ADA_INCLUDE_PATH
 Each of the directories listed in the value of the
-@code{ADA_INCLUDE_PATH} ^environment variable^logical name^.
+@env{ADA_INCLUDE_PATH} ^environment variable^logical name^.
 @ifclear vms
 Construct this value
-exactly as the @code{PATH} environment variable: a list of directory
+exactly as the @env{PATH} environment variable: a list of directory
 names separated by colons (semicolons when working with the NT version).
 @end ifclear
 @ifset vms
@@ -6626,7 +7148,7 @@ Normally, define this value as a logical name containing a comma separated
 list of directory names.
 
 This variable can also be defined by means of an environment string
-(an argument to the DEC C exec* set of functions).
+(an argument to the HP C exec* set of functions).
 
 Logical Name:
 @smallexample
@@ -6635,30 +7157,20 @@ DEFINE ADA_INCLUDE_PATH ANOTHER_PATH,FOO:[BAM],FOO:[BAR]
 @end smallexample
 
 By default, the path includes GNU:[LIB.OPENVMS7_x.2_8_x.DECLIB]
-first, followed by the standard Ada 95
+first, followed by the standard Ada
 libraries in GNU:[LIB.OPENVMS7_x.2_8_x.ADAINCLUDE].
-If this is not redefined, the user will obtain the DEC Ada 83 IO packages
+If this is not redefined, the user will obtain the HP Ada 83 IO packages
 (Text_IO, Sequential_IO, etc)
-instead of the Ada95 packages. Thus, in order to get the Ada 95
+instead of the standard Ada packages. Thus, in order to get the standard Ada
 packages by default, ADA_INCLUDE_PATH must be redefined.
 @end ifset
 
 @item
-@findex ADA_PRJ_INCLUDE_FILE
-Each of the directories listed in the text file whose name is given
-by the @code{ADA_PRJ_INCLUDE_FILE} ^environment variable^logical name^.
-
-@noindent
-@code{ADA_PRJ_INCLUDE_FILE} is normally set by gnatmake or by the ^gnat^GNAT^
-driver when project files are used. It should not normally be set
-by other means.
-
-@item
 The content of the @file{ada_source_path} file which is part of the GNAT
 installation tree and is used to store standard libraries such as the
 GNAT Run Time Library (RTL) source files.
 @ifclear vms
-@ref{Installing the library}
+@ref{Installing a library}
 @end ifclear
 @end enumerate
 
@@ -6677,7 +7189,7 @@ The compiler outputs its object files and ALI files in the current
 working directory.
 @ifclear vms
 Caution: The object file can be redirected with the @option{-o} switch;
-however, @code{gcc} and @code{gnat1} have not been coordinated on this
+however, @command{gcc} and @code{gnat1} have not been coordinated on this
 so the @file{ALI} file will not go to the right place. Therefore, you should
 avoid using the @option{-o} switch.
 @end ifclear
@@ -6702,7 +7214,6 @@ Besides simplifying access to the RTL, a major use of search paths is
 in compiling sources from multiple directories. This can make
 development environments much more flexible.
 
-
 @node Order of Compilation Issues
 @section Order of Compilation Issues
 
@@ -6781,27 +7292,31 @@ mode.
 
 @noindent
 This chapter describes the GNAT binder, @code{gnatbind}, which is used
-to bind compiled GNAT objects. The @code{gnatbind} program performs
-four separate functions:
+to bind compiled GNAT objects.
+
+Note: to invoke @code{gnatbind} with a project file, use the @code{gnat}
+driver (see @ref{The GNAT Driver and Project Files}).
+
+The @code{gnatbind} program performs four separate functions:
 
 @enumerate
 @item
 Checks that a program is consistent, in accordance with the rules in
-Chapter 10 of the Ada 95 Reference Manual. In particular, error
+Chapter 10 of the Ada Reference Manual. In particular, error
 messages are generated if a program uses inconsistent versions of a
 given unit.
 
 @item
 Checks that an acceptable order of elaboration exists for the program
 and issues an error message if it cannot find an order of elaboration
-that satisfies the rules in Chapter 10 of the Ada 95 Language Manual.
+that satisfies the rules in Chapter 10 of the Ada Language Manual.
 
 @item
 Generates a main program incorporating the given elaboration order.
 This program is a small Ada package (body and spec) that
 must be subsequently compiled
 using the GNAT compiler. The necessary compilation step is usually
-performed automatically by @code{gnatlink}. The two most important
+performed automatically by @command{gnatlink}. The two most important
 functions of this program
 are to call the elaboration routines of units in an appropriate order
 and to call the main program.
@@ -6809,10 +7324,9 @@ and to call the main program.
 @item
 Determines the set of object files required by the given main program.
 This information is output in the forms of comments in the generated program,
-to be read by the @code{gnatlink} utility used to link the Ada application.
+to be read by the @command{gnatlink} utility used to link the Ada application.
 @end enumerate
 
-
 @node Running gnatbind
 @section Running @code{gnatbind}
 
@@ -6840,7 +7354,7 @@ that the given main program requires the package @code{Pack}, whose
 file is @file{pack.ali} and whose corresponding source spec file is
 @file{pack.ads}, it attempts to locate the source file @file{pack.ads}
 (using the same search path conventions as previously described for the
-@code{gcc} command). If it can locate this source file, it checks that
+@command{gcc} command). If it can locate this source file, it checks that
 the time stamps
 or source checksums of the source and its references to in @file{ALI} files
 match. In other words, any @file{ALI} files that mentions this spec must have
@@ -6901,10 +7415,9 @@ program in C rather than Ada. This may for example be helpful when you
 are generating a mixed language program with the main program in C. The
 GNAT compiler itself is an example.
 The use of the @option{^-C^/BIND_FILE=C^} switch
-for both @code{gnatbind} and @code{gnatlink} will cause the program to
+for both @code{gnatbind} and @command{gnatlink} will cause the program to
 be generated in C (and compiled using the gnu C compiler).
 
-
 @node Switches for gnatbind
 @section Switches for @command{gnatbind}
 
@@ -6923,6 +7436,23 @@ be presented in subsequent sections.
 
 @table @option
 @c !sort!
+
+@item --version
+@cindex @option{--version} @command{gnatbind}
+Display Copyright and version, then exit disregarding all other options.
+
+@item --help
+@cindex @option{--help} @command{gnatbind}
+If @option{--version} was not used, display usage, then exit disregarding
+all other options.
+
+@item -a
+@cindex @option{-a} @command{gnatbind}
+Indicates that, if supported by the platform, the adainit procedure should
+be treated as an initialisation routine by the linker (a constructor). This
+is intended to be used by the Project Manager to automatically initialize
+shared Stand-Alone Libraries.
+
 @item ^-aO^/OBJECT_SEARCH^
 @cindex @option{^-aO^/OBJECT_SEARCH^} (@command{gnatbind})
 Specify directory to be searched for ALI files.
@@ -6947,6 +7477,41 @@ Check only, no generation of binder output file.
 @cindex @option{^-C^/BIND_FILE=C^} (@command{gnatbind})
 Generate binder program in C
 
+@item ^-d^/DEFAULT_STACK_SIZE=^@var{nn}[k|m]
+@cindex @option{^-d^/DEFAULT_STACK_SIZE=^@var{nn}[k|m]} (@command{gnatbind})
+This switch can be used to change the default task stack size value
+to a specified size @var{nn}, which is expressed in bytes by default, or
+in kilobytes when suffixed with @var{k} or in megabytes when suffixed
+with @var{m}.
+In the absence of a [k|m] suffix, this switch is equivalent, in effect,
+to completing all task specs with
+@smallexample @c ada
+   pragma Storage_Size (nn);
+@end smallexample
+When they do not already have such a pragma.
+
+@item ^-D^/DEFAULT_SECONDARY_STACK_SIZE=^@var{nn}[k|m]
+@cindex @option{^-D^/DEFAULT_SECONDARY_STACK_SIZE=nnnnn^} (@command{gnatbind})
+This switch can be used to change the default secondary stack size value
+to a specified size @var{nn}, which is expressed in bytes by default, or
+in kilobytes when suffixed with @var{k} or in megabytes when suffixed
+with @var{m}.
+
+The secondary stack is used to deal with functions that return a variable
+sized result, for example a function returning an unconstrained
+String. There are two ways in which this secondary stack is allocated.
+
+For most targets, the secondary stack is growing on demand and is allocated
+as a chain of blocks in the heap. The -D option is not very
+relevant. It only give some control over the size of the allocated
+blocks (whose size is the minimum of the default secondary stack size value,
+and the actual size needed for the current allocation request).
+
+For certain targets, notably VxWorks 653,
+the secondary stack is allocated by carving off a fixed ratio chunk of the
+primary task stack. The -D option is used to define the
+size of the environment task's secondary stack.
+
 @item ^-e^/ELABORATION_DEPENDENCIES^
 @cindex @option{^-e^/ELABORATION_DEPENDENCIES^} (@command{gnatbind})
 Output complete list of elaboration-order dependencies.
@@ -6964,7 +7529,7 @@ See also the packages @code{GNAT.Traceback} and
 @code{GNAT.Traceback.Symbolic} for more information.
 @ifclear vms
 Note that on x86 ports, you must not use @option{-fomit-frame-pointer}
-@code{gcc} option.
+@command{gcc} option.
 @end ifclear
 
 @item ^-F^/FORCE_ELABS_FLAGS^
@@ -6997,13 +7562,13 @@ Output chosen elaboration order.
 
 @item ^-Lxxx^/BUILD_LIBRARY=xxx^
 @cindex @option{^-L^/BUILD_LIBRARY^} (@command{gnatbind})
-Binds the units for library building. In this case the adainit and
-adafinal procedures (See @pxref{Binding with Non-Ada Main Programs})
+Bind the units for library building. In this case the adainit and
+adafinal procedures (@pxref{Binding with Non-Ada Main Programs})
 are renamed to ^xxxinit^XXXINIT^ and
 ^xxxfinal^XXXFINAL^.
 Implies ^-n^/NOCOMPILE^.
 @ifclear vms
-(@pxref{GNAT and Libraries}, for more details.)
+(@xref{GNAT and Libraries}, for more details.)
 @end ifclear
 @ifset vms
 On OpenVMS, these init and final procedures are exported in uppercase
@@ -7014,7 +7579,8 @@ procedure will be "TOTOFINAL".
 
 @item ^-Mxyz^/RENAME_MAIN=xyz^
 @cindex @option{^-M^/RENAME_MAIN^} (@command{gnatbind})
-Rename generated main program from main to xyz
+Rename generated main program from main to xyz. This option is
+supported on cross environments only.
 
 @item ^-m^/ERROR_LIMIT=^@var{n}
 @cindex @option{^-m^/ERROR_LIMIT^} (@command{gnatbind})
@@ -7041,7 +7607,7 @@ Do not look for library files in the system default directory.
 @item --RTS=@var{rts-path}
 @cindex @option{--RTS} (@code{gnatbind})
 Specifies the default location of the runtime library. Same meaning as the
-equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}).
+equivalent @command{gnatmake} flag (@pxref{Switches for gnatmake}).
 
 @item ^-o ^/OUTPUT=^@var{file}
 @cindex @option{^-o ^/OUTPUT^} (@command{gnatbind})
@@ -7057,6 +7623,10 @@ Output object list.
 @cindex @option{^-p^/PESSIMISTIC_ELABORATION^} (@command{gnatbind})
 Pessimistic (worst-case) elaboration order
 
+@item ^-R^-R^
+@cindex @option{^-R^-R^} (@command{gnatbind})
+Output closure source list.
+
 @item ^-s^/READ_SOURCES=ALL^
 @cindex @option{^-s^/READ_SOURCES=ALL^} (@command{gnatbind})
 Require all source files to be present.
@@ -7069,7 +7639,6 @@ The @var{xxx} ^string specified with the switch^option^ may be either
 @itemize @bullet
 @item ``@option{^in^INVALID^}'' requesting an invalid value where possible
 @item ``@option{^lo^LOW^}'' for the lowest possible value
-possible, and the low
 @item ``@option{^hi^HIGH^}'' for the highest possible value
 @item ``@option{xx}'' for a value consisting of repeated bytes with the
 value 16#xx# (i.e. xx is a string of two hexadecimal digits).
@@ -7078,7 +7647,7 @@ value 16#xx# (i.e. xx is a string of two hexadecimal digits).
 In addition, you can specify @option{-Sev} to indicate that the value is
 to be set at run time. In this case, the program will look for an environment
 @cindex GNAT_INIT_SCALARS
-variable of the form @code{GNAT_INIT_SCALARS=xx}, where xx is one
+variable of the form @env{GNAT_INIT_SCALARS=xx}, where xx is one
 of @option{in/lo/hi/xx} with the same meanings as above.
 If no environment variable is found, or if it does not have a valid value,
 then the default is @option{in} (invalid values).
@@ -7103,7 +7672,7 @@ Set the time slice value to @var{n} milliseconds. If the system supports
 the specification of a specific time slice value, then the indicated value
 is used. If the system does not support specific time slice values, but
 does support some general notion of round-robin scheduling, then any
-non-zero value will activate round-robin scheduling.
+nonzero value will activate round-robin scheduling.
 
 A value of zero is treated specially. It turns off time
 slicing, and in addition, indicates to the tasking run time that the
@@ -7111,6 +7680,14 @@ semantics should match as closely as possible the Annex D
 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 @var{n} results stored and displayed
+at program termination. A result is generated when a task
+terminates. Results that can't be stored are displayed on the fly, at
+task termination. This option is currently not supported on Itanium
+platforms. (See @ref{Dynamic Stack Usage Analysis} for details.)
+
 @item ^-v^/REPORT_ERRORS=VERBOSE^
 @cindex @option{^-v^/REPORT_ERRORS=VERBOSE^} (@code{gnatbind})
 Verbose mode. Write error messages, header, summary output to
@@ -7136,6 +7713,10 @@ All warning messages are suppressed
 Warning messages are treated as fatal errors
 @end ifset
 
+@item ^-Wx^/WIDE_CHARACTER_ENCODING=^@var{e}
+@cindex @option{^-Wx^/WIDE_CHARACTER_ENCODING^} (@code{gnatbind})
+Override default wide character encoding for standard Text_IO files.
+
 @item ^-x^/READ_SOURCES=NONE^
 @cindex @option{^-x^/READ_SOURCES^} (@code{gnatbind})
 Exclude source files (check object consistency only).
@@ -7147,6 +7728,10 @@ Default mode, in which sources are checked for consistency only if
 they are available.
 @end ifset
 
+@item ^-y^/ENABLE_LEAP_SECONDS^
+@cindex @option{^-y^/ENABLE_LEAP_SECONDS^} (@code{gnatbind})
+Enable leap seconds support in @code{Ada.Calendar} and its children.
+
 @item ^-z^/ZERO_MAIN^
 @cindex @option{^-z^/ZERO_MAIN^} (@code{gnatbind})
 No main subprogram.
@@ -7158,7 +7743,6 @@ You may obtain this listing of switches by running @code{gnatbind} with
 no arguments.
 @end ifclear
 
-
 @node Consistency-Checking Modes
 @subsection Consistency-Checking Modes
 
@@ -7178,6 +7762,16 @@ their consistency. In normal mode, if a source file cannot be located it
 is simply ignored. If you specify this switch, a missing source
 file is an error.
 
+@item ^-Wx^/WIDE_CHARACTER_ENCODING=^@var{e}
+@cindex @option{^-Wx^/WIDE_CHARACTER_ENCODING^} (@code{gnatbind})
+Override default wide character encoding for standard Text_IO files.
+Normally the default wide character encoding method used for standard
+[Wide_[Wide_]]Text_IO files is taken from the encoding specified for
+the main source input (see description of switch
+@option{^-gnatWx^/WIDE_CHARACTER_ENCODING^} for the compiler). The
+use of this switch for the binder (which has the same set of
+possible arguments) overrides this default as specified.
+
 @item ^-x^/READ_SOURCES=NONE^
 @cindex @option{^-x^/READ_SOURCES=NONE^} (@code{gnatbind})
 Exclude source files. In this mode, the binder only checks that ALI
@@ -7187,9 +7781,9 @@ the resulting program is self-consistent.
 If a source file has been edited since it was last compiled, and you
 specify this switch, the binder will not detect that the object
 file is out of date with respect to the source file. Note that this is the
-mode that is automatically used by @code{gnatmake} because in this
+mode that is automatically used by @command{gnatmake} because in this
 case the checking against sources has already been performed by
-@code{gnatmake} in the course of compilation (i.e. before binding).
+@command{gnatmake} in the course of compilation (i.e. before binding).
 
 @ifset vms
 @item /READ_SOURCES=AVAILABLE
@@ -7289,7 +7883,7 @@ with extreme care.}
 
 @noindent
 The following switches provide additional control over the elaboration
-order. For full details see @xref{Elaboration Order Handling in GNAT}.
+order. For full details see @ref{Elaboration Order Handling in GNAT}.
 
 @table @option
 @item ^-p^/PESSIMISTIC_ELABORATION^
@@ -7306,7 +7900,7 @@ Normally it only makes sense to use the @option{^-p^/PESSIMISTIC_ELABORATION^}
 switch if dynamic
 elaboration checking is used (@option{-gnatE} switch used for compilation).
 This is because in the default static elaboration mode, all necessary
-@code{Elaborate_All} pragmas are implicitly inserted.
+@code{Elaborate} and @code{Elaborate_All} pragmas are implicitly inserted.
 These implicit pragmas are still respected by the binder in
 @option{^-p^/PESSIMISTIC_ELABORATION^} mode, so a
 safe elaboration order is assured.
@@ -7452,7 +8046,7 @@ file, unless overridden by the use of the @option{^-o file^/OUTPUT=file^}.
 The output is an Ada unit in source form that can
 be compiled with GNAT unless the -C switch is used in which case the
 output is a C source file, which must be compiled using the C compiler.
-This compilation occurs automatically as part of the @code{gnatlink}
+This compilation occurs automatically as part of the @command{gnatlink}
 processing.
 
 Currently the GNAT run time requires a FPU using 80 bits mode
@@ -7478,10 +8072,13 @@ The following switch is used to bind programs organized in this manner:
 Normally the binder checks that the unit name given on the command line
 corresponds to a suitable main subprogram. When this switch is used,
 a list of ALI files can be given, and the execution of the program
-consists of elaboration of these units in an appropriate order.
+consists of elaboration of these units in an appropriate order. Note
+that the default wide character encoding method for standard Text_IO
+files is always set to Brackets if this switch is set (you can use
+the binder switch
+@option{^-Wx^WIDE_CHARACTER_ENCODING^} to override this default).
 @end table
 
-
 @node Command-Line Access
 @section Command-Line Access
 
@@ -7512,7 +8109,6 @@ required, your main program must set @code{gnat_argc} and
 @code{gnat_argv} from the @code{argc} and @code{argv} values passed to
 it.
 
-
 @node Search Paths for gnatbind
 @section Search Paths for @code{gnatbind}
 
@@ -7520,7 +8116,7 @@ it.
 The binder takes the name of an ALI file as its argument and needs to
 locate source files as well as other ALI files to verify object consistency.
 
-For source files, it follows exactly the same search rules as @code{gcc}
+For source files, it follows exactly the same search rules as @command{gcc}
 (@pxref{Search Paths and the Run-Time Library (RTL)}). For ALI files the
 directories searched are:
 
@@ -7535,12 +8131,22 @@ switches on the @code{gnatbind}
 command line, in the order given.
 
 @item
+@findex ADA_PRJ_OBJECTS_FILE
+Each of the directories listed in the text file whose name is given
+by the @env{ADA_PRJ_OBJECTS_FILE} ^environment variable^logical name^.
+
+@noindent
+@env{ADA_PRJ_OBJECTS_FILE} is normally set by gnatmake or by the ^gnat^GNAT^
+driver when project files are used. It should not normally be set
+by other means.
+
+@item
 @findex ADA_OBJECTS_PATH
 Each of the directories listed in the value of the
-@code{ADA_OBJECTS_PATH} ^environment variable^logical name^.
+@env{ADA_OBJECTS_PATH} ^environment variable^logical name^.
 @ifset unw
 Construct this value
-exactly as the @code{PATH} environment variable: a list of directory
+exactly as the @env{PATH} environment variable: a list of directory
 names separated by colons (semicolons when working with the NT version
 of GNAT).
 @end ifset
@@ -7549,7 +8155,7 @@ Normally, define this value as a logical name containing a comma separated
 list of directory names.
 
 This variable can also be defined by means of an environment string
-(an argument to the DEC C exec* set of functions).
+(an argument to the HP C exec* set of functions).
 
 Logical Name:
 @smallexample
@@ -7558,31 +8164,21 @@ DEFINE ADA_OBJECTS_PATH ANOTHER_PATH,FOO:[BAM],FOO:[BAR]
 @end smallexample
 
 By default, the path includes GNU:[LIB.OPENVMS7_x.2_8_x.DECLIB]
-first, followed by the standard Ada 95
+first, followed by the standard Ada
 libraries in GNU:[LIB.OPENVMS7_x.2_8_x.ADALIB].
-If this is not redefined, the user will obtain the DEC Ada 83 IO packages
+If this is not redefined, the user will obtain the HP Ada 83 IO packages
 (Text_IO, Sequential_IO, etc)
-instead of the Ada95 packages. Thus, in order to get the Ada 95
+instead of the standard Ada packages. Thus, in order to get the standard Ada
 packages by default, ADA_OBJECTS_PATH must be redefined.
 @end ifset
 
 @item
-@findex ADA_PRJ_OBJECTS_FILE
-Each of the directories listed in the text file whose name is given
-by the @code{ADA_PRJ_OBJECTS_FILE} ^environment variable^logical name^.
-
-@noindent
-@code{ADA_PRJ_OBJECTS_FILE} is normally set by gnatmake or by the ^gnat^GNAT^
-driver when project files are used. It should not normally be set
-by other means.
-
-@item
 The content of the @file{ada_object_path} file which is part of the GNAT
 installation tree and is used to store standard libraries such as the
 GNAT Run Time Library (RTL) unless the switch @option{-nostdlib} is
 specified.
 @ifclear vms
-@ref{Installing the library}
+@ref{Installing a library}
 @end ifclear
 @end enumerate
 
@@ -7681,34 +8277,34 @@ the @code{adainit} and @code{adafinal} routines to be called before and
 after accessing the Ada units.
 @end table
 
-
 @c ------------------------------------
 @node Linking Using gnatlink
-@chapter Linking Using @code{gnatlink}
+@chapter Linking Using @command{gnatlink}
 @c ------------------------------------
 @findex gnatlink
 
 @noindent
-This chapter discusses @code{gnatlink}, a tool that links
+This chapter discusses @command{gnatlink}, a tool that links
 an Ada program and builds an executable file. This utility
-invokes the system linker ^(via the @code{gcc} command)^^
+invokes the system linker ^(via the @command{gcc} command)^^
 with a correct list of object files and library references.
-@code{gnatlink} automatically determines the list of files and
+@command{gnatlink} automatically determines the list of files and
 references for the Ada part of a program. It uses the binder file
 generated by the @command{gnatbind} to determine this list.
 
+Note: to invoke @code{gnatlink} with a project file, use the @code{gnat}
+driver (see @ref{The GNAT Driver and Project Files}).
+
 @menu
 * Running gnatlink::
 * Switches for gnatlink::
-* Setting Stack Size from gnatlink::
-* Setting Heap Size from gnatlink::
 @end menu
 
 @node Running gnatlink
-@section Running @code{gnatlink}
+@section Running @command{gnatlink}
 
 @noindent
-The form of the @code{gnatlink} command is
+The form of the @command{gnatlink} command is
 
 @smallexample
 $ gnatlink [@var{switches}] @var{mainprog}[.ali]
@@ -7716,7 +8312,7 @@ $ gnatlink [@var{switches}] @var{mainprog}[.ali]
 @end smallexample
 
 @noindent
-The arguments of @code{gnatlink} (switches, main @file{ALI} file,
+The arguments of @command{gnatlink} (switches, main @file{ALI} file,
 non-Ada objects
 or linker options) may be in any order, provided that no non-Ada object may
 be mistaken for a main @file{ALI} file.
@@ -7727,13 +8323,13 @@ whose name is the concatenation of @file{F} and @file{.ali}.
 @noindent
 @file{@var{mainprog}.ali} references the ALI file of the main program.
 The @file{.ali} extension of this file can be omitted. From this
-reference, @code{gnatlink} locates the corresponding binder file
+reference, @command{gnatlink} locates the corresponding binder file
 @file{b~@var{mainprog}.adb} and, using the information in this file along
 with the list of non-Ada objects and linker options, constructs a
 linker command file to create the executable.
 
-The arguments other than the @code{gnatlink} switches and the main @file{ALI}
-file are passed to the linker uninterpreted.
+The arguments other than the @command{gnatlink} switches and the main
+@file{ALI} file are passed to the linker uninterpreted.
 They typically include the names of
 object files for units written in other languages than Ada and any library
 references required to resolve references in any of these foreign language
@@ -7741,67 +8337,73 @@ units, or in @code{Import} pragmas in any Ada units.
 
 @var{linker options} is an optional list of linker specific
 switches.
-The default linker called by gnatlink is @var{gcc} which in
+The default linker called by gnatlink is @command{gcc} which in
 turn calls the appropriate system linker.
 Standard options for the linker such as @option{-lmy_lib} or
 @option{-Ldir} can be added as is.
 For options that are not recognized by
-@var{gcc} as linker options, use the @var{gcc} switches @option{-Xlinker} or
-@option{-Wl,}.
+@command{gcc} as linker options, use the @command{gcc} switches
+@option{-Xlinker} or @option{-Wl,}.
 Refer to the GCC documentation for
 details. Here is an example showing how to generate a linker map:
 
-@ifclear vms
 @smallexample
-$ gnatlink my_prog -Wl,-Map,MAPFILE
+$ ^gnatlink my_prog -Wl,-Map,MAPFILE^GNAT LINK my_prog.ali /MAP^
 @end smallexample
-@end ifclear
-
-@ifset vms
-<<Need example for VMS>>
-@end ifset
 
 Using @var{linker options} it is possible to set the program stack and
-heap size. See @ref{Setting Stack Size from gnatlink}, and
+heap size.
+@ifclear vms
+See @ref{Setting Stack Size from gnatlink} and
 @ref{Setting Heap Size from gnatlink}.
+@end ifclear
 
-@code{gnatlink} determines the list of objects required by the Ada
+@command{gnatlink} determines the list of objects required by the Ada
 program and prepends them to the list of objects passed to the linker.
-@code{gnatlink} also gathers any arguments set by the use of
+@command{gnatlink} also gathers any arguments set by the use of
 @code{pragma Linker_Options} and adds them to the list of arguments
 presented to the linker.
 
 @ifset vms
-@code{gnatlink} accepts the following types of extra files on the command
-line: objects (.OBJ), libraries (.OLB), sharable images (.EXE), and
-options files (.OPT). These are recognized and handled according to their
-extension.
+@command{gnatlink} accepts the following types of extra files on the command
+line: objects (@file{.OBJ}), libraries (@file{.OLB}), sharable images
+(@file{.EXE}), and options files (@file{.OPT}). These are recognized and
+handled according to their extension.
 @end ifset
 
 @node Switches for gnatlink
-@section Switches for @code{gnatlink}
+@section Switches for @command{gnatlink}
 
 @noindent
-The following switches are available with the @code{gnatlink} utility:
+The following switches are available with the @command{gnatlink} utility:
 
 @table @option
 @c !sort!
 
+@item --version
+@cindex @option{--version} @command{gnatlink}
+Display Copyright and version, then exit disregarding all other options.
+
+@item --help
+@cindex @option{--help} @command{gnatlink}
+If @option{--version} was not used, display usage, then exit disregarding
+all other options.
+
 @item ^-A^/BIND_FILE=ADA^
-@cindex @option{^-A^/BIND_FILE=ADA^} (@code{gnatlink})
+@cindex @option{^-A^/BIND_FILE=ADA^} (@command{gnatlink})
 The binder has generated code in Ada. This is the default.
 
 @item ^-C^/BIND_FILE=C^
-@cindex @option{^-C^/BIND_FILE=C^} (@code{gnatlink})
+@cindex @option{^-C^/BIND_FILE=C^} (@command{gnatlink})
 If instead of generating a file in Ada, the binder has generated one in
 C, then the linker needs to know about it. Use this switch to signal
-to @code{gnatlink} that the binder has generated C code rather than
+to @command{gnatlink} that the binder has generated C code rather than
 Ada code.
 
 @item ^-f^/FORCE_OBJECT_FILE_LIST^
 @cindex Command line length
-@cindex @option{^-f^/FORCE_OBJECT_FILE_LIST^} (@code{gnatlink})
-On some targets, the command line length is limited, and @code{gnatlink}
+@cindex @option{^-f^/FORCE_OBJECT_FILE_LIST^} (@command{gnatlink})
+On some targets, the command line length is limited, and @command{gnatlink}
 will generate a separate file for the linker if the list of object files
 is too long.
 The @option{^-f^/FORCE_OBJECT_FILE_LIST^} switch forces this file
@@ -7811,7 +8413,7 @@ special situations where the command line length is exceeded.
 
 @item ^-g^/DEBUG^
 @cindex Debugging information, including
-@cindex @option{^-g^/DEBUG^} (@code{gnatlink})
+@cindex @option{^-g^/DEBUG^} (@command{gnatlink})
 The option to include debugging information causes the Ada bind file (in
 other words, @file{b~@var{mainprog}.adb}) to be compiled with
 @option{^-g^/DEBUG^}.
@@ -7823,24 +8425,24 @@ default. The same procedure apply if a C bind file was generated using
 are @file{b_@var{mainprog}.c} and @file{b_@var{mainprog}.o}.
 
 @item ^-n^/NOCOMPILE^
-@cindex @option{^-n^/NOCOMPILE^} (@code{gnatlink})
+@cindex @option{^-n^/NOCOMPILE^} (@command{gnatlink})
 Do not compile the file generated by the binder. This may be used when
 a link is rerun with different options, but there is no need to recompile
 the binder file.
 
 @item ^-v^/VERBOSE^
-@cindex @option{^-v^/VERBOSE^} (@code{gnatlink})
+@cindex @option{^-v^/VERBOSE^} (@command{gnatlink})
 Causes additional information to be output, including a full list of the
 included object files. This switch option is most useful when you want
 to see what set of object files are being used in the link step.
 
 @item ^-v -v^/VERBOSE/VERBOSE^
-@cindex @option{^-v -v^/VERBOSE/VERBOSE^} (@code{gnatlink})
+@cindex @option{^-v -v^/VERBOSE/VERBOSE^} (@command{gnatlink})
 Very verbose mode. Requests that the compiler operate in verbose mode when
 it compiles the binder file, and that the system linker run in verbose mode.
 
 @item ^-o ^/EXECUTABLE=^@var{exec-name}
-@cindex @option{^-o^/EXECUTABLE^} (@code{gnatlink})
+@cindex @option{^-o^/EXECUTABLE^} (@command{gnatlink})
 @var{exec-name} specifies an alternate name for the generated
 executable program. If this switch is omitted, the executable has the same
 name as the main unit. For example, @code{gnatlink try.ali} creates
@@ -7848,42 +8450,44 @@ an executable called @file{^try^TRY.EXE^}.
 
 @ifclear vms
 @item -b @var{target}
-@cindex @option{-b} (@code{gnatlink})
+@cindex @option{-b} (@command{gnatlink})
 Compile your program to run on @var{target}, which is the name of a
 system configuration. You must have a GNAT cross-compiler built if
 @var{target} is not the same as your host system.
 
 @item -B@var{dir}
-@cindex @option{-B} (@code{gnatlink})
+@cindex @option{-B} (@command{gnatlink})
 Load compiler executables (for example, @code{gnat1}, the Ada compiler)
 from @var{dir} instead of the default location. Only use this switch
 when multiple versions of the GNAT compiler are available. See the
-@code{gcc} manual page for further details. You would normally use the
+@command{gcc} manual page for further details. You would normally use the
 @option{-b} or @option{-V} switch instead.
 
 @item --GCC=@var{compiler_name}
-@cindex @option{--GCC=compiler_name} (@code{gnatlink})
+@cindex @option{--GCC=compiler_name} (@command{gnatlink})
 Program used for compiling the binder file. The default is
-`@code{gcc}'. You need to use quotes around @var{compiler_name} if
-@code{compiler_name} contains spaces or other separator characters. As
-an example @option{--GCC="foo -x -y"} will instruct @code{gnatlink} to use
-@code{foo -x -y} as your compiler. Note that switch @option{-c} is always
+@command{gcc}. You need to use quotes around @var{compiler_name} if
+@code{compiler_name} contains spaces or other separator characters.
+As an example @option{--GCC="foo -x -y"} will instruct @command{gnatlink} to
+use @code{foo -x -y} as your compiler. Note that switch @option{-c} is always
 inserted after your command name. Thus in the above example the compiler
-command that will be used by @code{gnatlink} will be @code{foo -c -x -y}.
-If several @option{--GCC=compiler_name} are used, only the last
-@var{compiler_name} is taken into account. However, all the additional
-switches are also taken into account. Thus,
+command that will be used by @command{gnatlink} will be @code{foo -c -x -y}.
+A limitation of this syntax is that the name and path name of the executable
+itself must not include any embedded spaces. If several
+@option{--GCC=compiler_name} are used, only the last @var{compiler_name}
+is taken into account. However, all the additional switches are also taken
+into account. Thus,
 @option{--GCC="foo -x -y" --GCC="bar -z -t"} is equivalent to
 @option{--GCC="bar -x -y -z -t"}.
 
 @item --LINK=@var{name}
-@cindex @option{--LINK=} (@code{gnatlink})
+@cindex @option{--LINK=} (@command{gnatlink})
 @var{name} is the name of the linker to be invoked. This is especially
 useful in mixed language programs since languages such as C++ require
 their own linker to be used. When this switch is omitted, the default
-name for the linker is (@file{gcc}). When this switch is used, the
-specified linker is called instead of (@file{gcc}) with exactly the same
-parameters that would have been passed to (@file{gcc}) so if the desired
+name for the linker is @command{gcc}. When this switch is used, the
+specified linker is called instead of @command{gcc} with exactly the same
+parameters that would have been passed to @command{gcc} so if the desired
 linker requires different parameters it is necessary to use a wrapper
 script that massages the parameters before invoking the real linker. It
 may be useful to control the exact invocation by using the verbose
@@ -7893,7 +8497,7 @@ switch.
 
 @ifset vms
 @item /DEBUG=TRACEBACK
-@cindex @code{/DEBUG=TRACEBACK} (@code{gnatlink})
+@cindex @code{/DEBUG=TRACEBACK} (@command{gnatlink})
 This qualifier causes sufficient information to be included in the
 executable file to allow a traceback, but does not include the full
 symbol information needed by the debugger.
@@ -7908,8 +8512,8 @@ Generate the executable file even if there are linker warnings.
 
 @item /NOSTART_FILES
 Don't link in the object file containing the ``main'' transfer address.
-Used when linking with a foreign language main program compiled with a
-Digital compiler.
+Used when linking with a foreign language main program compiled with an
+HP compiler.
 
 @item /STATIC
 Prefer linking with object libraries over sharable images, even without
@@ -7918,78 +8522,18 @@ Prefer linking with object libraries over sharable images, even without
 
 @end table
 
-@node Setting Stack Size from gnatlink
-@section Setting Stack Size from @code{gnatlink}
+@node The GNAT Make Program gnatmake
+@chapter The GNAT Make Program @command{gnatmake}
+@findex gnatmake
 
-@noindent
-Under Windows systems, it is possible to specify the program stack size from
-@code{gnatlink} using either:
-
-@itemize @bullet
-
-@item using @option{-Xlinker} linker option
-
-@smallexample
-$ gnatlink hello -Xlinker --stack=0x10000,0x1000
-@end smallexample
-
-This sets the stack reserve size to 0x10000 bytes and the stack commit
-size to 0x1000 bytes.
-
-@item using @option{-Wl} linker option
-
-@smallexample
-$ gnatlink hello -Wl,--stack=0x1000000
-@end smallexample
-
-This sets the stack reserve size to 0x1000000 bytes. Note that with
-@option{-Wl} option it is not possible to set the stack commit size
-because the coma is a separator for this option.
-
-@end itemize
-
-@node Setting Heap Size from gnatlink
-@section Setting Heap Size from @code{gnatlink}
-
-@noindent
-Under Windows systems, it is possible to specify the program heap size from
-@code{gnatlink} using either:
-
-@itemize @bullet
-
-@item using @option{-Xlinker} linker option
-
-@smallexample
-$ gnatlink hello -Xlinker --heap=0x10000,0x1000
-@end smallexample
-
-This sets the heap reserve size to 0x10000 bytes and the heap commit
-size to 0x1000 bytes.
-
-@item using @option{-Wl} linker option
-
-@smallexample
-$ gnatlink hello -Wl,--heap=0x1000000
-@end smallexample
-
-This sets the heap reserve size to 0x1000000 bytes. Note that with
-@option{-Wl} option it is not possible to set the heap commit size
-because the coma is a separator for this option.
-
-@end itemize
-
-@node The GNAT Make Program gnatmake
-@chapter The GNAT Make Program @code{gnatmake}
-@findex gnatmake
-
-@menu
-* Running gnatmake::
-* Switches for gnatmake::
-* Mode Switches for gnatmake::
-* Notes on the Command Line::
-* How gnatmake Works::
-* Examples of gnatmake Usage::
-@end menu
+@menu
+* Running gnatmake::
+* Switches for gnatmake::
+* Mode Switches for gnatmake::
+* Notes on the Command Line::
+* How gnatmake Works::
+* Examples of gnatmake Usage::
+@end menu
 @noindent
 A typical development cycle when working on an Ada program consists of
 the following steps:
@@ -8019,7 +8563,7 @@ recompiled. The dependency rules in Ada can be quite complex, especially
 in the presence of overloading, @code{use} clauses, generics and inlined
 subprograms.
 
-@code{gnatmake} automatically takes care of the third and fourth steps
+@command{gnatmake} automatically takes care of the third and fourth steps
 of this process. It determines which sources need to be compiled,
 compiles them, and binds and links the resulting object files.
 
@@ -8028,13 +8572,13 @@ accurately recomputed from the new sources. The source based approach of
 the GNAT compilation model makes this possible. This means that if
 changes to the source program cause corresponding changes in
 dependencies, they will always be tracked exactly correctly by
-@code{gnatmake}.
+@command{gnatmake}.
 
 @node Running gnatmake
-@section Running @code{gnatmake}
+@section Running @command{gnatmake}
 
 @noindent
-The usual form of the @code{gnatmake} command is
+The usual form of the @command{gnatmake} command is
 
 @smallexample
 $ gnatmake [@var{switches}] @var{file_name}
@@ -8050,74 +8594,89 @@ If @code{switches} are present, they can be placed before the first
 If @var{mode_switches} are present, they must always be placed after
 the last @var{file_name} and all @code{switches}.
 
-If you are using standard file extensions (.adb and .ads), then the
+If you are using standard file extensions (@file{.adb} and @file{.ads}), then the
 extension may be omitted from the @var{file_name} arguments. However, if
 you are using non-standard extensions, then it is required that the
 extension be given. A relative or absolute directory path can be
 specified in a @var{file_name}, in which case, the input source file will
 be searched for in the specified directory only. Otherwise, the input
 source file will first be searched in the directory where
-@code{gnatmake} was invoked and if it is not found, it will be search on
+@command{gnatmake} was invoked and if it is not found, it will be search on
 the source path of the compiler as described in
 @ref{Search Paths and the Run-Time Library (RTL)}.
 
-All @code{gnatmake} output (except when you specify
+All @command{gnatmake} output (except when you specify
 @option{^-M^/DEPENDENCIES_LIST^}) is to
 @file{stderr}. The output produced by the
 @option{^-M^/DEPENDENCIES_LIST^} switch is send to
 @file{stdout}.
 
 @node Switches for gnatmake
-@section Switches for @code{gnatmake}
+@section Switches for @command{gnatmake}
 
 @noindent
-You may specify any of the following switches to @code{gnatmake}:
+You may specify any of the following switches to @command{gnatmake}:
 
 @table @option
 @c !sort!
+
+@item --version
+@cindex @option{--version} @command{gnatmake}
+Display Copyright and version, then exit disregarding all other options.
+
+@item --help
+@cindex @option{--help} @command{gnatmake}
+If @option{--version} was not used, display usage, then exit disregarding
+all other options.
+
 @ifclear vms
 @item --GCC=@var{compiler_name}
-@cindex @option{--GCC=compiler_name} (@code{gnatmake})
-Program used for compiling. The default is `@code{gcc}'. You need to use
+@cindex @option{--GCC=compiler_name} (@command{gnatmake})
+Program used for compiling. The default is `@command{gcc}'. You need to use
 quotes around @var{compiler_name} if @code{compiler_name} contains
 spaces or other separator characters. As an example @option{--GCC="foo -x
--y"} will instruct @code{gnatmake} to use @code{foo -x -y} as your
-compiler. Note that switch @option{-c} is always inserted after your
-command name. Thus in the above example the compiler command that will
-be used by @code{gnatmake} will be @code{foo -c -x -y}.
-If several @option{--GCC=compiler_name} are used, only the last
-@var{compiler_name} is taken into account. However, all the additional
-switches are also taken into account. Thus,
+-y"} will instruct @command{gnatmake} to use @code{foo -x -y} as your
+compiler. A limitation of this syntax is that the name and path name of
+the executable itself must not include any embedded spaces. Note that
+switch @option{-c} is always inserted after your command name. Thus in the
+above example the compiler command that will be used by @command{gnatmake}
+will be @code{foo -c -x -y}. If several @option{--GCC=compiler_name} are
+used, only the last @var{compiler_name} is taken into account. However,
+all the additional switches are also taken into account. Thus,
 @option{--GCC="foo -x -y" --GCC="bar -z -t"} is equivalent to
 @option{--GCC="bar -x -y -z -t"}.
 
 @item --GNATBIND=@var{binder_name}
-@cindex @option{--GNATBIND=binder_name} (@code{gnatmake})
+@cindex @option{--GNATBIND=binder_name} (@command{gnatmake})
 Program used for binding. The default is `@code{gnatbind}'. You need to
 use quotes around @var{binder_name} if @var{binder_name} contains spaces
 or other separator characters. As an example @option{--GNATBIND="bar -x
--y"} will instruct @code{gnatmake} to use @code{bar -x -y} as your
-binder. Binder switches that are normally appended by @code{gnatmake} to
-`@code{gnatbind}' are now appended to the end of @code{bar -x -y}.
+-y"} will instruct @command{gnatmake} to use @code{bar -x -y} as your
+binder. Binder switches that are normally appended by @command{gnatmake}
+to `@code{gnatbind}' are now appended to the end of @code{bar -x -y}.
+A limitation of this syntax is that the name and path name of the executable
+itself must not include any embedded spaces.
 
 @item --GNATLINK=@var{linker_name}
-@cindex @option{--GNATLINK=linker_name} (@code{gnatmake})
-Program used for linking. The default is `@code{gnatlink}'. You need to
+@cindex @option{--GNATLINK=linker_name} (@command{gnatmake})
+Program used for linking. The default is `@command{gnatlink}'. You need to
 use quotes around @var{linker_name} if @var{linker_name} contains spaces
 or other separator characters. As an example @option{--GNATLINK="lan -x
--y"} will instruct @code{gnatmake} to use @code{lan -x -y} as your
-linker. Linker switches that are normally appended by @code{gnatmake} to
-`@code{gnatlink}' are now appended to the end of @code{lan -x -y}.
+-y"} will instruct @command{gnatmake} to use @code{lan -x -y} as your
+linker. Linker switches that are normally appended by @command{gnatmake} to
+`@command{gnatlink}' are now appended to the end of @code{lan -x -y}.
+A limitation of this syntax is that the name and path name of the executable
+itself must not include any embedded spaces.
 
 @end ifclear
 
 @item ^-a^/ALL_FILES^
-@cindex @option{^-a^/ALL_FILES^} (@code{gnatmake})
+@cindex @option{^-a^/ALL_FILES^} (@command{gnatmake})
 Consider all files in the make process, even the GNAT internal system
 files (for example, the predefined Ada library files), as well as any
 locked files. Locked files are files whose ALI file is write-protected.
 By default,
-@code{gnatmake} does not check these files,
+@command{gnatmake} does not check these files,
 because the assumption is that the GNAT internal files are properly up
 to date, and also that any write protected ALI files have been properly
 installed. Note that if there is an installation problem, such that one
@@ -8141,7 +8700,7 @@ the @code{/CHECKS=SUPPRESS_ALL /STYLE_CHECKS=GNAT} switch.
 @end ifset
 
 @item ^-b^/ACTIONS=BIND^
-@cindex @option{^-b^/ACTIONS=BIND^} (@code{gnatmake})
+@cindex @option{^-b^/ACTIONS=BIND^} (@command{gnatmake})
 Bind only. Can be combined with @option{^-c^/ACTIONS=COMPILE^} to do
 compilation and binding, but no link.
 Can be combined with @option{^-l^/ACTIONS=LINK^}
@@ -8153,23 +8712,23 @@ may be given without extension, with the source extension or, if no GNAT
 Project File is specified, with the ALI file extension.
 
 @item ^-c^/ACTIONS=COMPILE^
-@cindex @option{^-c^/ACTIONS=COMPILE^} (@code{gnatmake})
+@cindex @option{^-c^/ACTIONS=COMPILE^} (@command{gnatmake})
 Compile only. Do not perform binding, except when @option{^-b^/ACTIONS=BIND^}
 is also specified. Do not perform linking, except if both
 @option{^-b^/ACTIONS=BIND^} and
  @option{^-l^/ACTIONS=LINK^} are also specified.
 If the root unit specified by @var{file_name} is not a main unit, this is the
-default. Otherwise @code{gnatmake} will attempt binding and linking
+default. Otherwise @command{gnatmake} will attempt binding and linking
 unless all objects are up to date and the executable is more recent than
 the objects.
 
 @item ^-C^/MAPPING^
-@cindex @option{^-C^/MAPPING^} (@code{gnatmake})
+@cindex @option{^-C^/MAPPING^} (@command{gnatmake})
 Use a temporary mapping file. A mapping file is a way to communicate to the
 compiler two mappings: from unit names to file names (without any directory
 information) and from file names to path names (with full directory
 information). These mappings are used by the compiler to short-circuit the path
-search. When @code{gnatmake} is invoked with this switch, it will create
+search. When @command{gnatmake} is invoked with this switch, it will create
 a temporary mapping file, initially populated by the project manager,
 if @option{^-P^/PROJECT_FILE^} is used, otherwise initially empty.
 Each invocation of the compiler will add the newly accessed sources to the
@@ -8177,7 +8736,7 @@ mapping file. This will improve the source search during the next invocation
 of the compiler.
 
 @item ^-C=^/USE_MAPPING_FILE=^@var{file}
-@cindex @option{^-C=^/USE_MAPPING^} (@code{gnatmake})
+@cindex @option{^-C=^/USE_MAPPING^} (@command{gnatmake})
 Use a specific mapping file. The file, specified as a path name (absolute or
 relative) by this switch, should already exist, otherwise the switch is
 ineffective. The specified mapping file will be communicated to the compiler.
@@ -8186,7 +8745,7 @@ This switch is not compatible with a project file
 (^-j^/PROCESSES=^nnn, when nnn is greater than 1).
 
 @item ^-D ^/DIRECTORY_OBJECTS=^@var{dir}
-@cindex @option{^-D^/DIRECTORY_OBJECTS^} (@code{gnatmake})
+@cindex @option{^-D^/DIRECTORY_OBJECTS^} (@command{gnatmake})
 Put all object files and ALI file in directory @var{dir}.
 If the @option{^-D^/DIRECTORY_OBJECTS^} switch is not used, all object files
 and ALI files go in the current working directory.
@@ -8195,84 +8754,95 @@ This switch cannot be used when using a project file.
 
 @ifclear vms
 @item -eL
-@cindex @option{-eL} (@code{gnatmake})
+@cindex @option{-eL} (@command{gnatmake})
 Follow all symbolic links when processing project files.
 @end ifclear
 
+@item ^-eS^/STANDARD_OUTPUT_FOR_COMMANDS^
+@cindex @option{^-eS^/STANDARD_OUTPUT_FOR_COMMANDS^} (@command{gnatmake})
+Output the commands for the compiler, the binder and the linker
+on ^standard output^SYS$OUTPUT^,
+instead of ^standard error^SYS$ERROR^.
+
 @item ^-f^/FORCE_COMPILE^
-@cindex @option{^-f^/FORCE_COMPILE^} (@code{gnatmake})
+@cindex @option{^-f^/FORCE_COMPILE^} (@command{gnatmake})
 Force recompilations. Recompile all sources, even though some object
 files may be up to date, but don't recompile predefined or GNAT internal
 files or locked files (files with a write-protected ALI file),
 unless the @option{^-a^/ALL_FILES^} switch is also specified.
 
 @item ^-F^/FULL_PATH_IN_BRIEF_MESSAGES^
-@cindex @option{^-F^/FULL_PATH_IN_BRIEF_MESSAGES^} (@code{gnatmake})
+@cindex @option{^-F^/FULL_PATH_IN_BRIEF_MESSAGES^} (@command{gnatmake})
 When using project files, if some errors or warnings are detected during
 parsing and verbose mode is not in effect (no use of switch
 ^-v^/VERBOSE^), then error lines start with the full path name of the project
 file, rather than its simple file name.
 
+@item ^-g^/DEBUG^
+@cindex @option{^-g^/DEBUG^} (@command{gnatmake})
+Enable debugging. This switch is simply passed to the compiler and to the
+linker.
+
 @item ^-i^/IN_PLACE^
-@cindex @option{^-i^/IN_PLACE^} (@code{gnatmake})
-In normal mode, @code{gnatmake} compiles all object files and ALI files
+@cindex @option{^-i^/IN_PLACE^} (@command{gnatmake})
+In normal mode, @command{gnatmake} compiles all object files and ALI files
 into the current directory. If the @option{^-i^/IN_PLACE^} switch is used,
 then instead object files and ALI files that already exist are overwritten
 in place. This means that once a large project is organized into separate
-directories in the desired manner, then @code{gnatmake} will automatically
+directories in the desired manner, then @command{gnatmake} will automatically
 maintain and update this organization. If no ALI files are found on the
 Ada object path (@ref{Search Paths and the Run-Time Library (RTL)}),
 the new object and ALI files are created in the
 directory containing the source being compiled. If another organization
 is desired, where objects and sources are kept in different directories,
 a useful technique is to create dummy ALI files in the desired directories.
-When detecting such a dummy file, @code{gnatmake} will be forced to recompile
-the corresponding source file, and it will be put the resulting object
-and ALI files in the directory where it found the dummy file.
+When detecting such a dummy file, @command{gnatmake} will be forced to
+recompile the corresponding source file, and it will be put the resulting
+object and ALI files in the directory where it found the dummy file.
 
 @item ^-j^/PROCESSES=^@var{n}
-@cindex @option{^-j^/PROCESSES^} (@code{gnatmake})
+@cindex @option{^-j^/PROCESSES^} (@command{gnatmake})
 @cindex Parallel make
 Use @var{n} processes to carry out the (re)compilations. On a
 multiprocessor machine compilations will occur in parallel. In the
 event of compilation errors, messages from various compilations might
-get interspersed (but @code{gnatmake} will give you the full ordered
+get interspersed (but @command{gnatmake} will give you the full ordered
 list of failing compiles at the end). If this is problematic, rerun
 the make process with n set to 1 to get a clean list of messages.
 
 @item ^-k^/CONTINUE_ON_ERROR^
-@cindex @option{^-k^/CONTINUE_ON_ERROR^} (@code{gnatmake})
+@cindex @option{^-k^/CONTINUE_ON_ERROR^} (@command{gnatmake})
 Keep going. Continue as much as possible after a compilation error. To
 ease the programmer's task in case of compilation errors, the list of
-sources for which the compile fails is given when @code{gnatmake}
+sources for which the compile fails is given when @command{gnatmake}
 terminates.
 
-If @code{gnatmake} is invoked with several @file{file_names} and with this
+If @command{gnatmake} is invoked with several @file{file_names} and with this
 switch, if there are compilation errors when building an executable,
-@code{gnatmake} will not attempt to build the following executables.
+@command{gnatmake} will not attempt to build the following executables.
 
 @item ^-l^/ACTIONS=LINK^
-@cindex @option{^-l^/ACTIONS=LINK^} (@code{gnatmake})
+@cindex @option{^-l^/ACTIONS=LINK^} (@command{gnatmake})
 Link only. Can be combined with @option{^-b^/ACTIONS=BIND^} to binding
 and linking. Linking will not be performed if combined with
 @option{^-c^/ACTIONS=COMPILE^}
 but not with @option{^-b^/ACTIONS=BIND^}.
 When not combined with @option{^-b^/ACTIONS=BIND^}
 all the units in the closure of the main program must have been previously
-compiled and must be up to date, and the main program need to have been bound.
+compiled and must be up to date, and the main program needs to have been bound.
 The root unit specified by @var{file_name}
 may be given without extension, with the source extension or, if no GNAT
 Project File is specified, with the ALI file extension.
 
 @item ^-m^/MINIMAL_RECOMPILATION^
-@cindex @option{^-m^/MINIMAL_RECOMPILATION^} (@code{gnatmake})
-Specifies that the minimum necessary amount of recompilations
-be performed. In this mode @code{gnatmake} ignores time
+@cindex @option{^-m^/MINIMAL_RECOMPILATION^} (@command{gnatmake})
+Specify that the minimum necessary amount of recompilations
+be performed. In this mode @command{gnatmake} ignores time
 stamp differences when the only
 modifications to a source file consist in adding/removing comments,
 empty lines, spaces or tabs. This means that if you have changed the
 comments in a source file or have simply reformatted it, using this
-switch will tell gnatmake not to recompile files that depend on it
+switch will tell @command{gnatmake} not to recompile files that depend on it
 (provided other sources on which these files depend have undergone no
 semantic modifications). Note that the debugging information may be
 out of date with respect to the sources if the @option{-m} switch causes
@@ -8281,7 +8851,7 @@ trade-off between compilation time and accurate debugging information.
 
 @item ^-M^/DEPENDENCIES_LIST^
 @cindex Dependencies, producing list
-@cindex @option{^-M^/DEPENDENCIES_LIST^} (@code{gnatmake})
+@cindex @option{^-M^/DEPENDENCIES_LIST^} (@command{gnatmake})
 Check if all objects are up to date. If they are, output the object
 dependences to @file{stdout} in a form that can be directly exploited in
 a @file{Makefile}. By default, each source file is prefixed with its
@@ -8302,7 +8872,7 @@ dependencies of the objects in external Ada libraries (see switch
 are never reported.
 
 @item ^-n^/DO_OBJECT_CHECK^
-@cindex @option{^-n^/DO_OBJECT_CHECK^} (@code{gnatmake})
+@cindex @option{^-n^/DO_OBJECT_CHECK^} (@command{gnatmake})
 Don't compile, bind, or link. Checks if all objects are up to date.
 If they are not, the full name of the first file that needs to be
 recompiled is printed.
@@ -8310,27 +8880,33 @@ Repeated use of this option, followed by compiling the indicated source
 file, will eventually result in recompiling all required units.
 
 @item ^-o ^/EXECUTABLE=^@var{exec_name}
-@cindex @option{^-o^/EXECUTABLE^} (@code{gnatmake})
+@cindex @option{^-o^/EXECUTABLE^} (@command{gnatmake})
 Output executable name. The name of the final executable program will be
 @var{exec_name}. If the @option{^-o^/EXECUTABLE^} switch is omitted the default
 name for the executable will be the name of the input file in appropriate form
 for an executable file on the host system.
 
-This switch cannot be used when invoking @code{gnatmake} with several
+This switch cannot be used when invoking @command{gnatmake} with several
 @file{file_names}.
 
+@item ^-p or --create-missing-dirs^/CREATE_MISSING_DIRS^
+@cindex @option{^-p^/CREATE_MISSING_DIRS^} (@command{gnatmake})
+When using project files (^-P^/PROJECT_FILE=^@var{project}), create
+automatically missing object directories, library directories and exec
+directories.
+
 @item ^-P^/PROJECT_FILE=^@var{project}
-@cindex @option{^-P^/PROJECT_FILE^} (@code{gnatmake})
+@cindex @option{^-P^/PROJECT_FILE^} (@command{gnatmake})
 Use project file @var{project}. Only one such switch can be used.
-See @ref{gnatmake and Project Files}.
+@xref{gnatmake and Project Files}.
 
 @item ^-q^/QUIET^
-@cindex @option{^-q^/QUIET^} (@code{gnatmake})
+@cindex @option{^-q^/QUIET^} (@command{gnatmake})
 Quiet. When this flag is not set, the commands carried out by
-@code{gnatmake} are displayed.
+@command{gnatmake} are displayed.
 
 @item ^-s^/SWITCH_CHECK/^
-@cindex @option{^-s^/SWITCH_CHECK^} (@code{gnatmake})
+@cindex @option{^-s^/SWITCH_CHECK^} (@command{gnatmake})
 Recompile if compiler switches have changed since last compilation.
 All compiler switches but -I and -o are taken into account in the
 following way:
@@ -8342,31 +8918,43 @@ is equivalent to @option{-O -g}.
 This switch is recommended when Integrated Preprocessing is used.
 
 @item ^-u^/UNIQUE^
-@cindex @option{^-u^/UNIQUE^} (@code{gnatmake})
+@cindex @option{^-u^/UNIQUE^} (@command{gnatmake})
 Unique. Recompile at most the main files. It implies -c. Combined with
 -f, it is equivalent to calling the compiler directly. Note that using
 ^-u^/UNIQUE^ with a project file and no main has a special meaning
-(see @ref{Project Files and Main Subprograms}).
+(@pxref{Project Files and Main Subprograms}).
 
 @item ^-U^/ALL_PROJECTS^
-@cindex @option{^-U^/ALL_PROJECTS^} (@code{gnatmake})
+@cindex @option{^-U^/ALL_PROJECTS^} (@command{gnatmake})
 When used without a project file or with one or several mains on the command
 line, is equivalent to ^-u^/UNIQUE^. When used with a project file and no main
 on the command line, all sources of all project files are checked and compiled
 if not up to date, and libraries are rebuilt, if necessary.
 
 @item ^-v^/REASONS^
-@cindex @option{^-v^/REASONS^} (@code{gnatmake})
-Verbose. Displays the reason for all recompilations @code{gnatmake}
-decides are necessary.
+@cindex @option{^-v^/REASONS^} (@command{gnatmake})
+Verbose. Display the reason for all recompilations @command{gnatmake}
+decides are necessary, with the highest verbosity level.
+
+@item ^-vl^/LOW_VERBOSITY^
+@cindex @option{^-vl^/LOW_VERBOSITY^} (@command{gnatmake})
+Verbosity level Low. Display fewer lines than in verbosity Medium.
+
+@item ^-vm^/MEDIUM_VERBOSITY^
+@cindex @option{^-vm^/MEDIUM_VERBOSITY^} (@command{gnatmake})
+Verbosity level Medium. Potentially display fewer lines than in verbosity High.
+
+@item ^-vh^/HIGH_VERBOSITY^
+@cindex @option{^-vm^/HIGH_VERBOSITY^} (@command{gnatmake})
+Verbosity level High. Equivalent to ^-v^/REASONS^.
 
 @item ^-vP^/MESSAGES_PROJECT_FILE=^@emph{x}
-Indicates the verbosity of the parsing of GNAT project files.
-See @ref{Switches Related to Project Files}.
+Indicate the verbosity of the parsing of GNAT project files.
+@xref{Switches Related to Project Files}.
 
 @item ^-x^/NON_PROJECT_UNIT_COMPILATION^
-@cindex @option{^-x^/NON_PROJECT_UNIT_COMPILATION^} (@code{gnatmake})
-Indicates that sources that are not part of any Project File may be compiled.
+@cindex @option{^-x^/NON_PROJECT_UNIT_COMPILATION^} (@command{gnatmake})
+Indicate that sources that are not part of any Project File may be compiled.
 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
@@ -8374,30 +8962,25 @@ object directory of the main Project. The compilation switches used will only
 be those specified on the command line.
 
 @item ^-X^/EXTERNAL_REFERENCE=^@var{name=value}
-Indicates that external variable @var{name} has the value @var{value}.
+Indicate 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.
-See @ref{Switches Related to Project Files}.
+@xref{Switches Related to Project Files}.
 
 @item ^-z^/NOMAIN^
-@cindex @option{^-z^/NOMAIN^} (@code{gnatmake})
+@cindex @option{^-z^/NOMAIN^} (@command{gnatmake})
 No main subprogram. Bind and link the program even if the unit name
 given on the command line is a package name. The resulting executable
 will execute the elaboration routines of the package and its closure,
 then the finalization routines.
 
-@item ^-g^/DEBUG^
-@cindex @option{^-g^/DEBUG^} (@code{gnatmake})
-Enable debugging. This switch is simply passed to the compiler and to the
-linker.
-
 @end table
 
 @table @asis
-@item @code{gcc} @asis{switches}
+@item @command{gcc} @asis{switches}
 @ifclear vms
-Any uppercase or multi-character switch that is not a @code{gnatmake} switch
-is passed to @code{gcc} (e.g. @option{-O}, @option{-gnato,} etc.)
+Any uppercase or multi-character switch that is not a @command{gnatmake} switch
+is passed to @command{gcc} (e.g. @option{-O}, @option{-gnato,} etc.)
 @end ifclear
 @ifset vms
 Any qualifier that cannot be recognized as a qualifier for @code{GNAT MAKE}
@@ -8413,15 +8996,15 @@ Source and library search path switches:
 @table @option
 @c !sort!
 @item ^-aI^/SOURCE_SEARCH=^@var{dir}
-@cindex @option{^-aI^/SOURCE_SEARCH^} (@code{gnatmake})
+@cindex @option{^-aI^/SOURCE_SEARCH^} (@command{gnatmake})
 When looking for source files also look in directory @var{dir}.
 The order in which source files search is undertaken is
 described in @ref{Search Paths and the Run-Time Library (RTL)}.
 
 @item ^-aL^/SKIP_MISSING=^@var{dir}
-@cindex @option{^-aL^/SKIP_MISSING^} (@code{gnatmake})
+@cindex @option{^-aL^/SKIP_MISSING^} (@command{gnatmake})
 Consider @var{dir} as being an externally provided Ada library.
-Instructs @code{gnatmake} to skip compilation units whose @file{.ALI}
+Instructs @command{gnatmake} to skip compilation units whose @file{.ALI}
 files have been located in directory @var{dir}. This allows you to have
 missing bodies for the units in @var{dir} and to ignore out of date bodies
 for the same units. You still need to specify
@@ -8429,37 +9012,37 @@ the location of the specs for these units by using the switches
 @option{^-aI^/SOURCE_SEARCH=^@var{dir}}
 or @option{^-I^/SEARCH=^@var{dir}}.
 Note: this switch is provided for compatibility with previous versions
-of @code{gnatmake}. The easier method of causing standard libraries
+of @command{gnatmake}. The easier method of causing standard libraries
 to be excluded from consideration is to write-protect the corresponding
 ALI files.
 
 @item ^-aO^/OBJECT_SEARCH=^@var{dir}
-@cindex @option{^-aO^/OBJECT_SEARCH^} (@code{gnatmake})
+@cindex @option{^-aO^/OBJECT_SEARCH^} (@command{gnatmake})
 When searching for library and object files, look in directory
 @var{dir}. The order in which library files are searched is described in
 @ref{Search Paths for gnatbind}.
 
 @item ^-A^/CONDITIONAL_SOURCE_SEARCH=^@var{dir}
-@cindex Search paths, for @code{gnatmake}
-@cindex @option{^-A^/CONDITIONAL_SOURCE_SEARCH^} (@code{gnatmake})
+@cindex Search paths, for @command{gnatmake}
+@cindex @option{^-A^/CONDITIONAL_SOURCE_SEARCH^} (@command{gnatmake})
 Equivalent to @option{^-aL^/SKIP_MISSING=^@var{dir}
 ^-aI^/SOURCE_SEARCH=^@var{dir}}.
 
 @item ^-I^/SEARCH=^@var{dir}
-@cindex @option{^-I^/SEARCH^} (@code{gnatmake})
+@cindex @option{^-I^/SEARCH^} (@command{gnatmake})
 Equivalent to @option{^-aO^/OBJECT_SEARCH=^@var{dir}
 ^-aI^/SOURCE_SEARCH=^@var{dir}}.
 
 @item ^-I-^/NOCURRENT_DIRECTORY^
-@cindex @option{^-I-^/NOCURRENT_DIRECTORY^} (@code{gnatmake})
+@cindex @option{^-I-^/NOCURRENT_DIRECTORY^} (@command{gnatmake})
 @cindex Source files, suppressing search
 Do not look for source files in the directory containing the source
 file named in the command line.
 Do not look for ALI or object files in the directory
-where @code{gnatmake} was invoked.
+where @command{gnatmake} was invoked.
 
 @item ^-L^/LIBRARY_SEARCH=^@var{dir}
-@cindex @option{^-L^/LIBRARY_SEARCH^} (@code{gnatmake})
+@cindex @option{^-L^/LIBRARY_SEARCH^} (@command{gnatmake})
 @cindex Linker libraries
 Add directory @var{dir} to the list of directories in which the linker
 will search for libraries. This is equivalent to
@@ -8470,15 +9053,15 @@ set in the registry are not searched for.
 @end ifclear
 
 @item -nostdinc
-@cindex @option{-nostdinc} (@code{gnatmake})
+@cindex @option{-nostdinc} (@command{gnatmake})
 Do not look for source files in the system default directory.
 
 @item -nostdlib
-@cindex @option{-nostdlib} (@code{gnatmake})
+@cindex @option{-nostdlib} (@command{gnatmake})
 Do not look for library files in the system default directory.
 
 @item --RTS=@var{rts-path}
-@cindex @option{--RTS} (@code{gnatmake})
+@cindex @option{--RTS} (@command{gnatmake})
 Specifies the default location of the runtime library. GNAT looks for the
 runtime
 in the following directories, and stops as soon as a valid runtime is found
@@ -8499,7 +9082,7 @@ The selected path is handled like a normal RTS path.
 @end table
 
 @node Mode Switches for gnatmake
-@section Mode Switches for @code{gnatmake}
+@section Mode Switches for @command{gnatmake}
 
 @noindent
 The mode switches (referred to as @code{mode_switches}) allow the
@@ -8512,26 +9095,26 @@ designated component of GNAT.
 @table @option
 @c !sort!
 @item -cargs @var{switches}
-@cindex @option{-cargs} (@code{gnatmake})
+@cindex @option{-cargs} (@command{gnatmake})
 Compiler switches. Here @var{switches} is a list of switches
-that are valid switches for @code{gcc}. They will be passed on to
-all compile steps performed by @code{gnatmake}.
+that are valid switches for @command{gcc}. They will be passed on to
+all compile steps performed by @command{gnatmake}.
 
 @item -bargs @var{switches}
-@cindex @option{-bargs} (@code{gnatmake})
+@cindex @option{-bargs} (@command{gnatmake})
 Binder switches. Here @var{switches} is a list of switches
 that are valid switches for @code{gnatbind}. They will be passed on to
-all bind steps performed by @code{gnatmake}.
+all bind steps performed by @command{gnatmake}.
 
 @item -largs @var{switches}
-@cindex @option{-largs} (@code{gnatmake})
+@cindex @option{-largs} (@command{gnatmake})
 Linker switches. Here @var{switches} is a list of switches
-that are valid switches for @code{gnatlink}. They will be passed on to
-all link steps performed by @code{gnatmake}.
+that are valid switches for @command{gnatlink}. They will be passed on to
+all link steps performed by @command{gnatmake}.
 
 @item -margs @var{switches}
-@cindex @option{-margs} (@code{gnatmake})
-Make switches. The switches are directly interpreted by @code{gnatmake},
+@cindex @option{-margs} (@command{gnatmake})
+Make switches. The switches are directly interpreted by @command{gnatmake},
 regardless of any previous occurrence of @option{-cargs}, @option{-bargs}
 or @option{-largs}.
 @end table
@@ -8541,25 +9124,25 @@ or @option{-largs}.
 
 @noindent
 This section contains some additional useful notes on the operation
-of the @code{gnatmake} command.
+of the @command{gnatmake} command.
 
 @itemize @bullet
 @item
-@cindex Recompilation, by @code{gnatmake}
-If @code{gnatmake} finds no ALI files, it recompiles the main program
+@cindex Recompilation, by @command{gnatmake}
+If @command{gnatmake} finds no ALI files, it recompiles the main program
 and all other units required by the main program.
-This means that @code{gnatmake}
+This means that @command{gnatmake}
 can be used for the initial compile, as well as during subsequent steps of
 the development cycle.
 
 @item
 If you enter @code{gnatmake @var{file}.adb}, where @file{@var{file}.adb}
-is a subunit or body of a generic unit, @code{gnatmake} recompiles
+is a subunit or body of a generic unit, @command{gnatmake} recompiles
 @file{@var{file}.adb} (because it finds no ALI) and stops, issuing a
 warning.
 
 @item
-In @code{gnatmake} the switch @option{^-I^/SEARCH^}
+In @command{gnatmake} the switch @option{^-I^/SEARCH^}
 is used to specify both source and
 library file paths. Use @option{^-aI^/SOURCE_SEARCH^}
 instead if you just want to specify
@@ -8568,21 +9151,14 @@ if you want to specify library paths
 only.
 
 @item
-@code{gnatmake} examines both an ALI file and its corresponding object file
-for consistency. If an ALI is more recent than its corresponding object,
-or if the object file is missing, the corresponding source will be recompiled.
-Note that @code{gnatmake} expects an ALI and the corresponding object file
-to be in the same directory.
-
-@item
-@code{gnatmake} will ignore any files whose ALI file is write-protected.
+@command{gnatmake} will ignore any files whose ALI file is write-protected.
 This may conveniently be used to exclude standard libraries from
 consideration and in particular it means that the use of the
 @option{^-f^/FORCE_COMPILE^} switch will not recompile these files
 unless @option{^-a^/ALL_FILES^} is also specified.
 
 @item
-@code{gnatmake} has been designed to make the use of Ada libraries
+@command{gnatmake} has been designed to make the use of Ada libraries
 particularly convenient. Assume you have an Ada library organized
 as follows: @i{^obj-dir^[OBJ_DIR]^} contains the objects and ALI files for
 of your Ada compilation units,
@@ -8601,9 +9177,9 @@ $ gnatmake /SOURCE_SEARCH=@i{[INCLUDE_DIR]}
 @end smallexample
 
 @item
-Using @code{gnatmake} along with the
+Using @command{gnatmake} along with the
 @option{^-m (minimal recompilation)^/MINIMAL_RECOMPILATION^}
-switch provides a mechanism for avoiding unnecessary rcompilations. Using
+switch provides a mechanism for avoiding unnecessary recompilations. Using
 this switch,
 you can update the comments/format of your
 source files without having to recompile everything. Note, however, that
@@ -8617,31 +9193,31 @@ that the debugging information may be out of date.
 @end itemize
 
 @node How gnatmake Works
-@section How @code{gnatmake} Works
+@section How @command{gnatmake} Works
 
 @noindent
-Generally @code{gnatmake} automatically performs all necessary
+Generally @command{gnatmake} automatically performs all necessary
 recompilations and you don't need to worry about how it works. However,
-it may be useful to have some basic understanding of the @code{gnatmake}
+it may be useful to have some basic understanding of the @command{gnatmake}
 approach and in particular to understand how it uses the results of
 previous compilations without incorrectly depending on them.
 
 First a definition: an object file is considered @dfn{up to date} if the
-corresponding ALI file exists and its time stamp predates that of the
-object file and if all the source files listed in the
+corresponding ALI file exists and if all the source files listed in the
 dependency section of this ALI file have time stamps matching those in
 the ALI file. This means that neither the source file itself nor any
 files that it depends on have been modified, and hence there is no need
 to recompile this file.
 
-@code{gnatmake} works by first checking if the specified main unit is up
+@command{gnatmake} works by first checking if the specified main unit is up
 to date. If so, no compilations are required for the main unit. If not,
-@code{gnatmake} compiles the main program to build a new ALI file that
+@command{gnatmake} compiles the main program to build a new ALI file that
 reflects the latest sources. Then the ALI file of the main unit is
 examined to find all the source files on which the main program depends,
-and @code{gnatmake} recursively applies the above procedure on all these files.
+and @command{gnatmake} recursively applies the above procedure on all these
+files.
 
-This process ensures that @code{gnatmake} only trusts the dependencies
+This process ensures that @command{gnatmake} only trusts the dependencies
 in an existing ALI file if they are known to be correct. Otherwise it
 always recompiles to determine a new, guaranteed accurate set of
 dependencies. As a result the program is compiled ``upside down'' from what may
@@ -8649,20 +9225,21 @@ be more familiar as the required order of compilation in some other Ada
 systems. In particular, clients are compiled before the units on which
 they depend. The ability of GNAT to compile in any order is critical in
 allowing an order of compilation to be chosen that guarantees that
-@code{gnatmake} will recompute a correct set of new dependencies if
+@command{gnatmake} will recompute a correct set of new dependencies if
 necessary.
 
-When invoking @code{gnatmake} with several @var{file_names}, if a unit is
+When invoking @command{gnatmake} with several @var{file_names}, if a unit is
 imported by several of the executables, it will be recompiled at most once.
 
 Note: when using non-standard naming conventions
-(See @ref{Using Other File Names}), changing through a configuration pragmas
-file the version of a source and invoking @code{gnatmake} to recompile may
+(@pxref{Using Other File Names}), changing through a configuration pragmas
+file the version of a source and invoking @command{gnatmake} to recompile may
 have no effect, if the previous version of the source is still accessible
-by @code{gnatmake}. It may be necessary to use the switch ^-f^/FORCE_COMPILE^.
+by @command{gnatmake}. It may be necessary to use the switch
+^-f^/FORCE_COMPILE^.
 
 @node Examples of gnatmake Usage
-@section Examples of @code{gnatmake} Usage
+@section Examples of @command{gnatmake} Usage
 
 @table @code
 @item gnatmake hello.adb
@@ -8691,11 +9268,10 @@ and @file{^main3^MAIN3.EXE^}.
 Compile all files necessary to bind and link the main program unit
 @code{Main_Unit} (from file @file{main_unit.adb}). All compilations will
 be done with optimization level 2 and the order of elaboration will be
-listed by the binder. @code{gnatmake} will operate in quiet mode, not
+listed by the binder. @command{gnatmake} will operate in quiet mode, not
 displaying commands it is executing.
 @end table
 
-
 @c *************************
 @node Improving Performance
 @chapter Improving Performance
@@ -8705,17 +9281,20 @@ displaying commands it is executing.
 This chapter presents several topics related to program performance.
 It first describes some of the tradeoffs that need to be considered
 and some of the techniques for making your program run faster.
-It then documents the @command{gnatelim} tool, which can reduce
-the size of program executables.
+It then documents the @command{gnatelim} tool and unused subprogram/data
+elimination feature, which can reduce the size of program executables.
+
+Note: to invoke @command{gnatelim} with a project file, use the @code{gnat}
+driver (see @ref{The GNAT Driver and Project Files}).
 
 @ifnottex
 @menu
 * Performance Considerations::
-* Reducing the Size of Ada Executables with gnatelim::
+* Reducing Size of Ada Executables with gnatelim::
+* Reducing Size of Executables with unused subprogram/data elimination::
 @end menu
 @end ifnottex
 
-
 @c *****************************
 @node Performance Considerations
 @section Performance Considerations
@@ -8765,7 +9344,9 @@ some guidelines on debugging optimized code.
 * Optimization Levels::
 * Debugging Optimized Code::
 * Inlining of Subprograms::
+* Other Optimization Switches::
 * Optimization and Strict Aliasing::
+
 @ifset vms
 * Coverage Analysis::
 @end ifset
@@ -8779,8 +9360,8 @@ By default, GNAT generates all run-time checks, except arithmetic overflow
 checking for integer operations and checks for access before elaboration on
 subprogram calls. The latter are not required in default mode, because all
 necessary checking is done at compile time.
-@cindex @option{-gnatp} (@code{gcc})
-@cindex @option{-gnato} (@code{gcc})
+@cindex @option{-gnatp} (@command{gcc})
+@cindex @option{-gnato} (@command{gcc})
 Two gnat switches, @option{-gnatp} and @option{-gnato} allow this default to
 be modified. @xref{Run-Time Checks}.
 
@@ -8834,13 +9415,13 @@ exception handlers are used. The reason is that certain sections of code
 have to be marked as non-abortable.
 
 If you use neither the @code{abort} statement, nor asynchronous transfer
-of control (@code{select .. then abort}), then this distributed overhead
+of control (@code{select @dots{} then abort}), then this distributed overhead
 is removed, which may have a general positive effect in improving
 overall performance.  Especially code involving frequent use of tasking
 constructs and controlled types will show much improved performance.
 The relevant restrictions pragmas are
 
-@smallexample
+@smallexample @c ada
    pragma Restrictions (No_Abort_Statements);
    pragma Restrictions (Max_Asynchronous_Select_Nesting => 0);
 @end smallexample
@@ -8852,7 +9433,7 @@ possibility of an immediate abort at any point.
 
 @node Optimization Levels
 @subsection Optimization Levels
-@cindex @option{^-O^/OPTIMIZE^} (@code{gcc})
+@cindex @option{^-O^/OPTIMIZE^} (@command{gcc})
 
 @noindent
 The default is optimization off. This results in the fastest compile
@@ -8860,12 +9441,13 @@ times, but GNAT makes absolutely no attempt to optimize, and the
 generated programs are considerably larger and slower than when
 optimization is enabled. You can use the
 @ifclear vms
-@option{-O@var{n}} switch, where @var{n} is an integer from 0 to 3,
+@option{-O} switch (the permitted forms are @option{-O0}, @option{-O1}
+@option{-O2}, @option{-O3}, and @option{-Os})
 @end ifclear
 @ifset vms
 @code{OPTIMIZE} qualifier
 @end ifset
-to @code{gcc} to control the optimization level:
+to @command{gcc} to control the optimization level:
 
 @table @option
 @item ^-O0^/OPTIMIZE=NONE^
@@ -8873,8 +9455,16 @@ No optimization (the default);
 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
+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
+gcc and other compilers should be kept in mind when doing
+performance comparisons.
+
 @item ^-O1^/OPTIMIZE=SOME^
-Medium level optimization;
+Moderate optimization;
 optimizes reasonably well but does not
 degrade compilation time significantly.
 
@@ -8890,6 +9480,9 @@ the slowest compilation time.
 Full optimization as in @option{-O2},
 and also attempts automatic inlining of small
 subprograms within a unit (@pxref{Inlining of Subprograms}).
+
+@item ^-Os^/OPTIMIZE=SPACE^
+Optimize space usage of resulting program.
 @end table
 
 @noindent
@@ -8900,6 +9493,10 @@ 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.
@@ -8918,8 +9515,7 @@ levels.
 Note regarding the use of @option{-O3}: The use of this optimization level
 is generally discouraged with GNAT, since it often results in larger
 executables which run more slowly. See further discussion of this point
-in @pxref{Inlining of Subprograms}.
-
+in @ref{Inlining of Subprograms}.
 
 @node Debugging Optimized Code
 @subsection Debugging Optimized Code
@@ -8929,7 +9525,7 @@ in @pxref{Inlining of Subprograms}.
 @noindent
 Although it is possible to do a reasonable amount of debugging at
 @ifclear vms
-non-zero optimization levels,
+nonzero optimization levels,
 the higher the level the more likely that
 @end ifclear
 @ifset vms
@@ -8945,7 +9541,7 @@ Explicit temporary variables that you code might be eliminated at
 ^level^setting^ @option{-O1} or higher.
 
 The use of the @option{^-g^/DEBUG^} switch,
-@cindex @option{^-g^/DEBUG^} (@code{gcc})
+@cindex @option{^-g^/DEBUG^} (@command{gcc})
 which is needed for source-level debugging,
 affects the size of the program executable on disk,
 and indeed the debugging information can be quite large.
@@ -9049,7 +9645,6 @@ on the resulting executable,
 which removes both debugging information and global symbols.
 @end ifclear
 
-
 @node Inlining of Subprograms
 @subsection Inlining of Subprograms
 
@@ -9063,7 +9658,7 @@ 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 @code{gcc}
+and not contain nested subprograms or anything else that @command{gcc}
 cannot support in inlined subprograms.
 
 @item
@@ -9079,8 +9674,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
@@ -9088,7 +9683,7 @@ 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 @code{gcc} cannot
+and not contain nested subprograms or anything else @command{gcc} cannot
 support in inlined subprograms.
 
 @item
@@ -9098,11 +9693,16 @@ The call appears in a body (not in a package spec).
 There is a @code{pragma Inline} for the subprogram.
 
 @item
-@cindex @option{-gnatn} (@code{gcc})
+@cindex @option{-gnatn} (@command{gcc})
 The @option{^-gnatn^/INLINE^} switch
-is used in the @code{gcc} command line
+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:
 
@@ -9113,13 +9713,13 @@ package R is
    pragma Inline (Q);
 end R;
 package body R is
-   ...
+   @dots{}
 end R;
 
 with R;
 procedure Main is
 begin
-   ...
+   @dots{}
    R.Q;
 end Main;
 @end cartouche
@@ -9138,12 +9738,12 @@ is compiled, the call will be inlined if the body of @code{Q} is small
 enough, but now @code{Main} depends on the body of @code{R} in
 @file{r.adb} as well as on the spec. This means that if this body is edited,
 the main program must be recompiled. Note that this extra dependency
-occurs whether or not the call is in fact inlined by @code{gcc}.
+occurs whether or not the call is in fact inlined by @command{gcc}.
 
 The use of front end inlining with @option{-gnatN} generates similar
 additional dependencies.
 
-@cindex @option{^-fno-inline^/INLINE=SUPPRESS^} (@code{gcc})
+@cindex @option{^-fno-inline^/INLINE=SUPPRESS^} (@command{gcc})
 Note: The @option{^-fno-inline^/INLINE=SUPPRESS^} switch
 can be used to prevent
 all inlining. This switch overrides all other conditions and ensures
@@ -9165,6 +9765,20 @@ that you should not automatically assume that @option{-O3} is better than
 @option{-O2}, and indeed you should use @option{-O3} only if tests show that
 it actually improves performance.
 
+@node Other Optimization Switches
+@subsection Other Optimization Switches
+@cindex Optimization Switches
+
+Since @code{GNAT} uses the @command{gcc} back end, all the specialized
+@command{gcc} optimization switches are potentially usable. These switches
+have not been extensively tested with GNAT but can generally be expected
+to work. Examples of switches in this category are
+@option{-funroll-loops} and
+the various target-specific @option{-m} options (in particular, it has been
+observed that @option{-march=pentium4} can significantly improve performance
+on appropriate machines). For full details of these switches, see the
+@command{gcc} manual.
+
 @node Optimization and Strict Aliasing
 @subsection Optimization and Strict Aliasing
 @cindex Aliasing
@@ -9186,16 +9800,16 @@ procedure R is
    type Int2A is access Int2;
    Int1V : Int1A;
    Int2V : Int2A;
-   ...
+   @dots{}
 
 begin
-   ...
+   @dots{}
    for J in Data'Range loop
       if Data (J) = Int1V.all then
          Int2V.all := Int2V.all + 1;
       end if;
    end loop;
-   ...
+   @dots{}
 end R;
 @end cartouche
 @end smallexample
@@ -9209,7 +9823,7 @@ the compiler optimizer can "know" that the value @code{Int1V.all} is constant
 for all iterations of the loop and avoid the extra memory reference
 required to dereference it each time through the loop.
 
-This kind of optimziation, called strict aliasing analysis, is
+This kind of optimization, called strict aliasing analysis, is
 triggered by specifying an optimization level of @option{-O2} or
 higher and allows @code{GNAT} to generate more efficient code
 when access values are involved.
@@ -9258,8 +9872,8 @@ end;
 @end smallexample
 
 @noindent
-This program prints out 0 in @code{-O0} or @code{-O1}
-mode, but it prints out 1 in @code{-O2} mode. That's
+This program prints out 0 in @option{-O0} or @option{-O1}
+mode, but it prints out 1 in @option{-O2} mode. That's
 because in strict aliasing mode, the compiler can and
 does assume that the assignment to @code{v2.all} could not
 affect the value of @code{v1.all}, since different types
@@ -9297,19 +9911,19 @@ the suspicious @code{Unchecked_Conversion}.
 As implied by the warning message, there are approaches you can use to
 avoid the unwanted strict aliasing optimization in a case like this.
 
-One possibility is to simply avoid the use of @code{-O2}, but
+One possibility is to simply avoid the use of @option{-O2}, but
 that is a bit drastic, since it throws away a number of useful
 optimizations that do not involve strict aliasing assumptions.
 
 A less drastic approach is to compile the program using the
-option @code{-fno-strict-aliasing}. Actually it is only the
+option @option{-fno-strict-aliasing}. Actually it is only the
 unit containing the dereferencing of the suspicious pointer
 that needs to be compiled. So in this case, if we compile
 unit @code{m} with this switch, then we get the expected
 value of zero printed. Analyzing which units might need
 the switch can be painful, so a more reasonable approach
-is to compile the entire program with options @code{-O2}
-and @code{-fno-strict-aliasing}. If the performance is
+is to compile the entire program with options @option{-O2}
+and @option{-fno-strict-aliasing}. If the performance is
 satisfactory with this combination of options, then the
 advantage is that the entire issue of possible "wrong"
 optimization due to strict aliasing is avoided.
@@ -9385,13 +9999,13 @@ unchecked conversion of access values.
 @subsection Coverage Analysis
 
 @noindent
-GNAT supports the Digital Performance Coverage Analyzer (PCA), which allows
+GNAT supports the HP Performance Coverage Analyzer (PCA), which allows
 the user to determine the distribution of execution time across a program,
 @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
@@ -9474,7 +10088,7 @@ being processed.
 @cindex @option{^-a^/ALL^} (@command{gnatelim})
 Also look for subprograms from the GNAT run time that can be eliminated. Note
 that when @file{gnat.adc} is produced using this switch, the entire program
-must be recompiled with switch @option{^-a^/ALL_FILES^} to @code{gnatmake}.
+must be recompiled with switch @option{^-a^/ALL_FILES^} to @command{gnatmake}.
 
 @item ^-I^/INCLUDE_DIRS=^@var{dir}
 @cindex @option{^-I^/INCLUDE_DIRS^} (@command{gnatelim})
@@ -9495,22 +10109,13 @@ file must be specified with full path.
 
 @item ^--GCC^/COMPILER^=@var{compiler_name}
 @cindex @option{^-GCC^/COMPILER^} (@command{gnatelim})
-Instructs @code{gnatelim} to use specific @code{gcc} compiler instead of one
+Instructs @code{gnatelim} to use specific @command{gcc} compiler instead of one
 available on the path.
 
 @item ^--GNATMAKE^/GNATMAKE^=@var{gnatmake_name}
 @cindex @option{^--GNATMAKE^/GNATMAKE^} (@command{gnatelim})
-Instructs @code{gnatelim} to use specific @code{gnatmake} instead of one
+Instructs @code{gnatelim} to use specific @command{gnatmake} instead of one
 available on the path.
-
-@item -d@var{x}
-@cindex @option{-d@var{x}} (@command{gnatelim})
-Activate internal debugging switches. @var{x} is a letter or digit, or
-string of letters or digits, which specifies the type of debugging
-mode desired.  Normally these are used only for internal development
-or system debugging purposes. You can find full documentation for these
-switches in the spec of the @code{Gnatelim} unit in the compiler
-source file @file{gnatelim.ads}.
 @end table
 
 @noindent
@@ -9559,7 +10164,6 @@ the @file{gnat.adc} file. You should recompile your program
 from scratch after that, because you need a consistent @file{gnat.adc} file
 during the entire compilation.
 
-
 @node Making Your Executables Smaller
 @subsection Making Your Executables Smaller
 
@@ -9620,8 +10224,130 @@ $ gnatmake ^-f main_prog^/FORCE_COMPILE MAIN_PROG^
 
 @end enumerate
 
+@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
+This section describes how you can eliminate unused subprograms and data from
+your executable just by setting options at compilation time.
+
+@menu
+* About unused subprogram/data elimination::
+* Compilation options::
+* Example of unused subprogram/data elimination::
+@end menu
+
+@node About unused subprogram/data elimination
+@subsection About unused subprogram/data elimination
+
+@noindent
+By default, an executable contains all code and data of its composing objects
+(directly linked or coming from statically linked libraries), even data or code
+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 available on all Linux platforms except for the IA-64
+architecture and on all cross platforms using the ELF binary file format.
+In both cases GNU binutils version 2.16 or later are required to enable it.
+
+@node Compilation options
+@subsection Compilation options
+
+@noindent
+The operation of eliminating the unused code and data from the final executable
+is directly performed by the linker.
+
+In order to do this, it has to work with objects compiled with the
+following options:
+@option{-ffunction-sections} @option{-fdata-sections}.
+@cindex @option{-ffunction-sections} (@command{gcc})
+@cindex @option{-fdata-sections} (@command{gcc})
+These options are usable with C and Ada files.
+They will place respectively each
+function or data in a separate section in the resulting object file.
+
+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 @command{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.
+However, no dead code elimination will be performed on those objects (they will
+be linked as is).
+
+The GNAT static library is now compiled with -ffunction-sections and
+-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
@@ -9667,7 +10393,6 @@ system, you can set up a procedure where you use @command{gnatchop} each
 time you compile, regarding the source files that it writes as temporary
 files that you throw away.
 
-
 @node Operating gnatchop in Compilation Mode
 @section Operating gnatchop in Compilation Mode
 
@@ -9701,8 +10426,7 @@ should apply to all subsequent compilations in the same compilation
 environment. Using GNAT, the current directory, possibly containing a
 @file{gnat.adc} file is the representation
 of a compilation environment. For more information on the
-@file{gnat.adc} file, see the section on handling of configuration
-pragmas @pxref{Handling of Configuration Pragmas}.
+@file{gnat.adc} file, see @ref{Handling of Configuration Pragmas}.
 
 Second, in compilation mode, if @code{gnatchop}
 is given a file that starts with
@@ -9735,7 +10459,7 @@ in which GNAT processes the ACVC tests.
 The @code{gnatchop} command has the form:
 
 @smallexample
-$ gnatchop switches @var{file name} [@var{file name} @var{file name} ...]
+$ gnatchop switches @var{file name} [@var{file name} @var{file name} @dots{}]
       [@var{directory}]
 @end smallexample
 
@@ -9824,6 +10548,15 @@ no source files written
 @table @option
 @c !sort!
 
+@item --version
+@cindex @option{--version} @command{gnatchop}
+Display Copyright and version, then exit disregarding all other options.
+
+@item --help
+@cindex @option{--help} @command{gnatchop}
+If @option{--version} was not used, display usage, then exit disregarding
+all other options.
+
 @item ^-c^/COMPILATION^
 @cindex @option{^-c^/COMPILATION^} (@code{gnatchop})
 Causes @code{gnatchop} to operate in compilation mode, in which
@@ -9887,7 +10620,8 @@ generated files to refers back to the original file name and line number.
 The result is that all error messages refer back to the original
 unchopped file.
 In addition, the debugging information placed into the object file (when
-the @option{^-g^/DEBUG^} switch of @code{gcc} or @code{gnatmake} is specified)
+the @option{^-g^/DEBUG^} switch of @command{gcc} or @command{gnatmake} is
+specified)
 also refers back to this original file so that tools like profilers and
 debuggers will give information in terms of the original unchopped file.
 
@@ -9947,7 +10681,7 @@ useful application of @code{gnatchop} is in sending sets of sources
 around, for example in email messages. The required sources are simply
 concatenated (for example, using a ^Unix @code{cat}^VMS @code{APPEND/NEW}^
 command), and then
-@code{gnatchop} is used at the other end to reconstitute the original
+@command{gnatchop} is used at the other end to reconstitute the original
 file names.
 
 @item gnatchop file1 file2 file3 direc
@@ -9967,39 +10701,45 @@ unit will be skipped.
 @cindex Pragmas, configuration
 
 @noindent
-In Ada 95, configuration pragmas include those pragmas described as
-such in the Ada 95 Reference Manual, as well as
+Configuration pragmas include those pragmas described as
+such in the Ada Reference Manual, as well as
 implementation-dependent pragmas that are configuration pragmas. See the
-individual descriptions of pragmas in the GNAT Reference Manual for
+individual descriptions of pragmas in the @cite{GNAT Reference Manual} for
 details on these additional GNAT-specific configuration pragmas. Most
 notably, the pragma @code{Source_File_Name}, which allows
 specifying non-default names for source files, is a configuration
 pragma. The following is a complete list of configuration pragmas
-recognized by @code{GNAT}:
+recognized by GNAT:
 
 @smallexample
    Ada_83
    Ada_95
+   Ada_05
    C_Pass_By_Copy
    Component_Alignment
+   Detect_Blocking
    Discard_Names
    Elaboration_Checks
    Eliminate
    Extend_System
-   Extensions_Allowed
    External_Name_Casing
    Float_Representation
    Initialize_Scalars
+   Interrupt_State
    License
    Locking_Policy
    Long_Float
    Normalize_Scalars
+   Persistent_BSS
    Polling
+   Profile
+   Profile_Warnings
    Propagate_Exceptions
    Queuing_Policy
    Ravenscar
    Restricted_Run_Time
    Restrictions
+   Restrictions_Warnings
    Reviewable
    Source_File_Name
    Style_Checks
@@ -10027,7 +10767,7 @@ all compilations performed in a given compilation environment.
 GNAT also provides the @code{gnatchop} utility to provide an automatic
 way to handle configuration pragmas following the semantics for
 compilations (that is, files with multiple units), described in the RM.
-See section @pxref{Operating gnatchop in Compilation Mode} for details.
+See @ref{Operating gnatchop in Compilation Mode} for details.
 However, for most purposes, it will be more convenient to edit the
 @file{gnat.adc} file that contains configuration pragmas directly,
 as described in the following section.
@@ -10051,15 +10791,15 @@ configuration pragmas, or more conveniently  by
 direct editing of the @file{gnat.adc} file, which is a standard format
 source file.
 
-In addition to @file{gnat.adc}, one additional file containing configuration
+In addition to @file{gnat.adc}, additional files containing configuration
 pragmas may be applied to the current compilation using the switch
 @option{-gnatec}@var{path}. @var{path} must designate an existing file that
 contains only configuration pragmas. These configuration pragmas are
 in addition to those found in @file{gnat.adc} (provided @file{gnat.adc}
 is present and switch @option{-gnatA} is not used).
 
-It is allowed to specify several switches @option{-gnatec}, however only
-the last one on the command line will be taken into account.
+It is allowed to specify several switches @option{-gnatec}, all of which
+will be taken into account.
 
 If you are using project file, a separate mechanism is provided using
 project attributes, see @ref{Specifying Configuration Pragmas} for more
@@ -10078,7 +10818,7 @@ pragma Extend_System (Aux_DEC);
 @noindent
 In the presence of this pragma, GNAT adds to the definition of the
 predefined package SYSTEM all the additional types and subprograms that are
-defined in DEC Ada. See @pxref{Compatibility with DEC Ada} for details.
+defined in HP Ada. See @ref{Compatibility with HP Ada} for details.
 @end ifset
 
 @node Handling Arbitrary File Naming Conventions Using gnatname
@@ -10104,11 +10844,11 @@ does not need additional information.
 @noindent
 When the source file names do not follow the standard GNAT default file naming
 conventions, the GNAT compiler must be given additional information through
-a configuration pragmas file (see @ref{Configuration Pragmas})
+a configuration pragmas file (@pxref{Configuration Pragmas})
 or a project file.
 When the non standard file naming conventions are well-defined,
 a small number of pragmas @code{Source_File_Name} specifying a naming pattern
-(see @ref{Alternative File Naming Schemes}) may be sufficient. However,
+(@pxref{Alternative File Naming Schemes}) may be sufficient. However,
 if the file naming conventions are irregular or arbitrary, a number
 of pragma @code{Source_File_Name} for individual compilation units
 must be defined.
@@ -10175,6 +10915,15 @@ You may specify any of the following switches to @code{gnatname}:
 @table @option
 @c !sort!
 
+@item --version
+@cindex @option{--version} @command{gnatname}
+Display Copyright and version, then exit disregarding all other options.
+
+@item --help
+@cindex @option{--help} @command{gnatname}
+If @option{--version} was not used, display usage, then exit disregarding
+all other options.
+
 @item ^-c^/CONFIG_FILE=^@file{file}
 @cindex @option{^-c^/CONFIG_FILE^} (@code{gnatname})
 Create a configuration pragmas file @file{file} (instead of the default
@@ -10230,7 +10979,7 @@ gnatname ^-Pprj -f"*.c"^/PROJECT_FILE=PRJ /FOREIGN_PATTERN=*.C^ "*.ada"
 @noindent
 will look for Ada units in all files with the @file{.ada} extension,
 and will add to the list of file for project @file{prj.gpr} the C files
-with extension ".^c^C^".
+with extension @file{.^c^C^}.
 
 @item ^-h^/HELP^
 @cindex @option{^-h^/HELP^} (@code{gnatname})
@@ -10315,7 +11064,6 @@ even in conjunction with one or several switches
 @option{^-D^/DIRS_FILE^}. Several Naming Patterns and one excluded pattern
 are used in this example.
 
-
 @c *****************************************
 @c * G N A T  P r o j e c t  M a n a g e r *
 @c *****************************************
@@ -10329,12 +11077,12 @@ are used in this example.
 * Objects and Sources in Project Files::
 * Importing Projects::
 * Project Extension::
+* Project Hierarchy Extension::
 * External References in Project Files::
 * Packages in Project Files::
 * Variables from Imported Projects::
 * Naming Schemes::
 * Library Projects::
-* Using Third-Party Libraries through Projects::
 * Stand-alone Library Projects::
 * Switches Related to Project Files::
 * Tools Supporting Project Files::
@@ -10431,7 +11179,7 @@ There may be zero, one or more spaces between @option{-P} and
 @end ifclear
 If you want to define (on the command line) an external variable that is
 queried by the project file, you must use the
-@option{^-X^/EXTERNAT_REFERENCE=^@emph{vbl}=@emph{value}} switch.
+@option{^-X^/EXTERNAL_REFERENCE=^@emph{vbl}=@emph{value}} switch.
 The Project Manager parses and interprets the project file, and drives the
 invoked tool based on the project settings.
 
@@ -10719,21 +11467,21 @@ One of the specifiable properties of a project is a list of files that contain
 main subprograms.  This property is captured in the @code{Main} attribute,
 whose value is a list of strings.  If a project defines the @code{Main}
 attribute, it is not necessary to identify the main subprogram(s) when
-invoking @command{gnatmake} (see @ref{gnatmake and Project Files}).
+invoking @command{gnatmake} (@pxref{gnatmake and Project Files}).
 
 @node Executable File Names
 @unnumberedsubsubsec Executable File Names
 
 @noindent
 By default, the executable file name corresponding to a main source is
-deducted from the main source file name. Through the attributes
+deduced from the main source file name. Through the attributes
 @code{Executable} and @code{Executable_Suffix} of package @code{Builder},
 it is possible to change this default.
 In project @code{Debug} above, the executable file name
 for main source @file{^proc.adb^PROC.ADB^} is
 @file{^proc1^PROC1.EXE^}.
 Attribute @code{Executable_Suffix}, when specified, may change the suffix
-of the the executable files, when no attribute @code{Executable} applies:
+of the executable files, when no attribute @code{Executable} applies:
 its value replace the platform-specific executable suffix.
 Attributes @code{Executable} and @code{Executable_Suffix} are the only ways to
 specify a non default executable file name when several mains are built at once
@@ -10798,6 +11546,8 @@ project Build is
         for ^Default_Switches^Default_Switches^ ("Ada")
             use ("^-g^-g^");
         for Executable ("proc") use "proc1";
+      when others =>
+        null;
     end case;
 
   end Builder;
@@ -10881,6 +11631,7 @@ is equivalent to the @command{gnatmake} invocation using the project file
 
 @node Importing Other Projects
 @subsection Importing Other Projects
+@cindex @code{ADA_PROJECT_PATH}
 
 @noindent
 A compilation unit in a source file in one project may depend on compilation
@@ -10927,9 +11678,9 @@ Skeletal code for a main procedure might be something like the following:
 @group
 with GUI, Comm;
 procedure App_Main is
-   ...
+   @dots{}
 begin
-   ...
+   @dots{}
 end App_Main;
 @end group
 @end smallexample
@@ -11083,20 +11834,20 @@ and no longer requires a body: in this case, it is necessary to indicate that
 the inherited body is not part of the sources of the project, otherwise there
 will be a compilation error when compiling the spec.
 
-For that purpose, the attribute @code{Locally_Removed_Files} is used.
+For that purpose, the attribute @code{Excluded_Source_Files} is used.
 Its value is a string list: a list of file names.
 
 @smallexample @c @projectfile
 project B extends "a" is
    for Source_Files use ("pkg.ads");
    --  New spec of Pkg does not need a completion
-   for Locally_Removed_Files use ("pkg.adb");
+   for Excluded_Source_Files use ("pkg.adb");
 end B;
 @end smallexample
 
-Attribute @code{Locally_Removed_Files} may also be used to check if a source
-is still needed: if it is possible to build using @code{gnatmake} when such
-a source is put in attribute @code{Locally_Removed_Files} of a project P, then
+Attribute @code{Excluded_Source_Files} may also be used to check if a source
+is still needed: if it is possible to build using @command{gnatmake} when such
+a source is put in attribute @code{Excluded_Source_Files} of a project P, then
 it is possible to remove the source completely from a system that includes
 project P.
 
@@ -11196,7 +11947,7 @@ reserved words currently used in project file syntax are:
 @end itemize
 
 @noindent
-Comments in project files have the same syntax as in Ada, two consecutives
+Comments in project files have the same syntax as in Ada, two consecutive
 hyphens through the end of the line.
 
 @node Packages
@@ -11226,11 +11977,17 @@ case insensitive. The following package names are legal:
 @item
 @code{Eliminate}
 @item
+@code{Pretty_Printer}
+@item
+@code{Metrics}
+@item
 @code{gnatls}
 @item
 @code{gnatstub}
 @item
 @code{IDE}
+@item
+@code{Language_Processing}
 @end itemize
 
 @noindent
@@ -11268,9 +12025,9 @@ A @emph{string expression} is either a @emph{simple string expression} or a
 A @emph{simple string expression} is one of the following:
 @itemize @bullet
 @item A literal string; e.g.@code{"comm/my_proj.gpr"}
-@item A string-valued variable reference (see @ref{Variables})
-@item A string-valued attribute reference (see @ref{Attributes})
-@item An external reference (see @ref{External References in Project Files})
+@item A string-valued variable reference (@pxref{Variables})
+@item A string-valued attribute reference (@pxref{Attributes})
+@item An external reference (@pxref{External References in Project Files})
 @end itemize
 
 @noindent
@@ -11334,7 +12091,7 @@ Variables of a string type are called @emph{typed variables}; all other
 variables are called @emph{untyped variables}. Typed variables are
 particularly useful in @code{case} constructions, to support conditional
 attribute declarations.
-(see @ref{case Constructions}).
+(@pxref{case Constructions}).
 
 The string literals in the list are case sensitive and must all be different.
 They may include any graphic characters allowed in Ada, including spaces.
@@ -11435,7 +12192,7 @@ the project's properties.  Some attributes have values that are strings;
 others have values that are string lists.
 
 There are two categories of attributes: @emph{simple attributes}
-and @emph{associative arrays} (see @ref{Associative Array Attributes}).
+and @emph{associative arrays} (@pxref{Associative Array Attributes}).
 
 Legal project attribute names, and attribute names for each legal package are
 listed below. Attributes names are case-insensitive.
@@ -11455,14 +12212,14 @@ The following attributes are defined on projects (all are simple attributes):
 @tab string
 @item @code{Exec_Dir}
 @tab string
-@item @code{Locally_Removed_Files}
+@item @code{Excluded_Source_Dirs}
 @tab string list
-@item @code{Main}
+@item @code{Excluded_Source_Files}
 @tab string list
 @item @code{Languages}
 @tab string list
-@item @code{Main_Language}
-@tab string
+@item @code{Main}
+@tab string list
 @item @code{Library_Dir}
 @tab string
 @item @code{Library_Name}
@@ -11477,13 +12234,25 @@ The following attributes are defined on projects (all are simple attributes):
 @tab string
 @item @code{Library_Options}
 @tab string list
+@item @code{Library_Src_Dir}
+@tab string
+@item @code{Library_ALI_Dir}
+@tab string
 @item @code{Library_GCC}
 @tab string
+@item @code{Library_Symbol_File}
+@tab string
+@item @code{Library_Symbol_Policy}
+@tab string
+@item @code{Library_Reference_Symbol_File}
+@tab string
+@item @code{Externally_Built}
+@tab string
 @end multitable
 
 @noindent
 The following attributes are defined for package  @code{Naming}
-(see @ref{Naming Schemes}):
+(@pxref{Naming Schemes}):
 
 @multitable @columnfractions .4 .2 .2 .2
 @item Attribute Name @tab Category @tab Index @tab Value
@@ -11529,7 +12298,7 @@ The following attributes are defined for package  @code{Naming}
 The following attributes are defined for packages @code{Builder},
 @code{Compiler}, @code{Binder},
 @code{Linker}, @code{Cross_Reference}, and @code{Finder}
-(see @ref{^Switches^Switches^ and Project Files}).
+(@pxref{^Switches^Switches^ and Project Files}).
 
 @multitable @columnfractions .4 .2 .2 .2
 @item Attribute Name @tab Category @tab Index @tab Value
@@ -11653,7 +12422,7 @@ project.
 @end smallexample
 
 @noindent
-In this example, @code{Default} must be either an project imported by the
+In this example, @code{Default} must be either a project imported by the
 current project, or the project that the current project extends. If the
 attribute is in a package (in this case, in package @code{Builder}), the same
 package needs to be specified.
@@ -11700,7 +12469,7 @@ end MyProj;
 The syntax of a @code{case} construction is based on the Ada case statement
 (although there is no @code{null} construction for empty alternatives).
 
-The case expression must a typed string variable.
+The case expression must be a typed string variable.
 Each alternative comprises the reserved word @code{when}, either a list of
 literal strings separated by the @code{"|"} character or the reserved word
 @code{others},  and the @code{"=>"} token.
@@ -11709,12 +12478,13 @@ case variable.
 An @code{others} alternative, if present, must occur last.
 
 After each @code{=>}, there are zero or more constructions.  The only
-constructions allowed in a case construction are other case constructions and
-attribute declarations. String type declarations, variable declarations and
-package declarations are not allowed.
+constructions allowed in a case construction are other case constructions,
+attribute declarations and variable declarations. String type declarations and
+package declarations are not allowed. Variable declarations are restricted to
+variables that have already been declared before the case construction.
 
 The value of the case variable is often given by an external reference
-(see @ref{External References in Project Files}).
+(@pxref{External References in Project Files}).
 
 @c ****************************************
 @c * Objects and Sources in Project Files *
@@ -11734,7 +12504,7 @@ The value of the case variable is often given by an external reference
 Each project has exactly one object directory and one or more source
 directories. The source directories must contain at least one source file,
 unless  the project file explicitly specifies that no source files are present
-(see @ref{Source File Names}).
+(@pxref{Source File Names}).
 
 @node Object Directory
 @subsection Object Directory
@@ -11752,7 +12522,7 @@ in the project file.
 @end smallexample
 
 @noindent
-The attribute @var{Object_Dir} has a string value, the path name of the object
+The attribute @code{Object_Dir} has a string value, the path name of the object
 directory. The path name may be absolute or relative to the directory of the
 project file. This directory must already exist, and be readable and writable.
 
@@ -11775,7 +12545,7 @@ in the project file.
 @end smallexample
 
 @noindent
-The attribute @var{Exec_Dir} has a string value, the path name of the exec
+The attribute @code{Exec_Dir} has a string value, the path name of the exec
 directory. The path name may be absolute or relative to the directory of the
 project file. This directory must already exist, and be writable.
 
@@ -11867,7 +12637,7 @@ contains a source file name.
 By default, if neither the attribute @code{Source_Files} nor the attribute
 @code{Source_List_File} is given an explicit value, then each file in the
 source directories that conforms to the project's naming scheme
-(see @ref{Naming Schemes}) is an immediate source of the project.
+(@pxref{Naming Schemes}) is an immediate source of the project.
 
 A warning is issued if both attributes @code{Source_Files} and
 @code{Source_List_File} are given explicit values. In this case, the attribute
@@ -11900,8 +12670,8 @@ list, or the @code{"Ada"} may be absent from @code{Languages}:
 Otherwise, a project must contain at least one immediate source.
 
 Projects with no source files are useful as template packages
-(see @ref{Packages in Project Files}) for other projects; in particular to
-define a package @code{Naming} (see @ref{Naming Schemes}).
+(@pxref{Packages in Project Files}) for other projects; in particular to
+define a package @code{Naming} (@pxref{Naming Schemes}).
 
 @c ****************************
 @c * Importing Projects *
@@ -11909,6 +12679,7 @@ define a package @code{Naming} (see @ref{Naming Schemes}).
 
 @node  Importing Projects
 @section Importing Projects
+@cindex @code{ADA_PROJECT_PATH}
 
 @noindent
 An immediate source of a project P may depend on source files that
@@ -11921,7 +12692,7 @@ source files.
   with "project1", "utilities.gpr";
   with "/namings/apex.gpr";
   project Main is
-    ...
+    @dots{}
 @end group
 @end smallexample
 
@@ -11932,19 +12703,24 @@ use literal strings instead of names, and the @code{with} clause identifies
 project files rather than packages.
 
 Each literal string is the file name or path name (absolute or relative) of a
-project file. If a string is simply a file name, with no path, then its
-location is determined by the @emph{project path}:
+project file. If a string corresponds to a file name, with no path or a
+relative path, then its location is determined by the @emph{project path}. The
+latter can be queried using @code{gnatls -v}. It contains:
 
 @itemize @bullet
 @item
-If the ^environment variable^logical name^ @env{ADA_PROJECT_PATH} exists,
-then the project path includes all the directories in this
-^environment variable^logical name^, plus the directory of the project file.
+In first position, the directory containing the current project file.
+@item
+In last position, the default project directory. This default project directory
+is part of the GNAT installation and is the standard place to install project
+files giving access to standard support libraries.
+@ifclear vms
+@ref{Installing a library}
+@end ifclear
 
 @item
-If the ^environment variable^logical name^ @env{ADA_PROJECT_PATH} does not
-exist, then the project path contains only one directory, namely the one where
-the project file is located.
+In between, all the directories referenced in the
+^environment variable^logical name^ @env{ADA_PROJECT_PATH} if it exists.
 @end itemize
 
 @noindent
@@ -11955,9 +12731,10 @@ If a relative pathname is used, as in
 @end smallexample
 
 @noindent
-then the path is relative to the directory where the importing project file is
-located. Any symbolic link will be fully resolved in the directory
-of the importing project file before the imported project file is examined.
+then the full path for the project is constructed by concatenating this
+relative path to those in the project path, in order, until a matching file is
+found. Any symbolic link will be fully resolved in the directory of the
+importing project file before the imported project file is examined.
 
 If the @code{with}'ed project file name does not have an extension,
 the default is @file{^.gpr^.GPR^}. If a file with this extension is not found,
@@ -11982,7 +12759,7 @@ permitted: if @code{A} imports @code{B} (directly or indirectly) then @code{B}
 is not allowed to import @code{A}. However, there are cases when cyclic
 dependencies would be beneficial. For these cases, another form of import
 between projects exists, the @code{limited with}: a project @code{A} that
-imports a project @code{B} with a straigh @code{with} may also be imported,
+imports a project @code{B} with a straight @code{with} may also be imported,
 directly or indirectly, by @code{B} on the condition that imports from @code{B}
 to @code{A} include at least one @code{limited with}.
 
@@ -12042,7 +12819,7 @@ modified versions of some of the source files, without changing the original
 sources. This can be achieved through the @emph{project extension} facility.
 
 @smallexample @c projectfile
-   project Modified_Utilities extends "/baseline/utilities.gpr" is ...
+   project Modified_Utilities extends "/baseline/utilities.gpr" is @dots{}
 @end smallexample
 
 @noindent
@@ -12071,6 +12848,78 @@ projects.
 A project is not allowed to import directly or indirectly at the same time a
 child project and any of its ancestors.
 
+@c *******************************
+@c * Project Hierarchy Extension *
+@c *******************************
+
+@node Project Hierarchy Extension
+@section Project Hierarchy Extension
+
+@noindent
+When extending a large system spanning multiple projects, it is often
+inconvenient to extend every project in the hierarchy that is impacted by a
+small change introduced. In such cases, it is possible to create a virtual
+extension of entire hierarchy using @code{extends all} relationship.
+
+When the project is extended using @code{extends all} inheritance, all projects
+that are imported by it, both directly and indirectly, are considered virtually
+extended. That is, the Project Manager creates "virtual projects"
+that extend every project in the hierarchy; all these virtual projects have
+no sources of their own and have as object directory the object directory of
+the root of "extending all" project.
+
+It is possible to explicitly extend one or more projects in the hierarchy
+in order to modify the sources. These extending projects must be imported by
+the "extending all" project, which will replace the corresponding virtual
+projects with the explicit ones.
+
+When building such a project hierarchy extension, the Project Manager will
+ensure that both modified sources and sources in virtual extending projects
+that depend on them, are recompiled.
+
+By means of example, consider the following hierarchy of projects.
+
+@enumerate
+@item
+project A, containing package P1
+@item
+project B importing A and containing package P2 which depends on P1
+@item
+project C importing B and containing package P3 which depends on P2
+@end enumerate
+
+@noindent
+We want to modify packages P1 and P3.
+
+This project hierarchy will need to be extended as follows:
+
+@enumerate
+@item
+Create project A1 that extends A, placing modified P1 there:
+
+@smallexample @c 0projectfile
+project A1 extends "(@dots{})/A" is
+end A1;
+@end smallexample
+
+@item
+Create project C1 that "extends all" C and imports A1, placing modified
+P3 there:
+
+@smallexample @c 0projectfile
+with "(@dots{})/A1";
+project C1 extends all "(@dots{})/C" is
+end C1;
+@end smallexample
+@end enumerate
+
+When you build project C1, your entire modified project space will be
+recompiled, including the virtual project B1 that has been impacted by the
+"extending all" inheritance of project C.
+
+Note that if a Library Project in the hierarchy is virtually extended,
+the virtual project that extends the Library Project is not a Library Project.
+
 @c ****************************************
 @c * External References in Project Files *
 @c ****************************************
@@ -12124,7 +12973,7 @@ an attribute declaration.
    Mode : Mode_Type := external ("MODE");
    case Mode is
      when "Debug" =>
-        ...
+        @dots{}
 @end group
 @end smallexample
 
@@ -12139,7 +12988,7 @@ an attribute declaration.
 A @emph{package} defines the settings for project-aware tools within a
 project.
 For each such tool one can declare a package; the names for these
-packages are preset (see @ref{Packages}).
+packages are preset (@pxref{Packages}).
 A package may contain variable declarations, attribute declarations, and case
 constructions.
 
@@ -12184,7 +13033,7 @@ the project file for an imported project.
   with "/global/apex.gpr";
   project Example is
     package Naming renames Apex.Naming;
-    ...
+    @dots{}
   end Example;
 @end group
 @end smallexample
@@ -12197,7 +13046,7 @@ a package from the template.
 
 In addition to the tool-oriented packages, you can also declare a package
 named @code{Naming} to establish specialized source file naming conventions
-(see @ref{Naming Schemes}).
+(@pxref{Naming Schemes}).
 
 @c ************************************
 @c * Variables from Imported Projects *
@@ -12224,7 +13073,7 @@ a project.
 @group
      package Builder is
         for ^Default_Switches^Default_Switches^ ("Ada")
-            use Imported.Builder.Ada_^Switches^Switches^ &
+            use Imported.Builder'Ada_^Switches^Switches^ &
                 "^-gnatg^-gnatg^" &
                 "^-v^-v^";
      end Builder;
@@ -12233,7 +13082,7 @@ a project.
 @group
      package Compiler is
         for ^Default_Switches^Default_Switches^ ("Ada")
-            use Base.Compiler.Ada_^Switches^Switches^;
+            use Base.Compiler'Ada_^Switches^Switches^;
      end Compiler;
   end Main;
 @end group
@@ -12278,11 +13127,11 @@ of reasons might not be possible), you can define the relevant file
 naming scheme in the @code{Naming} package in your project file.
 
 @noindent
-Note that the use of pragmas described in @ref{Alternative
-File Naming Schemes} by mean of a configuration pragmas file is not
-supported when using project files. You must use the features described
-in this paragraph. You can however use specify other configuration
-pragmas (see @ref{Specifying Configuration Pragmas}).
+Note that the use of pragmas described in
+@ref{Alternative File Naming Schemes} by mean of a configuration
+pragmas file is not supported when using project files. You must use
+the features described in this paragraph. You can however use specify
+other configuration pragmas (@pxref{Specifying Configuration Pragmas}).
 
 @ifclear vms
 For example, the following
@@ -12301,7 +13150,7 @@ package models the Apex file naming rules:
 @end ifclear
 
 @ifset vms
-For example, the following package models the DEC Ada file naming rules:
+For example, the following package models the HP Ada file naming rules:
 
 @smallexample @c projectfile
 @group
@@ -12324,14 +13173,14 @@ You can define the following attributes in package @code{Naming}:
 
 @table @code
 
-@item @var{Casing}
+@item @code{Casing}
 This must be a string with one of the three values @code{"lowercase"},
 @code{"uppercase"} or @code{"mixedcase"}; these strings are case insensitive.
 
 @noindent
-If @var{Casing} is not specified, then the default is @code{"lowercase"}.
+If @code{Casing} is not specified, then the default is @code{"lowercase"}.
 
-@item @var{Dot_Replacement}
+@item @code{Dot_Replacement}
 This must be a string whose value satisfies the following conditions:
 
 @itemize @bullet
@@ -12346,7 +13195,7 @@ is @code{"."}
 @noindent
 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
 
-@item @var{Spec_Suffix}
+@item @code{Spec_Suffix}
 This is an associative array (indexed by the programming language name, case
 insensitive) whose value is a string that must satisfy the following
 conditions:
@@ -12359,7 +13208,7 @@ conditions:
 If @code{Spec_Suffix ("Ada")} is not specified, then the default is
 @code{"^.ads^.ADS^"}.
 
-@item @var{Body_Suffix}
+@item @code{Body_Suffix}
 This is an associative array (indexed by the programming language name, case
 insensitive) whose value is a string that must satisfy the following
 conditions:
@@ -12367,21 +13216,26 @@ conditions:
 @itemize @bullet
 @item It must not be empty
 @item It must include at least one dot
-@item It cannot end with the same string as @code{Spec_Suffix ("Ada")}
+@item It cannot be the same as @code{Spec_Suffix ("Ada")}
 @end itemize
 @noindent
+If @code{Body_Suffix ("Ada")} and @code{Spec_Suffix ("Ada")} end with the
+same string, then a file name that ends with the longest of these two suffixes
+will be a body if the longest suffix is @code{Body_Suffix ("Ada")} or a spec
+if the longest suffix is @code{Spec_Suffix ("Ada")}.
+
 If @code{Body_Suffix ("Ada")} is not specified, then the default is
 @code{"^.adb^.ADB^"}.
 
-@item @var{Separate_Suffix}
+@item @code{Separate_Suffix}
 This must be a string whose value satisfies the same conditions as
-@code{Body_Suffix}.
+@code{Body_Suffix}. The same "longest suffix" rules apply.
 
 @noindent
 If @code{Separate_Suffix ("Ada")} is not specified, then it defaults to same
 value as @code{Body_Suffix ("Ada")}.
 
-@item @var{Spec}
+@item @code{Spec}
 @noindent
 You can use the associative array attribute @code{Spec}  to define
 the source file name for an individual Ada compilation unit's spec. The array
@@ -12394,7 +13248,7 @@ operating system).
    for Spec ("MyPack.MyChild") use "mypack.mychild.spec";
 @end smallexample
 
-@item @var{Body}
+@item @code{Body}
 
 You can use the associative array attribute @code{Body} to
 define the source file name for an individual Ada compilation unit's body
@@ -12421,20 +13275,21 @@ sensitive or insensitive depending on the operating system).
 
 To create a library project, you need to define in its project file
 two project-level attributes: @code{Library_Name} and @code{Library_Dir}.
-Additionally, you may define the library-related attributes
+Additionally, you may define other library-related attributes such as
 @code{Library_Kind}, @code{Library_Version}, @code{Library_Interface},
 @code{Library_Auto_Init}, @code{Library_Options} and @code{Library_GCC}.
 
 The @code{Library_Name} attribute has a string value. There is no restriction
-on the name of a library. It is the responsability of the developer to
-choose a name that will be accepted by the platform. It is recommanded to
+on the name of a library. It is the responsibility of the developer to
+choose a name that will be accepted by the platform. It is recommended to
 choose names that could be Ada identifiers; such names are almost guaranteed
 to be acceptable on all platforms.
 
 The @code{Library_Dir} attribute has a string value that designates the path
 (absolute or relative) of the directory where the library will reside.
-It must designate an existing directory, and this directory must be
-different from the project's object directory. It also needs to be writable.
+It must designate an existing directory, and this directory must be writable,
+different from the project's object directory and from any source directory
+in the project tree.
 
 If both @code{Library_Name} and @code{Library_Dir} are specified and
 are legal, then the project file defines a library project.  The optional
@@ -12442,13 +13297,11 @@ library-related attributes are checked only for such project files.
 
 The @code{Library_Kind} attribute has a string value that must be one of the
 following (case insensitive): @code{"static"}, @code{"dynamic"} or
-@code{"relocatable"}. If this attribute is not specified, the library is a
-static library, that is an archive of object files that can be potentially
-linked into an static executable. Otherwise, the library may be dynamic or
+@code{"relocatable"} (which is a synonym for @code{"dynamic"}). If this
+attribute is not specified, the library is a static library, that is
+an archive of object files that can be potentially linked into a
+static executable. Otherwise, the library may be dynamic or
 relocatable, that is a library that is loaded only at the start of execution.
-Depending on the operating system, there may or may not be a distinction
-between dynamic and relocatable libraries. For Unix and VMS Unix there is no
-such distinction.
 
 If you need to build both a static and a dynamic library, you should use two
 different object directories, since in some cases some extra code needs to
@@ -12456,6 +13309,13 @@ be generated for the latter. For such cases, it is recommended to either use
 two different project files, or a single one which uses external variables
 to indicate what kind of library should be build.
 
+The @code{Library_ALI_Dir} attribute may be specified to indicate the
+directory where the ALI files of the library will be copied. When it is
+not specified, the ALI files are copied to the directory specified in
+attribute @code{Library_Dir}. The directory specified by @code{Library_ALI_Dir}
+must be writable and different from the project's object directory and from
+any source directory in the project tree.
+
 The @code{Library_Version} attribute has a string value whose interpretation
 is platform dependent. It has no effect on VMS and Windows. On Unix, it is
 used only for dynamic/relocatable libraries as the internal name of the
@@ -12491,7 +13351,7 @@ is a library project file, it will check all immediate sources of the project
 and rebuild the library if any of the sources have been recompiled.
 
 Standard project files can import library project files. In such cases,
-the libraries will only be rebuild if some of its sources are recompiled
+the libraries will only be rebuilt if some of its sources are recompiled
 because they are in the closure of some other source in an importing project.
 Sources of the library project files that are not in such a closure will
 not be checked, unless the full library is checked, because one of its sources
@@ -12503,12 +13363,12 @@ For instance, assume the project file @code{A} imports the library project file
 @file{l2.ads}, @file{l2.adb}.
 
 If @file{l1.adb} has been modified, then the library associated with @code{L}
-will be rebuild when compiling all the immediate sources of @code{A} only
+will be rebuilt when compiling all the immediate sources of @code{A} only
 if @file{a1.ads}, @file{a2.ads} or @file{a2.adb} includes a statement
 @code{"with L1;"}.
 
 To be sure that all the sources in the library associated with @code{L} are
-up to date, and that all the sources of parject @code{A} are also up to date,
+up to date, and that all the sources of project @code{A} are also up to date,
 the following two commands needs to be used:
 
 @smallexample
@@ -12522,67 +13382,11 @@ All @file{ALI} files will also be copied from the object directory to the
 library directory. To build executables, @command{gnatmake} will use the
 library rather than the individual object files.
 
-
-@c **********************************************
-@c * Using Third-Party Libraries through Projects
-@c **********************************************
-@node Using Third-Party Libraries through Projects
-@section Using Third-Party Libraries through Projects
-
-Whether you are exporting your own library to make it available to
-clients, or you are using a library provided by a third party, it is
-convenient to have project files that automatically set the correct
-command line switches for the compiler and linker.
-
-Such project files are very similar to the library project files;
-@xref{Library Projects}. The only difference is that you set the
-@code{Source_Dirs} and @code{Object_Dir} attribute so that they point to the
-directories where, respectively, the sources and the read-only ALI files have
-been installed.
-
-If you need to interface with a set of libraries, as opposed to a
-single one, you need to create one library project for each of the
-libraries. In addition, a top-level project that imports all these
-library projects should be provided, so that the user of your library
-has a single @code{with} clause to add to his own projects.
-
-For instance, let's assume you are providing two static libraries
-@file{liba.a} and @file{libb.a}. The user needs to link with
-both of these libraries. Each of these is associated with its
-own set of header files. Let's assume furthermore that all the
-header files for the two libraries have been installed in the same
-directory @file{headers}. The @file{ALI} files are found in the same
-@file{headers} directory.
-
-In this case, you should provide the following three projects:
-
-@smallexample @c projectfile
-@group
-with "liba", "libb";
-project My_Library is
-  for Source_Dirs use ("headers");
-  for Object_Dir  use "headers";
-end My_Library;
-@end group
-
-@group
-project Liba is
-   for Source_Dirs use ();
-   for Library_Dir use "lib";
-   for Library_Name use "a";
-   for Library_Kind use "static";
-end Liba;
-@end group
-
-@group
-project Libb is
-   for Source_Dirs use ();
-   for Library_Dir use "lib";
-   for Library_Name use "b";
-   for Library_Kind use "static";
-end Libb;
-@end group
-@end smallexample
+@ifclear vms
+It is also possible to create library project files for third-party libraries
+that are precompiled and cannot be compiled locally thanks to the
+@code{externally_built} attribute. (See @ref{Installing a library}).
+@end ifclear
 
 @c *******************************
 @c * Stand-alone Library Projects *
@@ -12761,9 +13565,6 @@ only the last one is used.
 @menu
 * gnatmake and Project Files::
 * The GNAT Driver and Project Files::
-@ifclear vms
-* Glide and Project Files::
-@end ifclear
 @end menu
 
 @node gnatmake and Project Files
@@ -13002,7 +13803,7 @@ end Proj4;
 -- Ada source file:
 with Pack;
 procedure Foo_Main is
-   ...
+   @dots{}
 end Foo_Main;
 @end group
 @end smallexample
@@ -13153,7 +13954,7 @@ When a library project file is specified, switches ^-b^/ACTION=BIND^ and
 ^-l^/ACTION=LINK^ have special meanings.
 
 @itemize @bullet
-@item ^-b^/ACTION=BIND^ is only allwed for stand-alone libraries. It indicates
+@item ^-b^/ACTION=BIND^ is only allowed for stand-alone libraries. It indicates
 to @command{gnatmake} that @command{gnatbind} should be invoked for the
 library.
 
@@ -13168,23 +13969,27 @@ to @command{gnatmake} that the binder generated file should be compiled
 
 @noindent
 A number of GNAT tools, other than @command{^gnatmake^gnatmake^}
-are project-aware:
+can benefit from project files:
 @command{^gnatbind^gnatbind^},
+@command{^gnatcheck^gnatcheck^}),
+@command{^gnatclean^gnatclean^}),
+@command{^gnatelim^gnatelim^},
 @command{^gnatfind^gnatfind^},
 @command{^gnatlink^gnatlink^},
 @command{^gnatls^gnatls^},
-@command{^gnatelim^gnatelim^},
+@command{^gnatmetric^gnatmetric^},
 @command{^gnatpp^gnatpp^},
+@command{^gnatstub^gnatstub^},
 and @command{^gnatxref^gnatxref^}. However, none of these tools can be invoked
 directly with a project file switch (@option{^-P^/PROJECT_FILE=^}).
 They must be invoked through the @command{gnat} driver.
 
-The @command{gnat} driver is a front-end that accepts a number of commands and
-call the corresponding tool. It has been designed initially for VMS to convert
-VMS style qualifiers to Unix style switches, but it is now available to all
-the GNAT supported platforms.
+The @command{gnat} driver is a wrapper that accepts a number of commands and
+calls the corresponding tool. It was designed initially for VMS platforms (to
+convert VMS qualifiers to Unix-style switches), but it is now available on all
+GNAT platforms.
 
-On non VMS platforms, the @command{gnat} driver accepts the following commands
+On non-VMS platforms, the @command{gnat} driver accepts the following commands
 (case insensitive):
 
 @itemize @bullet
@@ -13215,14 +14020,29 @@ PREP or PREPROCESS to invoke @command{^gnatprep^gnatprep^}
 @item
 PP or PRETTY to invoke @command{^gnatpp^gnatpp^}
 @item
+METRIC to invoke @command{^gnatmetric^gnatmetric^}
+@item
 STUB to invoke @command{^gnatstub^gnatstub^}
 @item
 XREF to invoke @command{^gnatxref^gnatxref^}
 @end itemize
 
 @noindent
-Note that the compiler is invoked using the command
-@command{^gnatmake -f -u -c^gnatmake -f -u -c^}.
+(note that the compiler is invoked using the command
+@command{^gnatmake -f -u -c^gnatmake -f -u -c^}).
+
+@noindent
+On non VMS platforms, between @command{gnat} and the command, two
+special switches may be used:
+
+@itemize @bullet
+@item
+@command{-v} to display the invocation of the tool.
+@item
+@command{-dn} to prevent the @command{gnat} driver from removing
+the temporary files it has created. These temporary files are
+configuration files and temporary file list files.
+@end itemize
 
 @noindent
 The command may be followed by switches and arguments for the invoked
@@ -13243,8 +14063,8 @@ files may be specified with their path name preceded by '@@'.
 @end smallexample
 
 @noindent
-In addition, for command BIND, COMP or COMPILE, FIND, ELIM, LS or LIST, LINK,
-PP or PRETTY and XREF, the project file related switches
+In addition, for commands BIND, COMP or COMPILE, FIND, ELIM, LS or LIST, LINK,
+METRIC, PP or PRETTY, STUB and XREF, the project file related switches
 (@option{^-P^/PROJECT_FILE^},
 @option{^-X^/EXTERNAL_REFERENCE^} and
 @option{^-vP^/MESSAGES_PROJECT_FILE=^x}) may be used in addition to
@@ -13256,36 +14076,66 @@ specified on the command line, it invokes @command{^gnatpp^gnatpp^} with all
 the immediate sources of the specified project file.
 
 @noindent
-For each of these commands, there is optionally a corresponding  package
-in the main project.
+When GNAT METRIC is used with a project file, but with no source
+specified on the command line, it invokes @command{^gnatmetric^gnatmetric^}
+with all the immediate sources of the specified project file and with
+@option{^-d^/DIRECTORY^} with the parameter pointing to the object directory
+of the project.
 
-@itemize @bullet
+@noindent
+In addition, when GNAT PP, GNAT PRETTY or GNAT METRIC is used with
+a project file, no source is specified on the command line and
+switch ^-U^/ALL_PROJECTS^ is specified on the command line, then
+the underlying tool (^gnatpp^gnatpp^ or
+^gnatmetric^gnatmetric^) is invoked for all sources of all projects,
+not only for the immediate sources of the main project.
+@ifclear vms
+(-U stands for Universal or Union of the project files of the project tree)
+@end ifclear
+
+@noindent
+For each of the following commands, there is optionally a corresponding
+package in the main project.
+
+@itemize @bullet
 @item
 package @code{Binder} for command BIND (invoking @code{^gnatbind^gnatbind^})
 
 @item
+package @code{Check} for command CHECK (invoking
+@code{^gnatcheck^gnatcheck^})
+
+@item
 package @code{Compiler} for command COMP or COMPILE (invoking the compiler)
 
 @item
-package @code{Finder} for command FIND (invoking @code{^gnatfind^gnatfind^})
+package @code{Cross_Reference} for command XREF (invoking
+@code{^gnatxref^gnatxref^})
 
 @item
 package @code{Eliminate} for command ELIM (invoking
 @code{^gnatelim^gnatelim^})
 
 @item
+package @code{Finder} for command FIND (invoking @code{^gnatfind^gnatfind^})
+
+@item
 package @code{Gnatls} for command LS or LIST (invoking @code{^gnatls^gnatls^})
 
 @item
+package @code{Gnatstub} for command STUB
+(invoking @code{^gnatstub^gnatstub^})
+
+@item
 package @code{Linker} for command LINK (invoking @code{^gnatlink^gnatlink^})
 
 @item
-package @code{Pretty_Printer} for command PP or PRETTY
-(invoking @code{^gnatpp^gnatpp^})
+package @code{Metrics} for command METRIC
+(invoking @code{^gnatmetric^gnatmetric^})
 
 @item
-package @code{Cross_Reference} for command XREF (invoking
-@code{^gnatxref^gnatxref^})
+package @code{Pretty_Printer} for command PP or PRETTY
+(invoking @code{^gnatpp^gnatpp^})
 
 @end itemize
 
@@ -13311,7 +14161,7 @@ All other packages have two attribute @code{^Switches^Switches^} and
 @code{^Default_Switches^Default_Switches^}.
 
 @noindent
-@code{^Switches^Switches^} is an associated array attribute, indexed by the
+@code{^Switches^Switches^} is an associative array attribute, indexed by the
 source file name, that has a string list value: the ^switches^switches^ to be
 used when the tool corresponding to the package is invoked for the specific
 source file.
@@ -13401,23 +14251,29 @@ found in the package corresponding to the tool:
 @code{^Default_Switches^Default_Switches^ ("Ada")} for all tools,
 except @code{^Switches^Switches^ ("main.adb")}
 for @code{^gnatlink^gnatlink^}.
-
-@ifclear vms
-@node Glide and Project Files
-@subsection Glide and Project Files
-
-@noindent
-Glide will automatically recognize the @file{.gpr} extension for
-project files, and will
-convert them to its own internal format automatically. However, it
-doesn't provide a syntax-oriented editor for modifying these
-files.
-The project file will be loaded as text when you select the menu item
-@code{Ada} @result{} @code{Project} @result{} @code{Edit}.
-You can edit this text and save the @file{gpr} file;
-when you next select this project file in Glide it
-will be automatically reloaded.
-@end ifclear
+It is also possible to invoke some of the tools,
+@code{^gnatcheck^gnatcheck^}),
+@code{^gnatmetric^gnatmetric^}),
+and @code{^gnatpp^gnatpp^})
+on a set of project units thanks to the combination of the switches
+@option{-P}, @option{-U} and possibly the main unit when one is interested
+in its closure. For instance,
+@smallexample
+gnat metric -Pproj
+@end smallexample
+will compute the metrics for all the immediate units of project
+@code{proj}.
+@smallexample
+gnat metric -Pproj -U
+@end smallexample
+will compute the metrics for all the units of the closure of projects
+rooted at @code{proj}.
+@smallexample
+gnat metric -Pproj -U main_unit
+@end smallexample
+will compute the metrics for the closure of units rooted at
+@code{main_unit}. This last possibility relies implicitly
+on @command{gnatbind}'s option @option{-R}.
 
 @c **********************
 @node An Extended Example
@@ -13697,7 +14553,6 @@ simple_name ::=
 
 @end smallexample
 
-
 @node The Cross-Referencing Tools gnatxref and gnatfind
 @chapter  The Cross-Referencing Tools @code{gnatxref} and @code{gnatfind}
 @findex gnatxref
@@ -13723,10 +14578,13 @@ definitions and/or references to a specified entity or entities, whereas
 cross-references.
 
 To use these tools, you must not compile your application using the
-@option{-gnatx} switch on the @file{gnatmake} command line
-(see @ref{The GNAT Make Program gnatmake}). Otherwise, cross-referencing
+@option{-gnatx} switch on the @command{gnatmake} command line
+(@pxref{The GNAT Make Program gnatmake}). Otherwise, cross-referencing
 information will not be generated.
 
+Note: to invoke @code{gnatxref} or @code{gnatfind} with a project file,
+use the @code{gnat} driver (see @ref{The GNAT Driver and Project Files}).
+
 @menu
 * gnatxref Switches::
 * gnatfind Switches::
@@ -13742,7 +14600,7 @@ information will not be generated.
 @noindent
 The command invocation for @code{gnatxref} is:
 @smallexample
-$ gnatxref [switches] sourcefile1 [sourcefile2 ...]
+$ gnatxref [switches] sourcefile1 [sourcefile2 @dots{}]
 @end smallexample
 
 @noindent
@@ -13758,12 +14616,25 @@ specifying @file{source*.adb} is the same as giving every file in the current
 directory whose name starts with @file{source} and whose extension is
 @file{adb}.
 
+You shouldn't specify any directory name, just base names. @command{gnatxref}
+and @command{gnatfind} will be able to locate these files by themselves using
+the source path. If you specify directories, no result is produced.
+
 @end table
 
 @noindent
-The switches can be :
+The switches can be:
 @table @option
 @c !sort!
+@item --version
+@cindex @option{--version} @command{gnatxref}
+Display Copyright and version, then exit disregarding all other options.
+
+@item --help
+@cindex @option{--help} @command{gnatxref}
+If @option{--version} was not used, display usage, then exit disregarding
+all other options.
+
 @item ^-a^/ALL_FILES^
 @cindex @option{^-a^/ALL_FILES^} (@command{gnatxref})
 If this switch is present, @code{gnatfind} and @code{gnatxref} will parse
@@ -13776,13 +14647,13 @@ or permissions status in the file system for the current user.
 @item -aIDIR
 @cindex @option{-aIDIR} (@command{gnatxref})
 When looking for source files also look in directory DIR. The order in which
-source file search is undertaken is the same as for @file{gnatmake}.
+source file search is undertaken is the same as for @command{gnatmake}.
 
 @item -aODIR
 @cindex @option{-aODIR} (@command{gnatxref})
 When searching for library and object files, look in directory
 DIR. The order in which library files are searched is the same as for
-@file{gnatmake}.
+@command{gnatmake}.
 
 @item -nostdinc
 @cindex @option{-nostdinc} (@command{gnatxref})
@@ -13795,7 +14666,7 @@ Do not look for library files in the system default directory.
 @item --RTS=@var{rts-path}
 @cindex @option{--RTS} (@command{gnatxref})
 Specifies the default location of the runtime library. Same meaning as the
-equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}).
+equivalent @command{gnatmake} flag (@pxref{Switches for gnatmake}).
 
 @item ^-d^/DERIVED_TYPES^
 @cindex @option{^-d^/DERIVED_TYPES^} (@command{gnatxref})
@@ -13820,8 +14691,8 @@ Equivalent to @samp{-aODIR -aIDIR}.
 
 @item -pFILE
 @cindex @option{-pFILE} (@command{gnatxref})
-Specify a project file to use @xref{Project Files}. These project files are
-the @file{.adp} files used by Glide. If you need to use the @file{.gpr}
+Specify a project file to use @xref{Project Files}.
+If you need to use the @file{.gpr}
 project files, you should use gnatxref through the GNAT driver
 (@command{gnat xref -Pproject}).
 
@@ -13841,7 +14712,7 @@ display every unused entity and 'with'ed package.
 @item -v
 Instead of producing the default output, @code{gnatxref} will generate a
 @file{tags} file that can be used by vi. For examples how to use this
-feature, see @xref{Examples of gnatxref Usage}. The tags file is output
+feature, see @ref{Examples of gnatxref Usage}. The tags file is output
 to the standard output, thus you will have to redirect it to a file.
 @end ifclear
 
@@ -13861,7 +14732,7 @@ The command line for @code{gnatfind} is:
 
 @smallexample
 $ gnatfind [switches] pattern[:sourcefile[:line[:column]]]
-      [file1 file2 ...]
+      [file1 file2 @dots{}]
 @end smallexample
 
 @noindent
@@ -13870,7 +14741,7 @@ where
 @table @code
 @item pattern
 An entity will be output only if it matches the regular expression found
-in @samp{pattern}, see @xref{Regular Expressions in gnatfind and gnatxref}.
+in @samp{pattern}, see @ref{Regular Expressions in gnatfind and gnatxref}.
 
 Omitting the pattern is equivalent to specifying @samp{*}, which
 will match any entity. Note that if you do not provide a pattern, you
@@ -13883,7 +14754,7 @@ for matching purposes. At the current time there is no support for
 @item sourcefile
 @code{gnatfind} will look for references, bodies or declarations
 of symbols referenced in @file{sourcefile}, at line @samp{line}
-and column @samp{column}. See @pxref{Examples of gnatfind Usage}
+and column @samp{column}. See @ref{Examples of gnatfind Usage}
 for syntax examples.
 
 @item line
@@ -13895,21 +14766,23 @@ is a decimal integer identifying the exact location on the
 line of the first character of the identifier for the
 entity reference. Columns are numbered from 1.
 
-@item file1 file2 ...
+@item file1 file2 @dots{}
 The search will be restricted to these source files. If none are given, then
 the search will be done for every library file in the search path.
 These file must appear only after the pattern or sourcefile.
 
 These file names are considered to be regular expressions, so for instance
-specifying 'source*.adb' is the same as giving every file in the current
-directory whose name starts with 'source' and whose extension is 'adb'.
+specifying @file{source*.adb} is the same as giving every file in the current
+directory whose name starts with @file{source} and whose extension is
+@file{adb}.
 
 The location of the spec of the entity will always be displayed, even if it
-isn't in one of file1, file2,... The occurrences of the entity in the
-separate units of the ones given on the command line will also be displayed.
+isn't in one of @file{file1}, @file{file2},@enddots{}  The occurrences
+of the entity in the separate units of the ones given on the command
+line will also be displayed.
 
 Note that if you specify at least one file in this part, @code{gnatfind} may
-sometimes not be able to find the body of the subprograms...
+sometimes not be able to find the body of the subprograms.
 
 @end table
 
@@ -13921,6 +14794,14 @@ The following switches are available:
 @table @option
 @c !sort!
 
+@cindex @option{--version} @command{gnatfind}
+Display Copyright and version, then exit disregarding all other options.
+
+@item --help
+@cindex @option{--help} @command{gnatfind}
+If @option{--version} was not used, display usage, then exit disregarding
+all other options.
+
 @item ^-a^/ALL_FILES^
 @cindex @option{^-a^/ALL_FILES^} (@command{gnatfind})
 If this switch is present, @code{gnatfind} and @code{gnatxref} will parse
@@ -13933,13 +14814,13 @@ or permission status in the file system for the current user.
 @item -aIDIR
 @cindex @option{-aIDIR} (@command{gnatfind})
 When looking for source files also look in directory DIR. The order in which
-source file search is undertaken is the same as for @file{gnatmake}.
+source file search is undertaken is the same as for @command{gnatmake}.
 
 @item -aODIR
 @cindex @option{-aODIR} (@command{gnatfind})
 When searching for library and object files, look in directory
 DIR. The order in which library files are searched is the same as for
-@file{gnatmake}.
+@command{gnatmake}.
 
 @item -nostdinc
 @cindex @option{-nostdinc} (@command{gnatfind})
@@ -13952,7 +14833,7 @@ Do not look for library files in the system default directory.
 @item --RTS=@var{rts-path}
 @cindex @option{--RTS} (@command{gnatfind})
 Specifies the default location of the runtime library. Same meaning as the
-equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}).
+equivalent @command{gnatmake} flag (@pxref{Switches for gnatmake}).
 
 @item ^-d^/DERIVED_TYPE_INFORMATION^
 @cindex @option{^-d^/DERIVED_TYPE_INFORMATION^} (@code{gnatfind})
@@ -14031,7 +14912,7 @@ you specify @code{*} at the end of the command line.
 Project files allow a programmer to specify how to compile its
 application, where to find sources, etc.  These files are used
 @ifclear vms
-primarily by the Glide Ada mode, but they can also be used
+primarily by GPS, but they can also be used
 @end ifclear
 by the two tools
 @code{gnatxref} and @code{gnatfind}.
@@ -14130,14 +15011,14 @@ specifies the command used to debug the application
 @noindent
 As specified in the section about @command{gnatfind}, the pattern can be a
 regular expression. Actually, there are to set of regular expressions
-which are recognized by the program :
+which are recognized by the program:
 
 @table @code
 @item globbing patterns
 These are the most usual regular expression. They are the same that you
 generally used in a Unix shell command line, or in a DOS session.
 
-Here is a more formal grammar :
+Here is a more formal grammar:
 @smallexample
 @group
 @iftex
@@ -14148,7 +15029,7 @@ term   ::= elmt            -- matches elmt
 term   ::= elmt elmt       -- concatenation (elmt then elmt)
 term   ::= *               -- any string of 0 or more characters
 term   ::= ?               -- matches any character
-term   ::= [char @{char@}] -- matches any character listed
+term   ::= [char @{char@}]   -- matches any character listed
 term   ::= [char - char]   -- matches any character in range
 @end group
 @end smallexample
@@ -14165,9 +15046,9 @@ reference manual style BNF is as follows
 @leftskip=.5cm
 @end iftex
 @group
-regexp ::= term @{| term@} -- alternation (term or term ...)
+regexp ::= term @{| term@}   -- alternation (term or term @dots{})
 
-term ::= item @{item@}     -- concatenation (item then item)
+term ::= item @{item@}       -- concatenation (item then item)
 
 item ::= elmt              -- match elmt
 item ::= elmt *            -- zero or more elmt's
@@ -14188,18 +15069,19 @@ nschar ::= any character except ()[].*+?^^^
 @end group
 @end smallexample
 
-Following are a few examples :
+Following are a few examples:
 
 @table @samp
 @item abcde|fghi
-will match any of the two strings 'abcde' and 'fghi'.
+will match any of the two strings @samp{abcde} and @samp{fghi},
 
 @item abc*d
-will match any string like 'abd', 'abcd', 'abccd', 'abcccd', and so on
+will match any string like @samp{abd}, @samp{abcd}, @samp{abccd},
+@samp{abcccd}, and so on,
 
 @item [a-z]+
 will match any string which has only lowercase characters in it (and at
-least one character
+least one character.
 
 @end table
 @end table
@@ -14210,7 +15092,7 @@ least one character
 @subsection General Usage
 
 @noindent
-For the following examples, we will consider the following units :
+For the following examples, we will consider the following units:
 
 @smallexample @c ada
 @group
@@ -14306,9 +15188,9 @@ of these.
 @subsection Using gnatxref with vi
 
 @code{gnatxref} can generate a tags file output, which can be used
-directly from @file{vi}. Note that the standard version of @file{vi}
+directly from @command{vi}. Note that the standard version of @command{vi}
 will not work properly with overloaded symbols. Consider using another
-free implementation of @file{vi}, such as @file{vim}.
+free implementation of @command{vi}, such as @command{vim}.
 
 @smallexample
 $ gnatxref -v gnatfind.adb > tags
@@ -14318,7 +15200,7 @@ $ gnatxref -v gnatfind.adb > tags
 will generate the tags file for @code{gnatfind} itself (if the sources
 are in the search path!).
 
-From @file{vi}, you can then use the command @samp{:tag @i{entity}}
+From @command{vi}, you can then use the command @samp{:tag @i{entity}}
 (replacing @i{entity} by whatever you are looking for), and vi will
 display a new file with the corresponding declaration of entity.
 @end ifclear
@@ -14389,7 +15271,6 @@ point to any character in the middle of the identifier.
 
 @end table
 
-
 @c *********************************
 @node The GNAT Pretty-Printer gnatpp
 @chapter The GNAT Pretty-Printer @command{gnatpp}
@@ -14410,11 +15291,22 @@ semantically legal.
 If this condition is not met, @command{gnatpp} will terminate with an
 error message; no output file will be generated.
 
+If the source files presented to @command{gnatpp} contain
+preprocessing directives, then the output file will
+correspond to the generated source after all
+preprocessing is carried out. There is no way
+using @command{gnatpp} to obtain pretty printed files that
+include the preprocessing directives.
+
 If the compilation unit
 contained in the input source depends semantically upon units located
 outside the current directory, you have to provide the source search path
-when invoking @command{gnatpp}; see the description of the @command{gnatpp}
-switches below.
+when invoking @command{gnatpp}, if these units are contained in files with
+names that do not follow the GNAT file naming rules, you have to provide
+the configuration file describing the corresponding naming scheme;
+see the description of the @command{gnatpp}
+switches below. Another possibility is to use a project file and to
+call @command{gnatpp} through the @command{gnat} driver
 
 The @command{gnatpp} command has the form
 
@@ -14437,7 +15329,6 @@ allowed.  The file name may contain path information; it does not have to
 follow the GNAT file naming rules
 @end itemize
 
-
 @menu
 * Switches for gnatpp::
 * Formatting Rules::
@@ -14499,7 +15390,6 @@ indicate the effect.
 * Other gnatpp Switches::
 @end menu
 
-
 @node Alignment Control
 @subsection Alignment Control
 @cindex Alignment control in @command{gnatpp}
@@ -14534,13 +15424,16 @@ Align @code{:=} in assignment statements
 
 @item ^-A4^/ALIGN=ARROWS^
 Align @code{=>} in associations
+
+@item ^-A5^/ALIGN=COMPONENT_CLAUSES^
+Align @code{at} keywords in the component clauses in record
+representation clauses
 @end table
 
 @noindent
 The @option{^-A^/ALIGN^} switches are mutually compatible; any combination
 is allowed.
 
-
 @node Casing Control
 @subsection Casing Control
 @cindex Casing control in @command{gnatpp}
@@ -14635,18 +15528,20 @@ The @option{^-D-^/SPECIFIC_CASING^} and
 @option{^-D@var{file}^/DICTIONARY=@var{file}^} switches are mutually
 compatible.
 
-
 @node Construct Layout Control
 @subsection Construct Layout Control
 @cindex Layout control in @command{gnatpp}
 
 @noindent
 This group of @command{gnatpp} switches controls the layout of comments and
-complex syntactic constructs.  See @ref{Formatting Comments}, for details
+complex syntactic constructs.  See @ref{Formatting Comments} for details
 on their effect.
 
 @table @option
 @cindex @option{^-c@var{n}^/COMMENTS_LAYOUT^} (@command{gnatpp})
+@item ^-c0^/COMMENTS_LAYOUT=UNTOUCHED^
+All the comments remain unchanged
+
 @item ^-c1^/COMMENTS_LAYOUT=DEFAULT^
 GNAT-style comment line indentation (this is the default).
 
@@ -14659,6 +15554,11 @@ GNAT-style comment beginning
 @item ^-c4^/COMMENTS_LAYOUT=REFORMAT^
 Reformat comment blocks
 
+@item ^-c5^/COMMENTS_LAYOUT=KEEP_SPECIAL^
+Keep unchanged special form comments
+
+Reformat comment blocks
+
 @cindex @option{^-l@var{n}^/CONSTRUCT_LAYOUT^} (@command{gnatpp})
 @item ^-l1^/CONSTRUCT_LAYOUT=GNAT^
 GNAT-style layout (this is the default)
@@ -14669,18 +15569,45 @@ Compact layout
 @item ^-l3^/CONSTRUCT_LAYOUT=UNCOMPACT^
 Uncompact layout
 
-@item ^-notab^/NOTABS^
+@cindex @option{^-N^/NOTABS^} (@command{gnatpp})
+@item ^-N^/NOTABS^
 All the VT characters are removed from the comment text. All the HT characters
 are expanded with the sequences of space characters to get to the next tab
 stops.
 
+@cindex @option{^--no-separate-is^/NO_SEPARATE_IS^} (@command{gnatpp})
+@item ^--no-separate-is^/NO_SEPARATE_IS^
+Do not place the keyword @code{is} on a separate line in a subprogram body in
+case if the specification occupies more then one line.
+
+@cindex @option{^--separate-loop-then^/SEPARATE_LOOP_THEN^} (@command{gnatpp})
+@item ^--separate-loop-then^/SEPARATE_LOOP_THEN^
+Place the keyword @code{loop} in FOR and WHILE loop statements and the
+keyword @code{then} in IF statements on a separate line.
+
+@cindex @option{^--no-separate-loop-then^/NO_SEPARATE_LOOP_THEN^} (@command{gnatpp})
+@item ^--no-separate-loop-then^/NO_SEPARATE_LOOP_THEN^
+Do not place the keyword @code{loop} in FOR and WHILE loop statements and the
+keyword @code{then} in IF statements on a separate line. This option is
+incompatible with @option{^--separate-loop-then^/SEPARATE_LOOP_THEN^} option.
+
+@cindex @option{^--use-on-new-line^/USE_ON_NEW_LINE^} (@command{gnatpp})
+@item ^--use-on-new-line^/USE_ON_NEW_LINE^
+Start each USE clause in a context clause from a separate line.
+
+@cindex @option{^--separate-stmt-name^/STMT_NAME_ON_NEW_LINE^} (@command{gnatpp})
+@item ^--separate-stmt-name^/STMT_NAME_ON_NEW_LINE^
+Use a separate line for a loop or block statement name, but do not use an extra
+indentation level for the statement itself.
+
 @end table
 
 @ifclear vms
 @noindent
 The @option{-c1} and @option{-c2} switches are incompatible.
 The @option{-c3} and @option{-c4} switches are compatible with each other and
-also with @option{-c1} and @option{-c2}.
+also with @option{-c1} and @option{-c2}. The @option{-c0} switch disables all
+the other comment formatting switches.
 
 The @option{-l1}, @option{-l2}, and @option{-l3} switches are incompatible.
 @end ifclear
@@ -14710,23 +15637,22 @@ These switches allow control over line length and indentation.
 @table @option
 @item ^-M@i{nnn}^/LINE_LENGTH_MAX=@i{nnn}^
 @cindex @option{^-M^/LINE_LENGTH^} (@command{gnatpp})
-Maximum line length, @i{nnn} from 32 ..256, the default value is 79
+Maximum line length, @i{nnn} from 32@dots{}256, the default value is 79
 
 @item ^-i@i{nnn}^/INDENTATION_LEVEL=@i{nnn}^
 @cindex @option{^-i^/INDENTATION_LEVEL^} (@command{gnatpp})
-Indentation level, @i{nnn} from 1 .. 9, the default value is 3
+Indentation level, @i{nnn} from 1@dots{}9, the default value is 3
 
 @item ^-cl@i{nnn}^/CONTINUATION_INDENT=@i{nnn}^
 @cindex @option{^-cl^/CONTINUATION_INDENT^} (@command{gnatpp})
 Indentation level for continuation lines (relative to the line being
-continued), @i{nnn} from 1 .. 9.
+continued), @i{nnn} from 1@dots{}9.
 The default
 value is one less then the (normal) indentation level, unless the
 indentation is set to 1 (in which case the default value for continuation
 line indentation is also 1)
 @end table
 
-
 @node Other Formatting Options
 @subsection Other Formatting Options
 
@@ -14786,7 +15712,6 @@ The same as the corresponding gcc switch
 
 @end table
 
-
 @node Output File Control
 @subsection Output File Control
 
@@ -14827,13 +15752,65 @@ reading or processing the input file.
 @cindex @option{^-rf^/OVERRIDING_REPLACE^} (@code{gnatpp})
 Like @option{^-r^/REPLACE^} except that if the file with the specified name
 already exists, it is overwritten.
+
+@item ^-rnb^/NO_BACKUP^
+@cindex @option{^-rnb^/NO_BACKUP^} (@code{gnatpp})
+Replace the input source file with the reformatted output without
+creating any backup copy of the input source.
+
+@item ^--eol=@var{xxx}^/END_OF_LINE=@var{xxx}^
+@cindex @option{^--eol^/END_OF_LINE^} (@code{gnatpp})
+Specifies the format of the reformatted output file. The @var{xxx}
+^string specified with the switch^option^ may be either
+@itemize @bullet
+@item ``@option{^dos^DOS^}'' MS DOS style, lines end with CR LF characters
+@item ``@option{^crlf^CRLF^}''
+the same as @option{^crlf^CRLF^}
+@item ``@option{^unix^UNIX^}'' UNIX style, lines end with LF character
+@item ``@option{^lf^LF^}''
+the same as @option{^unix^UNIX^}
+@end itemize
+
+@item ^-W^/RESULT_ENCODING=^@var{e}
+@cindex @option{^-W^/RESULT_ENCODING=^} (@command{gnatpp})
+Specify the wide character encoding method used to write the code in the
+result file
+@var{e} is one of the following:
+
+@itemize @bullet
+
+@item ^h^HEX^
+Hex encoding
+
+@item ^u^UPPER^
+Upper half encoding
+
+@item ^s^SHIFT_JIS^
+Shift/JIS encoding
+
+@item ^e^EUC^
+EUC encoding
+
+@item ^8^UTF8^
+UTF-8 encoding
+
+@item ^b^BRACKETS^
+Brackets encoding (default value)
+@end itemize
+
 @end table
 
 @noindent
 Options @option{^-pipe^/STANDARD_OUTPUT^},
 @option{^-o^/OUTPUT^} and
 @option{^-of^/FORCED_OUTPUT^} are allowed only if the call to gnatpp
-contains only one file to reformat
+contains only one file to reformat.
+Option
+@option{^--eol^/END_OF_LINE^}
+and
+@option{^-W^/RESULT_ENCODING^}
+cannot be used together
+with @option{^-pipe^/STANDARD_OUTPUT^} option.
 
 @node Other gnatpp Switches
 @subsection Other @code{gnatpp} Switches
@@ -14842,6 +15819,14 @@ contains only one file to reformat
 The additional @command{gnatpp} switches are defined in this subsection.
 
 @table @option
+@item ^-files @var{filename}^/FILES=@var{output_file}^
+@cindex @option{^-files^/FILES^} (@code{gnatpp})
+Take the argument source files from the specified file. This file should be an
+ordinary textual file containing file names separated by spaces or
+line breaks. You can use this switch more then once in the same call to
+@command{gnatpp}. You also can combine this switch with explicit list of
+files.
+
 @item ^-v^/VERBOSE^
 @cindex @option{^-v^/VERBOSE^} (@code{gnatpp})
 Verbose mode;
@@ -14851,11 +15836,10 @@ a trace of the actions it takes to produce or obtain the ASIS tree.
 @item ^-w^/WARNINGS^
 @cindex @option{^-w^/WARNINGS^} (@code{gnatpp})
 Warning mode;
-@command{gnatpp} generates a warning whenever it can not provide
+@command{gnatpp} generates a warning whenever it cannot provide
 a required layout in the result source.
 @end table
 
-
 @node Formatting Rules
 @section Formatting Rules
 
@@ -14871,7 +15855,6 @@ They provide the detailed descriptions of the switches shown above.
 * Name Casing::
 @end menu
 
-
 @node White Space and Empty Lines
 @subsection White Space and Empty Lines
 
@@ -14905,7 +15888,6 @@ In order to preserve a visual separation between comment blocks, use an
 Likewise, if for some reason you wish to have a sequence of empty lines,
 use a sequence of empty comments instead.
 
-
 @node Formatting Comments
 @subsection Formatting Comments
 
@@ -15049,11 +16031,43 @@ comments may be reformatted in typical
 word processor style (that is, moving words between lines and putting as
 many words in a line as possible).
 
+@noindent
+The @option{^-c5^/COMMENTS_LAYOUT=KEEP_SPECIAL^} switch specifies, that comments
+that has a special format (that is, a character that is neither a letter nor digit
+not white space nor line break immediately following the leading @code{--} of
+the comment) should be without any change moved from the argument source
+into reformatted source. This switch allows to preserve comments that are used
+as a special marks in the code (e.g. SPARK annotation).
 
 @node Construct Layout
 @subsection Construct Layout
 
 @noindent
+In several cases the suggested layout in the Ada Reference Manual includes
+an extra level of indentation that many programmers prefer to avoid. The
+affected cases include:
+
+@itemize @bullet
+
+@item Record type declaration (RM 3.8)
+
+@item Record representation clause (RM 13.5.1)
+
+@item Loop statement in case if a loop has a statement identifier (RM 5.6)
+
+@item Block statement in case if a block has a statement identifier (RM 5.6)
+@end itemize
+
+@noindent
+In compact mode (when GNAT style layout or compact layout is set),
+the pretty printer uses one level of indentation instead
+of two. This is achieved in the record definition and record representation
+clause cases by putting the @code{record} keyword on the same line as the
+start of the declaration or representation clause, and in the block and loop
+case by putting the block or loop header on the same line as the statement
+identifier.
+
+@noindent
 The difference between GNAT style @option{^-l1^/CONSTRUCT_LAYOUT=GNAT^}
 and compact @option{^-l2^/CONSTRUCT_LAYOUT=COMPACT^}
 layout on the one hand, and uncompact layout
@@ -15083,6 +16097,22 @@ type q is
 
 @item
 @smallexample @c ada
+for q use record
+   a at 0 range  0 .. 31;
+   b at 4 range  0 .. 31;
+end record;
+@end smallexample
+@tab
+@smallexample @c ada
+for q use
+   record
+      a at 0 range  0 .. 31;
+      b at 4 range  0 .. 31;
+   end record;
+@end smallexample
+
+@item
+@smallexample @c ada
 Block : declare
    A : Integer := 3;
 begin
@@ -15127,6 +16157,11 @@ type q is record                        type q is
 end record;                                   b : integer;
                                            end record;
 
+for q use record                        for q use
+   a at 0 range  0 .. 31;                  record
+   b at 4 range  0 .. 31;                     a at 0 range  0 .. 31;
+end record;                                   b at 4 range  0 .. 31;
+                                           end record;
 
 Block : declare                         Block :
    A : Integer := 3;                       declare
@@ -15148,6 +16183,12 @@ A further difference between GNAT style layout and compact layout is that
 GNAT style layout inserts empty lines as separation for
 compound statements, return statements and bodies.
 
+Note that the layout specified by
+@option{^--separate-stmt-name^/STMT_NAME_ON_NEW_LINE^}
+for named block and loop statements overrides the layout defined by these
+constructs by @option{^-l1^/CONSTRUCT_LAYOUT=GNAT^},
+@option{^-l2^/CONSTRUCT_LAYOUT=COMPACT^} or
+@option{^-l3^/CONSTRUCT_LAYOUT=UNCOMPACT^} option.
 
 @node Name Casing
 @subsection Name Casing
@@ -15220,16 +16261,15 @@ A casing schema is a string that has the following syntax:
 
 @smallexample
 @cartouche
-  @var{casing_schema} ::= @var{identifier} | [*]@var{simple_identifier}[*]
+  @var{casing_schema} ::= @var{identifier} | *@var{simple_identifier}*
 
   @var{simple_identifier} ::= @var{letter}@{@var{letter_or_digit}@}
 @end cartouche
 @end smallexample
 
 @noindent
-(The @code{[]} metanotation stands for an optional part;
-see @cite{Ada Reference Manual}, Section 2.3) for the definition of the
-@var{identifier} lexical element and the @var{letter_or_digit} category).
+(See @cite{Ada Reference Manual}, Section 2.3) for the definition of the
+@var{identifier} lexical element and the @var{letter_or_digit} category.)
 
 The casing schema string can be followed by white space and/or an Ada-style
 comment; any amount of white space is allowed before the string.
@@ -15253,22 +16293,16 @@ if the whole name is in the dictionary, @command{gnatpp} uses for this name
 the casing defined by the dictionary; no subwords are checked for this word
 
 @item
-for the first subword (that is, for the subword preceding the leftmost
-``_''), @command{gnatpp} checks if the dictionary contains the corresponding
-string of the form @code{@var{simple_identifier}*}, and if it does, the
-casing of this @var{simple_identifier} is used for this subword
-
-@item
-for the last subword (following the rightmost ``_'') @command{gnatpp}
-checks if the dictionary contains the corresponding string of the form
-@code{*@var{simple_identifier}}, and if it does, the casing of this
-@var{simple_identifier} is used for this subword
+for every subword @command{gnatpp} checks if the dictionary contains the
+corresponding string of the form @code{*@var{simple_identifier}*},
+and if it does, the casing of this @var{simple_identifier} is used
+for this subword
 
 @item
-for every intermediate subword (surrounded by two'_') @command{gnatpp} checks
-if the dictionary contains the corresponding string of the form
-@code{*@var{simple_identifier}*}, and if it does, the casing of this
-simple_identifier is used for this subword
+if the whole name does not contain any ``_'' inside, and if for this name
+the dictionary contains two entries - one of the form @var{identifier},
+and another - of the form *@var{simple_identifier}*, then the first one
+is applied to define the casing of this name
 
 @item
 if more than one dictionary file is passed as @command{gnatpp} switches, each
@@ -15304,7 +16338,7 @@ And suppose we have two dictionaries:
 @i{dict1:}
    NAME1
    *NaMe3*
-   *NAME2
+   *Name1*
 @end cartouche
 
 @cartouche
@@ -15332,10157 +16366,12424 @@ then we will get the following name casing in the @command{gnatpp} output:
 @cartouche
 procedure Test is
    NAME1             : Integer := 1;
-   Name4_NAME3_NAME2 : integer := 2;
+   Name4_NAME3_Name2 : Integer := 2;
    Name2_NAME3_Name4 : Boolean;
    Name1_Var         : Float;
 begin
-   Name2_NAME3_Name4 := Name4_NAME3_NAME2 > NAME1;
+   Name2_NAME3_Name4 := Name4_NAME3_Name2 > NAME1;
 end Test;
 @end cartouche
 @end smallexample
 
+@c *********************************
+@node The GNAT Metric Tool gnatmetric
+@chapter The GNAT Metric Tool @command{gnatmetric}
+@findex gnatmetric
+@cindex Metric tool
 
+@noindent
+^The @command{gnatmetric} tool^@command{GNAT METRIC}^ is an ASIS-based utility
+for computing various program metrics.
+It takes an Ada source file as input and generates a file containing the
+metrics data as output. Various switches control which
+metrics are computed and output.
 
-@c ***********************************
-@node File Name Krunching Using gnatkr
-@chapter File Name Krunching Using @code{gnatkr}
-@findex gnatkr
+@command{gnatmetric} generates and uses the ASIS
+tree for the input source and thus requires the input to be syntactically and
+semantically legal.
+If this condition is not met, @command{gnatmetric} will generate
+an error message; no metric information for this file will be
+computed and reported.
 
-@noindent
-This chapter discusses the method used by the compiler to shorten
-the default file names chosen for Ada units so that they do not
-exceed the maximum length permitted. It also describes the
-@code{gnatkr} utility that can be used to determine the result of
-applying this shortening.
-@menu
-* About gnatkr::
-* Using gnatkr::
-* Krunching Method::
-* Examples of gnatkr Usage::
-@end menu
+If the compilation unit contained in the input source depends semantically
+upon units in files located outside the current directory, you have to provide
+the source search path when invoking @command{gnatmetric}.
+If it depends semantically upon units that are contained
+in files with names that do not follow the GNAT file naming rules, you have to
+provide the configuration file describing the corresponding naming scheme (see
+the description of the @command{gnatmetric} switches below.)
+Alternatively, you may use a project file and invoke @command{gnatmetric}
+through the @command{gnat} driver.
 
-@node About gnatkr
-@section About @code{gnatkr}
+The @command{gnatmetric} command has the form
+
+@smallexample
+$ gnatmetric [@i{switches}] @{@i{filename}@} [@i{-cargs gcc_switches}]
+@end smallexample
 
 @noindent
-The default file naming rule in GNAT
-is that the file name must be derived from
-the unit name. The exact default rule is as follows:
+where
 @itemize @bullet
 @item
-Take the unit name and replace all dots by hyphens.
+@i{switches} specify the metrics to compute and define the destination for
+the output
+
 @item
-If such a replacement occurs in the
-second character position of a name, and the first character is
-^a, g, s, or i^A, G, S, or I^ then replace the dot by the character
-^~ (tilde)^$ (dollar sign)^
-instead of a minus.
-@end itemize
-The reason for this exception is to avoid clashes
-with the standard names for children of System, Ada, Interfaces,
-and GNAT, which use the prefixes ^s- a- i- and g-^S- A- I- and G-^
-respectively.
+Each @i{filename} is the name (including the extension) of a source
+file to process. ``Wildcards'' are allowed, and
+the file name may contain path information.
+If no @i{filename} is supplied, then the @i{switches} list must contain
+at least one
+@option{-files} switch (@pxref{Other gnatmetric Switches}).
+Including both a @option{-files} switch and one or more
+@i{filename} arguments is permitted.
 
-The @option{^-gnatk^/FILE_NAME_MAX_LENGTH=^@var{nn}}
-switch of the compiler activates a ``krunching''
-circuit that limits file names to nn characters (where nn is a decimal
-integer). For example, using OpenVMS,
-where the maximum file name length is
-39, the value of nn is usually set to 39, but if you want to generate
-a set of files that would be usable if ported to a system with some
-different maximum file length, then a different value can be specified.
-The default value of 39 for OpenVMS need not be specified.
+@item
+@i{-cargs gcc_switches} is a list of switches for
+@command{gcc}. They will be passed on to all compiler invocations made by
+@command{gnatmetric} to generate the ASIS trees. Here you can provide
+@option{^-I^/INCLUDE_DIRS=^} switches to form the source search path,
+and use the @option{-gnatec} switch to set the configuration file.
+@end itemize
 
-The @code{gnatkr} utility can be used to determine the krunched name for
-a given file, when krunched to a specified maximum length.
+@menu
+* Switches for gnatmetric::
+@end menu
 
-@node Using gnatkr
-@section Using @code{gnatkr}
+@node Switches for gnatmetric
+@section Switches for @command{gnatmetric}
 
 @noindent
-The @code{gnatkr} command has the form
+The following subsections describe the various switches accepted by
+@command{gnatmetric}, organized by category.
 
-@ifclear vms
-@smallexample
-$ gnatkr @var{name} [@var{length}]
-@end smallexample
-@end ifclear
+@menu
+* Output Files Control::
+* Disable Metrics For Local Units::
+* Specifying a set of metrics to compute::
+* Other gnatmetric Switches::
+* Generate project-wide metrics::
+@end menu
 
-@ifset vms
-@smallexample
-$ gnatkr @var{name} /COUNT=nn
-@end smallexample
-@end ifset
+@node Output Files Control
+@subsection Output File Control
+@cindex Output file control in @command{gnatmetric}
 
 @noindent
-@var{name} is the uncrunched file name, derived from the name of the unit
-in the standard manner described in the previous section (i.e. in particular
-all dots are replaced by hyphens). The file name may or may not have an
-extension (defined as a suffix of the form period followed by arbitrary
-characters other than period). If an extension is present then it will
-be preserved in the output. For example, when krunching @file{hellofile.ads}
-to eight characters, the result will be hellofil.ads.
+@command{gnatmetric} has two output formats. It can generate a
+textual (human-readable) form, and also XML. By default only textual
+output is generated.
 
-Note: for compatibility with previous versions of @code{gnatkr} dots may
-appear in the name instead of hyphens, but the last dot will always be
-taken as the start of an extension. So if @code{gnatkr} is given an argument
-such as @file{Hello.World.adb} it will be treated exactly as if the first
-period had been a hyphen, and for example krunching to eight characters
-gives the result @file{hellworl.adb}.
+When generating the output in textual form, @command{gnatmetric} creates
+for each Ada source file a corresponding text file
+containing the computed metrics, except for the case when the set of metrics
+specified by gnatmetric parameters consists only of metrics that are computed
+for the whole set of analyzed sources, but not for each Ada source.
+By default, this file is placed in the same directory as where the source
+file is located, and its name is obtained
+by appending the ^@file{.metrix}^@file{$METRIX}^ suffix to the name of the
+input file.
 
-Note that the result is always all lower case (except on OpenVMS where it is
-all upper case). Characters of the other case are folded as required.
+All the output information generated in XML format is placed in a single
+file. By default this file is placed in the current directory and has the
+name ^@file{metrix.xml}^@file{METRIX$XML}^.
 
-@var{length} represents the length of the krunched name. The default
-when no argument is given is ^8^39^ characters. A length of zero stands for
-unlimited, in other words do not chop except for system files where the
-impled crunching length is always eight characters.
+Some of the computed metrics are summed over the units passed to
+@command{gnatmetric}; for example, the total number of lines of code.
+By default this information is sent to @file{stdout}, but a file
+can be specified with the @option{-og} switch.
 
-@noindent
-The output is the krunched name. The output has an extension only if the
-original argument was a file name with an extension.
+The following switches control the @command{gnatmetric} output:
 
-@node Krunching Method
-@section Krunching Method
+@table @option
+@cindex @option{^-x^/XML^} (@command{gnatmetric})
+@item ^-x^/XML^
+Generate the XML output
+
+@cindex @option{^-nt^/NO_TEXT^} (@command{gnatmetric})
+@item ^-nt^/NO_TEXT^
+Do not generate the output in text form (implies @option{^-x^/XML^})
+
+@cindex @option{^-d^/DIRECTORY^} (@command{gnatmetric})
+@item ^-d @var{output_dir}^/DIRECTORY=@var{output_dir}^
+Put textual files with detailed metrics into @var{output_dir}
+
+@cindex @option{^-o^/SUFFIX_DETAILS^} (@command{gnatmetric})
+@item ^-o @var{file_suffix}^/SUFFIX_DETAILS=@var{file_suffix}^
+Use @var{file_suffix}, instead of ^@file{.metrix}^@file{$METRIX}^
+in the name of the output file.
+
+@cindex @option{^-og^/GLOBAL_OUTPUT^} (@command{gnatmetric})
+@item ^-og @var{file_name}^/GLOBAL_OUTPUT=@var{file_name}^
+Put global metrics into @var{file_name}
+
+@cindex @option{^-ox^/XML_OUTPUT^} (@command{gnatmetric})
+@item ^-ox @var{file_name}^/XML_OUTPUT=@var{file_name}^
+Put the XML output into @var{file_name} (also implies @option{^-x^/XML^})
+
+@cindex @option{^-sfn^/SHORT_SOURCE_FILE_NAME^} (@command{gnatmetric})
+@item ^-sfn^/SHORT_SOURCE_FILE_NAME^
+Use ``short'' source file names in the output.  (The @command{gnatmetric}
+output includes the name(s) of the Ada source file(s) from which the metrics
+are computed.  By default each name includes the absolute path. The
+@option{^-sfn^/SHORT_SOURCE_FILE_NAME^} switch causes @command{gnatmetric}
+to exclude all directory information from the file names that are output.)
+
+@end table
+
+@node Disable Metrics For Local Units
+@subsection Disable Metrics For Local Units
+@cindex Disable Metrics For Local Units in @command{gnatmetric}
 
 @noindent
-The initial file name is determined by the name of the unit that the file
-contains. The name is formed by taking the full expanded name of the
-unit and replacing the separating dots with hyphens and
-using ^lowercase^uppercase^
-for all letters, except that a hyphen in the second character position is
-replaced by a ^tilde^dollar sign^ if the first character is
-^a, i, g, or s^A, I, G, or S^.
-The extension is @code{.ads} for a
-specification and @code{.adb} for a body.
-Krunching does not affect the extension, but the file name is shortened to
-the specified length by following these rules:
+@command{gnatmetric} relies on the GNAT compilation model @minus{}
+one compilation
+unit per one source file. It computes line metrics for the whole source
+file, and it also computes syntax
+and complexity metrics for the file's outermost unit.
+
+By default, @command{gnatmetric} will also compute all metrics for certain
+kinds of locally declared program units:
 
 @itemize @bullet
 @item
-The name is divided into segments separated by hyphens, tildes or
-underscores and all hyphens, tildes, and underscores are
-eliminated. If this leaves the name short enough, we are done.
+subprogram (and generic subprogram) bodies;
 
 @item
-If the name is too long, the longest segment is located (left-most
-if there are two of equal length), and shortened by dropping
-its last character. This is repeated until the name is short enough.
-
-As an example, consider the krunching of @*@file{our-strings-wide_fixed.adb}
-to fit the name into 8 characters as required by some operating systems.
+package (and generic package) specifications and bodies;
 
-@smallexample
-our-strings-wide_fixed 22
-our strings wide fixed 19
-our string  wide fixed 18
-our strin   wide fixed 17
-our stri    wide fixed 16
-our stri    wide fixe  15
-our str     wide fixe  14
-our str     wid  fixe  13
-our str     wid  fix   12
-ou  str     wid  fix   11
-ou  st      wid  fix   10
-ou  st      wi   fix   9
-ou  st      wi   fi    8
-Final file name: oustwifi.adb
-@end smallexample
+@item
+task object and type specifications and bodies;
 
 @item
-The file names for all predefined units are always krunched to eight
-characters. The krunching of these predefined units uses the following
-special prefix replacements:
+protected object and type specifications and bodies.
+@end itemize
 
-@table @file
-@item ada-
-replaced by @file{^a^A^-}
+@noindent
+These kinds of entities will be referred to as
+@emph{eligible local program units}, or simply @emph{eligible local units},
+@cindex Eligible local unit (for @command{gnatmetric})
+in the discussion below.
 
-@item gnat-
-replaced by @file{^g^G^-}
+Note that a subprogram declaration, generic instantiation,
+or renaming declaration only receives metrics
+computation when it appear as the outermost entity
+in a source file.
 
-@item interfaces-
-replaced by @file{^i^I^-}
+Suppression of metrics computation for eligible local units can be
+obtained via the following switch:
+
+@table @option
+@cindex @option{^-n@var{x}^/SUPPRESS^} (@command{gnatmetric})
+@item ^-nolocal^/SUPPRESS=LOCAL_DETAILS^
+Do not compute detailed metrics for eligible local program units
 
-@item system-
-replaced by @file{^s^S^-}
 @end table
 
-These system files have a hyphen in the second character position. That
-is why normal user files replace such a character with a
-^tilde^dollar sign^, to
-avoid confusion with system file names.
+@node Specifying a set of metrics to compute
+@subsection Specifying a set of metrics to compute
 
-As an example of this special rule, consider
-@*@file{ada-strings-wide_fixed.adb}, which gets krunched as follows:
+@noindent
+By default all the metrics are computed and reported. The switches
+described in this subsection allow you to control, on an individual
+basis, whether metrics are computed and
+reported. If at least one positive metric
+switch is specified (that is, a switch that defines that a given
+metric or set of metrics is to be computed), then only
+explicitly specified metrics are reported.
 
-@smallexample
-ada-strings-wide_fixed 22
-a-  strings wide fixed 18
-a-  string  wide fixed 17
-a-  strin   wide fixed 16
-a-  stri    wide fixed 15
-a-  stri    wide fixe  14
-a-  str     wide fixe  13
-a-  str     wid  fixe  12
-a-  str     wid  fix   11
-a-  st      wid  fix   10
-a-  st      wi   fix   9
-a-  st      wi   fi    8
-Final file name: a-stwifi.adb
-@end smallexample
-@end itemize
+@menu
+* Line Metrics Control::
+* Syntax Metrics Control::
+* Complexity Metrics Control::
+@end menu
 
-Of course no file shortening algorithm can guarantee uniqueness over all
-possible unit names, and if file name krunching is used then it is your
-responsibility to ensure that no name clashes occur. The utility
-program @code{gnatkr} is supplied for conveniently determining the
-krunched name of a file.
+@node Line Metrics Control
+@subsubsection Line Metrics Control
+@cindex Line metrics control in @command{gnatmetric}
 
-@node Examples of gnatkr Usage
-@section Examples of @code{gnatkr} Usage
+@noindent
+For any (legal) source file, and for each of its
+eligible local program units, @command{gnatmetric} computes the following
+metrics:
 
-@smallexample
-@iftex
-@leftskip=0cm
-@end iftex
-@ifclear vms
-$ gnatkr very_long_unit_name.ads      --> velounna.ads
-$ gnatkr grandparent-parent-child.ads --> grparchi.ads
-$ gnatkr Grandparent.Parent.Child.ads --> grparchi.ads
-$ gnatkr grandparent-parent-child     --> grparchi
-@end ifclear
-$ gnatkr very_long_unit_name.ads/count=6 --> vlunna.ads
-$ gnatkr very_long_unit_name.ads/count=0 --> very_long_unit_name.ads
-@end smallexample
+@itemize @bullet
+@item
+the total number of lines;
 
-@node Preprocessing Using gnatprep
-@chapter Preprocessing Using @code{gnatprep}
-@findex gnatprep
+@item
+the total number of code lines (i.e., non-blank lines that are not comments)
 
-@noindent
-The @code{gnatprep} utility provides
-a simple preprocessing capability for Ada programs.
-It is designed for use with GNAT, but is not dependent on any special
-features of GNAT.
+@item
+the number of comment lines
 
-@menu
-* Using gnatprep::
-* Switches for gnatprep::
-* Form of Definitions File::
-* Form of Input Text for gnatprep::
-@end menu
+@item
+the number of code lines containing end-of-line comments;
 
-@node Using gnatprep
-@section Using @code{gnatprep}
+@item
+the comment percentage: the ratio between the number of lines that contain
+comments and the number of all non-blank lines, expressed as a percentage;
 
-@noindent
-To call @code{gnatprep} use
+@item
+the number of empty lines and lines containing only space characters and/or
+format effectors (blank lines)
 
-@smallexample
-$ gnatprep [-bcrsu] [-Dsymbol=value] infile outfile [deffile]
-@end smallexample
+@item
+the average number of code lines in subprogram bodies, task bodies, entry
+bodies and statement sequences in package bodies (this metric is only computed
+across the whole set of the analyzed units)
+
+@end itemize
 
 @noindent
-where
-@table @code
-@item infile
-is the full name of the input file, which is an Ada source
-file containing preprocessor directives.
+@command{gnatmetric} sums the values of the line metrics for all the
+files being processed and then generates the cumulative results. The tool
+also computes for all the files being processed the average number of code
+lines in bodies.
 
-@item outfile
-is the full name of the output file, which is an Ada source
-in standard Ada form. When used with GNAT, this file name will
-normally have an ads or adb suffix.
+You can use the following switches to select the specific line metrics
+to be computed and reported.
 
-@item deffile
-is the full name of a text file containing definitions of
-symbols to be referenced by the preprocessor. This argument is
-optional, and can be replaced by the use of the @option{-D} switch.
+@table @option
+@cindex @option{^--lines@var{x}^/LINE_COUNT_METRICS^} (@command{gnatmetric})
 
-@item switches
-is an optional sequence of switches as described in the next section.
-@end table
+@ifclear vms
+@cindex @option{--no-lines@var{x}}
+@end ifclear
 
-@node Switches for gnatprep
-@section Switches for @code{gnatprep}
+@item ^--lines-all^/LINE_COUNT_METRICS=ALL_ON^
+Report all the line metrics
 
-@table @option
-@c !sort!
+@item ^--no-lines-all^/LINE_COUNT_METRICS=ALL_OFF^
+Do not report any of line metrics
 
-@item ^-b^/BLANK_LINES^
-@cindex @option{^-b^/BLANK_LINES^} (@command{gnatprep})
-Causes both preprocessor lines and the lines deleted by
-preprocessing to be replaced by blank lines in the output source file,
-preserving line numbers in the output file.
+@item ^--lines^/LINE_COUNT_METRICS=ALL_LINES_ON^
+Report the number of all lines
 
-@item ^-c^/COMMENTS^
-@cindex @option{^-c^/COMMENTS^} (@command{gnatprep})
-Causes both preprocessor lines and the lines deleted
-by preprocessing to be retained in the output source as comments marked
-with the special string @code{"--! "}. This option will result in line numbers
-being preserved in the output file.
+@item ^--no-lines^/LINE_COUNT_METRICS=ALL_LINES_OFF^
+Do not report the number of all lines
 
-@item ^-Dsymbol=value^/ASSOCIATE="symbol=value"^
-@cindex @option{^-D^/ASSOCIATE^} (@command{gnatprep})
-Defines a new symbol, associated with value. If no value is given on the
-command line, then symbol is considered to be @code{True}. This switch
-can be used in place of a definition file.
+@item ^--lines-code^/LINE_COUNT_METRICS=CODE_LINES_ON^
+Report the number of code lines
 
-@ifset vms
-@item /REMOVE
-@cindex @option{/REMOVE} (@command{gnatprep})
-This is the default setting which causes lines deleted by preprocessing
-to be entirely removed from the output file.
-@end ifset
+@item ^--no-lines-code^/LINE_COUNT_METRICS=CODE_LINES_OFF^
+Do not report the number of code lines
 
-@item ^-r^/REFERENCE^
-@cindex @option{^-r^/REFERENCE^} (@command{gnatprep})
-Causes a @code{Source_Reference} pragma to be generated that
-references the original input file, so that error messages will use
-the file name of this original file. The use of this switch implies
-that preprocessor lines are not to be removed from the file, so its
-use will force @option{^-b^/BLANK_LINES^} mode if
-@option{^-c^/COMMENTS^}
-has not been specified explicitly.
+@item ^--lines-comment^/LINE_COUNT_METRICS=COMMENT_LINES_ON^
+Report the number of comment lines
 
-Note that if the file to be preprocessed contains multiple units, then
-it will be necessary to @code{gnatchop} the output file from
-@code{gnatprep}. If a @code{Source_Reference} pragma is present
-in the preprocessed file, it will be respected by
-@code{gnatchop ^-r^/REFERENCE^}
-so that the final chopped files will correctly refer to the original
-input source file for @code{gnatprep}.
+@item ^--no-lines-comment^/LINE_COUNT_METRICS=COMMENT_LINES_OFF^
+Do not report the number of comment lines
 
-@item ^-s^/SYMBOLS^
-@cindex @option{^-s^/SYMBOLS^} (@command{gnatprep})
-Causes a sorted list of symbol names and values to be
-listed on the standard output file.
+@item ^--lines-eol-comment^/LINE_COUNT_METRICS=CODE_COMMENT_LINES_ON^
+Report the number of code lines containing
+end-of-line comments
 
-@item ^-u^/UNDEFINED^
-@cindex @option{^-u^/UNDEFINED^} (@command{gnatprep})
-Causes undefined symbols to be treated as having the value FALSE in the context
-of a preprocessor test. In the absence of this option, an undefined symbol in
-a @code{#if} or @code{#elsif} test will be treated as an error.
+@item ^--no-lines-eol-comment^/LINE_COUNT_METRICS=CODE_COMMENT_LINES_OFF^
+Do not report the number of code lines containing
+end-of-line comments
+
+@item ^--lines-ratio^/LINE_COUNT_METRICS=COMMENT_PERCENTAGE_ON^
+Report the comment percentage in the program text
+
+@item ^--no-lines-ratio^/LINE_COUNT_METRICS=COMMENT_PERCENTAGE_OFF^
+Do not report the comment percentage in the program text
+
+@item ^--lines-blank^/LINE_COUNT_METRICS=BLANK_LINES_ON^
+Report the number of blank lines
+
+@item ^--no-lines-blank^/LINE_COUNT_METRICS=BLANK_LINES_OFF^
+Do not report the number of blank lines
+
+@item ^--lines-average^/LINE_COUNT_METRICS=AVERAGE_BODY_LINES_ON^
+Report the average number of code lines in subprogram bodies, task bodies,
+entry bodies and statement sequences in package bodies. The metric is computed
+and reported for the whole set of processed Ada sources only.
+
+@item ^--no-lines-average^/LINE_COUNT_METRICS=AVERAGE_BODY_LINES_OFF^
+Do not report the average number of code lines in subprogram bodies,
+task bodies, entry bodies and statement sequences in package bodies.
 
 @end table
 
-@ifclear vms
+@node Syntax Metrics Control
+@subsubsection Syntax Metrics Control
+@cindex Syntax metrics control in @command{gnatmetric}
+
 @noindent
-Note: if neither @option{-b} nor @option{-c} is present,
-then preprocessor lines and
-deleted lines are completely removed from the output, unless -r is
-specified, in which case -b is assumed.
-@end ifclear
+@command{gnatmetric} computes various syntactic metrics for the
+outermost unit and for each eligible local unit:
 
-@node Form of Definitions File
-@section Form of Definitions File
+@table @emph
+@item LSLOC (``Logical Source Lines Of Code'')
+The total number of declarations and the total number of statements
+
+@item Maximal static nesting level of inner program units
+According to
+@cite{Ada Reference Manual}, 10.1(1), ``A program unit is either a
+package, a task unit, a protected unit, a
+protected entry, a generic unit, or an explicitly declared subprogram other
+than an enumeration literal.''
+
+@item Maximal nesting level of composite syntactic constructs
+This corresponds to the notion of the
+maximum nesting level in the GNAT built-in style checks
+(@pxref{Style Checking})
+@end table
 
 @noindent
-The definitions file contains lines of the form
+For the outermost unit in the file, @command{gnatmetric} additionally computes
+the following metrics:
 
-@smallexample
-symbol := value
-@end smallexample
+@table @emph
+@item Public subprograms
+This metric is computed for package specifications. It is the
+number of subprograms and generic subprograms declared in the visible
+part (including the visible part of nested packages, protected objects, and
+protected types).
+
+@item All subprograms
+This metric is computed for bodies and subunits. The
+metric is equal to a total number of subprogram bodies in the compilation
+unit.
+Neither generic instantiations nor renamings-as-a-body nor body stubs
+are counted. Any subprogram body is counted, independently of its nesting
+level and enclosing constructs. Generic bodies and bodies of protected
+subprograms are counted in the same way as ``usual'' subprogram bodies.
+
+@item Public types
+This metric is computed for package specifications and
+generic package declarations. It is the total number of types
+that can be referenced from outside this compilation unit, plus the
+number of types from all the visible parts of all the visible generic
+packages. Generic formal types are not counted.  Only types, not subtypes,
+are included.
 
 @noindent
-where symbol is an identifier, following normal Ada (case-insensitive)
-rules for its syntax, and value is one of the following:
+Along with the total number of public types, the following
+types are counted and reported separately:
 
 @itemize @bullet
 @item
-Empty, corresponding to a null substitution
+Abstract types
+
 @item
-A string literal using normal Ada syntax
+Root tagged types (abstract, non-abstract, private, non-private). Type
+extensions are @emph{not} counted
+
 @item
-Any sequence of characters from the set
-(letters, digits, period, underline).
+Private types (including private extensions)
+
+@item
+Task types
+
+@item
+Protected types
+
 @end itemize
 
-@noindent
-Comment lines may also appear in the definitions file, starting with
-the usual @code{--},
-and comments may be added to the definitions lines.
+@item All types
+This metric is computed for any compilation unit. It is equal to the total
+number of the declarations of different types given in the compilation unit.
+The private and the corresponding full type declaration are counted as one
+type declaration. Incomplete type declarations and generic formal types
+are not counted.
+No distinction is made among different kinds of types (abstract,
+private etc.); the total number of types is computed and reported.
 
-@node Form of Input Text for gnatprep
-@section Form of Input Text for @code{gnatprep}
+@end table
 
 @noindent
-The input text may contain preprocessor conditional inclusion lines,
-as well as general symbol substitution sequences.
+By default, all the syntax metrics are computed and reported. You can use the
+following switches to select specific syntax metrics.
 
-The preprocessor conditional inclusion commands have the form
+@table @option
 
-@smallexample
-@group
-@cartouche
-#if @i{expression} [then]
-   lines
-#elsif @i{expression} [then]
-   lines
-#elsif @i{expression} [then]
-   lines
-...
-#else
-   lines
-#end if;
-@end cartouche
-@end group
-@end smallexample
+@cindex @option{^--syntax@var{x}^/SYNTAX_METRICS^} (@command{gnatmetric})
 
-@noindent
-In this example, @i{expression} is defined by the following grammar:
-@smallexample
-@i{expression} ::=  <symbol>
-@i{expression} ::=  <symbol> = "<value>"
-@i{expression} ::=  <symbol> = <symbol>
-@i{expression} ::=  <symbol> 'Defined
-@i{expression} ::=  not @i{expression}
-@i{expression} ::=  @i{expression} and @i{expression}
-@i{expression} ::=  @i{expression} or @i{expression}
-@i{expression} ::=  @i{expression} and then @i{expression}
-@i{expression} ::=  @i{expression} or else @i{expression}
-@i{expression} ::=  ( @i{expression} )
-@end smallexample
+@ifclear vms
+@cindex @option{--no-syntax@var{x}}
+@end ifclear
 
-@noindent
-For the first test (@i{expression} ::= <symbol>) the symbol must have
-either the value true or false, that is to say the right-hand of the
-symbol definition must be one of the (case-insensitive) literals
-@code{True} or @code{False}. If the value is true, then the
-corresponding lines are included, and if the value is false, they are
-excluded.
+@item ^--syntax-all^/SYNTAX_METRICS=ALL_ON^
+Report all the syntax metrics
 
-The test (@i{expression} ::= <symbol> @code{'Defined}) is true only if
-the symbol has been defined in the definition file or by a @option{-D}
-switch on the command line. Otherwise, the test is false.
+@item ^--no-syntax-all^/ALL_OFF^
+Do not report any of syntax metrics
 
-The equality tests are case insensitive, as are all the preprocessor lines.
+@item ^--declarations^/SYNTAX_METRICS=DECLARATIONS_ON^
+Report the total number of declarations
 
-If the symbol referenced is not defined in the symbol definitions file,
-then the effect depends on whether or not switch @option{-u}
-is specified. If so, then the symbol is treated as if it had the value
-false and the test fails. If this switch is not specified, then
-it is an error to reference an undefined symbol. It is also an error to
-reference a symbol that is defined with a value other than @code{True}
-or @code{False}.
+@item ^--no-declarations^/SYNTAX_METRICS=DECLARATIONS_OFF^
+Do not report the total number of declarations
 
-The use of the @code{not} operator inverts the sense of this logical test, so
-that the lines are included only if the symbol is not defined.
-The @code{then} keyword is optional as shown
+@item ^--statements^/SYNTAX_METRICS=STATEMENTS_ON^
+Report the total number of statements
 
-The @code{#} must be the first non-blank character on a line, but
-otherwise the format is free form. Spaces or tabs may appear between
-the @code{#} and the keyword. The keywords and the symbols are case
-insensitive as in normal Ada code. Comments may be used on a
-preprocessor line, but other than that, no other tokens may appear on a
-preprocessor line. Any number of @code{elsif} clauses can be present,
-including none at all. The @code{else} is optional, as in Ada.
-
-The @code{#} marking the start of a preprocessor line must be the first
-non-blank character on the line, i.e. it must be preceded only by
-spaces or horizontal tabs.
-
-Symbol substitution outside of preprocessor lines is obtained by using
-the sequence
+@item ^--no-statements^/SYNTAX_METRICS=STATEMENTS_OFF^
+Do not report the total number of statements
 
-@smallexample
-$symbol
-@end smallexample
+@item ^--public-subprograms^/SYNTAX_METRICS=PUBLIC_SUBPROGRAMS_ON^
+Report the number of public subprograms in a compilation unit
 
-@noindent
-anywhere within a source line, except in a comment or within a
-string literal. The identifier
-following the @code{$} must match one of the symbols defined in the symbol
-definition file, and the result is to substitute the value of the
-symbol in place of @code{$symbol} in the output file.
+@item ^--no-public-subprograms^/SYNTAX_METRICS=PUBLIC_SUBPROGRAMS_OFF^
+Do not report the number of public subprograms in a compilation unit
 
-Note that although the substitution of strings within a string literal
-is not possible, it is possible to have a symbol whose defined value is
-a string literal. So instead of setting XYZ to @code{hello} and writing:
+@item ^--all-subprograms^/SYNTAX_METRICS=ALL_SUBPROGRAMS_ON^
+Report the number of all the subprograms in a compilation unit
 
-@smallexample
-Header : String := "$XYZ";
-@end smallexample
+@item ^--no-all-subprograms^/SYNTAX_METRICS=ALL_SUBPROGRAMS_OFF^
+Do not report the number of all the subprograms in a compilation unit
 
-@noindent
-you should set XYZ to @code{"hello"} and write:
+@item ^--public-types^/SYNTAX_METRICS=PUBLIC_TYPES_ON^
+Report the number of public types in a compilation unit
 
-@smallexample
-Header : String := $XYZ;
-@end smallexample
+@item ^--no-public-types^/SYNTAX_METRICS=PUBLIC_TYPES_OFF^
+Do not report the number of public types in a compilation unit
 
-@noindent
-and then the substitution will occur as desired.
+@item ^--all-types^/SYNTAX_METRICS=ALL_TYPES_ON^
+Report the number of all the types in a compilation unit
 
-@ifset vms
-@node The GNAT Run-Time Library Builder gnatlbr
-@chapter The GNAT Run-Time Library Builder @code{gnatlbr}
-@findex gnatlbr
-@cindex Library builder
+@item ^--no-all-types^/SYNTAX_METRICS=ALL_TYPES_OFF^
+Do not report the number of all the types in a compilation unit
 
-@noindent
-@code{gnatlbr} is a tool for rebuilding the GNAT run time with user
-supplied configuration pragmas.
+@item ^--unit-nesting^/SYNTAX_METRICS=UNIT_NESTING_ON^
+Report the maximal program unit nesting level
 
-@menu
-* Running gnatlbr::
-* Switches for gnatlbr::
-* Examples of gnatlbr Usage::
-@end menu
+@item ^--no-unit-nesting^/SYNTAX_METRICS=UNIT_NESTING_OFF^
+Do not report the maximal program unit nesting level
 
-@node Running gnatlbr
-@section Running @code{gnatlbr}
+@item ^--construct-nesting^/SYNTAX_METRICS=CONSTRUCT_NESTING_ON^
+Report the maximal construct nesting level
 
-@noindent
-The @code{gnatlbr} command has the form
+@item ^--no-construct-nesting^/SYNTAX_METRICS=CONSTRUCT_NESTING_OFF^
+Do not report the maximal construct nesting level
 
-@smallexample
-$ GNAT LIBRARY /[CREATE | SET | DELETE]=directory [/CONFIG=file]
-@end smallexample
+@end table
 
-@node Switches for gnatlbr
-@section Switches for @code{gnatlbr}
+@node Complexity Metrics Control
+@subsubsection Complexity Metrics Control
+@cindex Complexity metrics control in @command{gnatmetric}
 
 @noindent
-@code{gnatlbr} recognizes the following switches:
-
-@table @option
-@c !sort!
-@item /CREATE=directory
-@cindex @code{/CREATE} (@code{gnatlbr})
-     Create the new run-time library in the specified directory.
-
-@item /SET=directory
-@cindex @code{/SET} (@code{gnatlbr})
-     Make the library in the specified directory the current run-time
-     library.
-
-@item /DELETE=directory
-@cindex @code{/DELETE} (@code{gnatlbr})
-     Delete the run-time library in the specified directory.
+For a program unit that is an executable body (a subprogram body (including
+generic bodies), task body, entry body or a package body containing
+its own statement sequence) @command{gnatmetric} computes the following
+complexity metrics:
 
-@item /CONFIG=file
-@cindex @code{/CONFIG} (@code{gnatlbr})
-     With /CREATE:
-     Use the configuration pragmas in the specified file when building
-     the library.
+@itemize @bullet
+@item
+McCabe cyclomatic complexity;
 
-     With /SET:
-     Use the configuration pragmas in the specified file when compiling.
+@item
+McCabe essential complexity;
 
-@end table
+@item
+maximal loop nesting level
 
-@node Examples of gnatlbr Usage
-@section Example of @code{gnatlbr} Usage
+@end itemize
 
-@smallexample
-Contents of VAXFLOAT.ADC:
-pragma Float_Representation (VAX_Float);
+@noindent
+The McCabe complexity metrics are defined
+in @url{http://www.mccabe.com/pdf/nist235r.pdf}
 
-$ GNAT LIBRARY /CREATE=[.VAXFLOAT] /CONFIG=VAXFLOAT.ADC
+According to McCabe, both control statements and short-circuit control forms
+should be taken into account when computing cyclomatic complexity. For each
+body, we compute three metric values:
 
-GNAT LIBRARY rebuilds the run-time library in directory [.VAXFLOAT]
+@itemize @bullet
+@item
+the complexity introduced by control
+statements only, without taking into account short-circuit forms,
 
-@end smallexample
-@end ifset
+@item
+the complexity introduced by short-circuit control forms only, and
 
-@node The GNAT Library Browser gnatls
-@chapter The GNAT Library Browser @code{gnatls}
-@findex gnatls
-@cindex Library browser
+@item
+the total
+cyclomatic complexity, which is the sum of these two values.
+@end itemize
 
 @noindent
-@code{gnatls} is a tool that outputs information about compiled
-units. It gives the relationship between objects, unit names and source
-files. It can also be used to check the source dependencies of a unit
-as well as various characteristics.
+When computing cyclomatic and essential complexity, @command{gnatmetric} skips
+the code in the exception handlers and in all the nested program units.
 
-@menu
-* Running gnatls::
-* Switches for gnatls::
-* Examples of gnatls Usage::
-@end menu
+By default, all the complexity metrics are computed and reported.
+For more fine-grained control you can use
+the following switches:
 
-@node Running gnatls
-@section Running @code{gnatls}
+@table @option
+@cindex @option{^-complexity@var{x}^/COMPLEXITY_METRICS^} (@command{gnatmetric})
 
-@noindent
-The @code{gnatls} command has the form
+@ifclear vms
+@cindex @option{--no-complexity@var{x}}
+@end ifclear
 
-@smallexample
-$ gnatls switches @var{object_or_ali_file}
-@end smallexample
+@item ^--complexity-all^/COMPLEXITY_METRICS=ALL_ON^
+Report all the complexity metrics
 
-@noindent
-The main argument is the list of object or @file{ali} files
-(@pxref{The Ada Library Information Files})
-for which information is requested.
+@item ^--no-complexity-all^/COMPLEXITY_METRICS=ALL_OFF^
+Do not report any of complexity metrics
 
-In normal mode, without additional option, @code{gnatls} produces a
-four-column listing. Each line represents information for a specific
-object. The first column gives the full path of the object, the second
-column gives the name of the principal unit in this object, the third
-column gives the status of the source and the fourth column gives the
-full path of the source representing this unit.
-Here is a simple example of use:
+@item ^--complexity-cyclomatic^/COMPLEXITY_METRICS=CYCLOMATIC_ON^
+Report the McCabe Cyclomatic Complexity
 
-@smallexample
-$ gnatls *.o
-^./^[]^demo1.o            demo1            DIF demo1.adb
-^./^[]^demo2.o            demo2             OK demo2.adb
-^./^[]^hello.o            h1                OK hello.adb
-^./^[]^instr-child.o      instr.child      MOK instr-child.adb
-^./^[]^instr.o            instr             OK instr.adb
-^./^[]^tef.o              tef              DIF tef.adb
-^./^[]^text_io_example.o  text_io_example   OK text_io_example.adb
-^./^[]^tgef.o             tgef             DIF tgef.adb
-@end smallexample
+@item ^--no-complexity-cyclomatic^/COMPLEXITY_METRICS=CYCLOMATIC_OFF^
+Do not report the McCabe Cyclomatic Complexity
 
-@noindent
-The first line can be interpreted as follows: the main unit which is
-contained in
-object file @file{demo1.o} is demo1, whose main source is in
-@file{demo1.adb}. Furthermore, the version of the source used for the
-compilation of demo1 has been modified (DIF). Each source file has a status
-qualifier which can be:
+@item ^--complexity-essential^/COMPLEXITY_METRICS=ESSENTIAL_ON^
+Report the Essential Complexity
 
-@table @code
-@item OK (unchanged)
-The version of the source file used for the compilation of the
-specified unit corresponds exactly to the actual source file.
+@item ^--no-complexity-essential^/COMPLEXITY_METRICS=ESSENTIAL_OFF^
+Do not report the Essential Complexity
 
-@item MOK (slightly modified)
-The version of the source file used for the compilation of the
-specified unit differs from the actual source file but not enough to
-require recompilation. If you use gnatmake with the qualifier
-@option{^-m (minimal recompilation)^/MINIMAL_RECOMPILATION^}, a file marked
-MOK will not be recompiled.
+@item ^--loop-nesting^/COMPLEXITY_METRICS=LOOP_NESTING_ON^
+Report maximal loop nesting level
 
-@item DIF (modified)
-No version of the source found on the path corresponds to the source
-used to build this object.
+@item ^--no-loop-nesting^/COMPLEXITY_METRICS=LOOP_NESTING_OFF^
+Do not report maximal loop nesting level
 
-@item ??? (file not found)
-No source file was found for this unit.
+@item ^--complexity-average^/COMPLEXITY_METRICS=AVERAGE_COMPLEXITY_ON^
+Report the average McCabe Cyclomatic Complexity for all the subprogram bodies,
+task bodies, entry bodies and statement sequences in package bodies.
+The metric is computed and reported for whole set of processed Ada sources
+only.
 
-@item HID (hidden,  unchanged version not first on PATH)
-The version of the source that corresponds exactly to the source used
-for compilation has been found on the path but it is hidden by another
-version of the same source that has been modified.
+@item ^--no-complexity-average^/COMPLEXITY_METRICS=AVERAGE_COMPLEXITY_OFF^
+Do not report the average McCabe Cyclomatic Complexity for all the subprogram
+bodies, task bodies, entry bodies and statement sequences in package bodies
+
+@cindex @option{^-ne^/NO_EXITS_AS_GOTOS^} (@command{gnatmetric})
+@item ^-ne^/NO_EXITS_AS_GOTOS^
+Do not consider @code{exit} statements as @code{goto}s when
+computing Essential Complexity
 
 @end table
 
-@node Switches for gnatls
-@section Switches for @code{gnatls}
+@node Other gnatmetric Switches
+@subsection Other @code{gnatmetric} Switches
 
 @noindent
-@code{gnatls} recognizes the following switches:
+Additional @command{gnatmetric} switches are as follows:
 
 @table @option
-@c !sort!
-@item ^-a^/ALL_UNITS^
-@cindex @option{^-a^/ALL_UNITS^} (@code{gnatls})
-Consider all units, including those of the predefined Ada library.
-Especially useful with @option{^-d^/DEPENDENCIES^}.
-
-@item ^-d^/DEPENDENCIES^
-@cindex @option{^-d^/DEPENDENCIES^} (@code{gnatls})
-List sources from which specified units depend on.
-
-@item ^-h^/OUTPUT=OPTIONS^
-@cindex @option{^-h^/OUTPUT=OPTIONS^} (@code{gnatls})
-Output the list of options.
+@item ^-files @var{filename}^/FILES=@var{filename}^
+@cindex @option{^-files^/FILES^} (@code{gnatmetric})
+Take the argument source files from the specified file. This file should be an
+ordinary text file containing file names separated by spaces or
+line breaks. You can use this switch more then once in the same call to
+@command{gnatmetric}. You also can combine this switch with
+an explicit list of files.
 
-@item ^-o^/OUTPUT=OBJECTS^
-@cindex @option{^-o^/OUTPUT=OBJECTS^} (@code{gnatls})
-Only output information about object files.
+@item ^-v^/VERBOSE^
+@cindex @option{^-v^/VERBOSE^} (@code{gnatmetric})
+Verbose mode;
+@command{gnatmetric} generates version information and then
+a trace of sources being processed.
 
-@item ^-s^/OUTPUT=SOURCES^
-@cindex @option{^-s^/OUTPUT=SOURCES^} (@code{gnatls})
-Only output information about source files.
+@item ^-dv^/DEBUG_OUTPUT^
+@cindex @option{^-dv^/DEBUG_OUTPUT^} (@code{gnatmetric})
+Debug mode;
+@command{gnatmetric} generates various messages useful to understand what
+happens during the metrics computation
 
-@item ^-u^/OUTPUT=UNITS^
-@cindex @option{^-u^/OUTPUT=UNITS^} (@code{gnatls})
-Only output information about compilation units.
+@item ^-q^/QUIET^
+@cindex @option{^-q^/QUIET^} (@code{gnatmetric})
+Quiet mode.
+@end table
 
-@item ^-aO^/OBJECT_SEARCH=^@var{dir}
-@itemx ^-aI^/SOURCE_SEARCH=^@var{dir}
-@itemx ^-I^/SEARCH=^@var{dir}
-@itemx  ^-I-^/NOCURRENT_DIRECTORY^
-@itemx -nostdinc
-@cindex @option{^-aO^/OBJECT_SEARCH^} (@code{gnatls})
-@cindex @option{^-aI^/SOURCE_SEARCH^} (@code{gnatls})
-@cindex @option{^-I^/SEARCH^} (@code{gnatls})
-@cindex @option{^-I-^/NOCURRENT_DIRECTORY^} (@code{gnatls})
-Source path manipulation. Same meaning as the equivalent @code{gnatmake} flags
-(see @ref{Switches for gnatmake}).
+@node Generate project-wide metrics
+@subsection Generate project-wide metrics
 
-@item --RTS=@var{rts-path}
-@cindex @option{--RTS} (@code{gnatls})
-Specifies the default location of the runtime library. Same meaning as the
-equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}).
+In order to compute metrics on all units of a given project, you can use
+the @command{gnat} driver along with the @option{-P} option:
+@smallexample
+   gnat metric -Pproj
+@end smallexample
 
-@item ^-v^/OUTPUT=VERBOSE^
-@cindex @option{^-v^/OUTPUT=VERBOSE^} (@code{gnatls})
-Verbose mode. Output the complete source and object paths. Do not use
-the default column layout but instead use long format giving as much as
-information possible on each requested units, including special
-characteristics such as:
+@noindent
+If the project @code{proj} depends upon other projects, you can compute
+the metrics on the project closure using the @option{-U} option:
+@smallexample
+   gnat metric -Pproj -U
+@end smallexample
 
-@table @code
-@item  Preelaborable
-The unit is preelaborable in the Ada 95 sense.
+@noindent
+Finally, if not all the units are relevant to a particular main
+program in the project closure, you can generate metrics for the set
+of units needed to create a given main program (unit closure) using
+the @option{-U} option followed by the name of the main unit:
+@smallexample
+   gnat metric -Pproj -U main
+@end smallexample
 
-@item No_Elab_Code
-No elaboration code has been produced by the compiler for this unit.
 
-@item Pure
-The unit is pure in the Ada 95 sense.
+@c ***********************************
+@node File Name Krunching Using gnatkr
+@chapter File Name Krunching Using @code{gnatkr}
+@findex gnatkr
 
-@item Elaborate_Body
-The unit contains a pragma Elaborate_Body.
+@noindent
+This chapter discusses the method used by the compiler to shorten
+the default file names chosen for Ada units so that they do not
+exceed the maximum length permitted. It also describes the
+@code{gnatkr} utility that can be used to determine the result of
+applying this shortening.
+@menu
+* About gnatkr::
+* Using gnatkr::
+* Krunching Method::
+* Examples of gnatkr Usage::
+@end menu
 
-@item Remote_Types
-The unit contains a pragma Remote_Types.
-
-@item Shared_Passive
-The unit contains a pragma Shared_Passive.
-
-@item Predefined
-This unit is part of the predefined environment and cannot be modified
-by the user.
-
-@item Remote_Call_Interface
-The unit contains a pragma Remote_Call_Interface.
-
-@end table
-
-@end table
-
-@node Examples of gnatls Usage
-@section Example of @code{gnatls} Usage
-@ifclear vms
+@node About gnatkr
+@section About @code{gnatkr}
 
 @noindent
-Example of using the verbose switch. Note how the source and
-object paths are affected by the -I switch.
-
-@smallexample
-$ gnatls -v -I.. demo1.o
-
-GNATLS 3.10w (970212) Copyright 1999 Free Software Foundation, Inc.
+The default file naming rule in GNAT
+is that the file name must be derived from
+the unit name. The exact default rule is as follows:
+@itemize @bullet
+@item
+Take the unit name and replace all dots by hyphens.
+@item
+If such a replacement occurs in the
+second character position of a name, and the first character is
+^a, g, s, or i^A, G, S, or I^ then replace the dot by the character
+^~ (tilde)^$ (dollar sign)^
+instead of a minus.
+@end itemize
+The reason for this exception is to avoid clashes
+with the standard names for children of System, Ada, Interfaces,
+and GNAT, which use the prefixes ^s- a- i- and g-^S- A- I- and G-^
+respectively.
 
-Source Search Path:
-   <Current_Directory>
-   ../
-   /home/comar/local/adainclude/
+The @option{^-gnatk^/FILE_NAME_MAX_LENGTH=^@var{nn}}
+switch of the compiler activates a ``krunching''
+circuit that limits file names to nn characters (where nn is a decimal
+integer). For example, using OpenVMS,
+where the maximum file name length is
+39, the value of nn is usually set to 39, but if you want to generate
+a set of files that would be usable if ported to a system with some
+different maximum file length, then a different value can be specified.
+The default value of 39 for OpenVMS need not be specified.
 
-Object Search Path:
-   <Current_Directory>
-   ../
-   /home/comar/local/lib/gcc-lib/mips-sni-sysv4/2.7.2/adalib/
+The @code{gnatkr} utility can be used to determine the krunched name for
+a given file, when krunched to a specified maximum length.
 
-./demo1.o
-   Unit =>
-     Name   => demo1
-     Kind   => subprogram body
-     Flags  => No_Elab_Code
-     Source => demo1.adb    modified
-@end smallexample
+@node Using gnatkr
+@section Using @code{gnatkr}
 
 @noindent
-The following is an example of use of the dependency list.
-Note the use of the -s switch
-which gives a straight list of source files. This can be useful for
-building specialized scripts.
+The @code{gnatkr} command has the form
 
+@ifclear vms
 @smallexample
-$ gnatls -d demo2.o
-./demo2.o   demo2        OK demo2.adb
-                         OK gen_list.ads
-                         OK gen_list.adb
-                         OK instr.ads
-                         OK instr-child.ads
-
-$ gnatls -d -s -a demo1.o
-demo1.adb
-/home/comar/local/adainclude/ada.ads
-/home/comar/local/adainclude/a-finali.ads
-/home/comar/local/adainclude/a-filico.ads
-/home/comar/local/adainclude/a-stream.ads
-/home/comar/local/adainclude/a-tags.ads
-gen_list.ads
-gen_list.adb
-/home/comar/local/adainclude/gnat.ads
-/home/comar/local/adainclude/g-io.ads
-instr.ads
-/home/comar/local/adainclude/system.ads
-/home/comar/local/adainclude/s-exctab.ads
-/home/comar/local/adainclude/s-finimp.ads
-/home/comar/local/adainclude/s-finroo.ads
-/home/comar/local/adainclude/s-secsta.ads
-/home/comar/local/adainclude/s-stalib.ads
-/home/comar/local/adainclude/s-stoele.ads
-/home/comar/local/adainclude/s-stratt.ads
-/home/comar/local/adainclude/s-tasoli.ads
-/home/comar/local/adainclude/s-unstyp.ads
-/home/comar/local/adainclude/unchconv.ads
+$ gnatkr @var{name} [@var{length}]
 @end smallexample
 @end ifclear
 
 @ifset vms
 @smallexample
-GNAT LIST /DEPENDENCIES /OUTPUT=SOURCES /ALL_UNITS DEMO1.ADB
-
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]ada.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]a-finali.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]a-filico.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]a-stream.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]a-tags.ads
-demo1.adb
-gen_list.ads
-gen_list.adb
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]gnat.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]g-io.ads
-instr.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]system.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-exctab.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-finimp.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-finroo.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-secsta.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-stalib.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-stoele.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-stratt.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-tasoli.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-unstyp.ads
-GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]unchconv.ads
+$ gnatkr @var{name} /COUNT=nn
 @end smallexample
 @end ifset
 
-@node Cleaning Up Using gnatclean
-@chapter Cleaning Up Using @code{gnatclean}
-@findex gnatclean
-@cindex Cleaning tool
-
 @noindent
-@code{gnatclean} is a tool that allows the deletion of files produced by the
-compiler, binder and linker, including ALI files, object files, tree files,
-expanded source files, library files, interface copy source files, binder
-generated files and executable files.
+@var{name} is the uncrunched file name, derived from the name of the unit
+in the standard manner described in the previous section (i.e. in particular
+all dots are replaced by hyphens). The file name may or may not have an
+extension (defined as a suffix of the form period followed by arbitrary
+characters other than period). If an extension is present then it will
+be preserved in the output. For example, when krunching @file{hellofile.ads}
+to eight characters, the result will be hellofil.ads.
 
-@menu
-* Running gnatclean::
-* Switches for gnatclean::
-* Examples of gnatclean Usage::
-@end menu
+Note: for compatibility with previous versions of @code{gnatkr} dots may
+appear in the name instead of hyphens, but the last dot will always be
+taken as the start of an extension. So if @code{gnatkr} is given an argument
+such as @file{Hello.World.adb} it will be treated exactly as if the first
+period had been a hyphen, and for example krunching to eight characters
+gives the result @file{hellworl.adb}.
 
-@node Running gnatclean
-@section Running @code{gnatclean}
+Note that the result is always all lower case (except on OpenVMS where it is
+all upper case). Characters of the other case are folded as required.
+
+@var{length} represents the length of the krunched name. The default
+when no argument is given is ^8^39^ characters. A length of zero stands for
+unlimited, in other words do not chop except for system files where the
+implied crunching length is always eight characters.
 
 @noindent
-The @code{gnatclean} command has the form:
+The output is the krunched name. The output has an extension only if the
+original argument was a file name with an extension.
 
-@smallexample
-$ gnatclean switches @var{names}
-@end smallexample
+@node Krunching Method
+@section Krunching Method
 
 @noindent
-@var{names} is a list of source file names. Suffixes @code{.^ads^ADS^} and
-@code{^adb^ADB^} may be omitted. If a project file is specified using switch
-@code{^-P^/PROJECT_FILE=^}, then @var{names} may be completely omitted.
+The initial file name is determined by the name of the unit that the file
+contains. The name is formed by taking the full expanded name of the
+unit and replacing the separating dots with hyphens and
+using ^lowercase^uppercase^
+for all letters, except that a hyphen in the second character position is
+replaced by a ^tilde^dollar sign^ if the first character is
+^a, i, g, or s^A, I, G, or S^.
+The extension is @code{.ads} for a
+specification and @code{.adb} for a body.
+Krunching does not affect the extension, but the file name is shortened to
+the specified length by following these rules:
 
-@noindent
-In normal mode, @code{gnatclean} delete the files produced by the compiler and,
-if switch @code{^-c^/COMPILER_FILES_ONLY^} is not specified, by the binder and
-the linker. In informative-only mode, specified by switch
-@code{^-n^/NODELETE^}, the list of files that would have been deleted in
-normal mode is listed, but no file is actually deleted.
+@itemize @bullet
+@item
+The name is divided into segments separated by hyphens, tildes or
+underscores and all hyphens, tildes, and underscores are
+eliminated. If this leaves the name short enough, we are done.
 
-@node Switches for gnatclean
-@section Switches for @code{gnatclean}
+@item
+If the name is too long, the longest segment is located (left-most
+if there are two of equal length), and shortened by dropping
+its last character. This is repeated until the name is short enough.
 
-@noindent
-@code{gnatclean} recognizes the following switches:
+As an example, consider the krunching of @*@file{our-strings-wide_fixed.adb}
+to fit the name into 8 characters as required by some operating systems.
 
-@table @option
-@c !sort!
-@item ^-c^/COMPILER_FILES_ONLY^
-@cindex @option{^-c^/COMPILER_FILES_ONLY^} (@code{gnatclean})
-Only attempt to delete the files produced by the compiler, not those produced
-by the binder or the linker. The files that are not to be deleted are library
-files, interface copy files, binder generated files and executable files.
+@smallexample
+our-strings-wide_fixed 22
+our strings wide fixed 19
+our string  wide fixed 18
+our strin   wide fixed 17
+our stri    wide fixed 16
+our stri    wide fixe  15
+our str     wide fixe  14
+our str     wid  fixe  13
+our str     wid  fix   12
+ou  str     wid  fix   11
+ou  st      wid  fix   10
+ou  st      wi   fix   9
+ou  st      wi   fi    8
+Final file name: oustwifi.adb
+@end smallexample
 
-@item ^-D ^/DIRECTORY_OBJECTS=^@var{dir}
-@cindex @option{^-D^/DIRECTORY_OBJECTS^} (@code{gnatclean})
-Indicate that ALI and object files should normally be found in directory
-@var{dir}.
+@item
+The file names for all predefined units are always krunched to eight
+characters. The krunching of these predefined units uses the following
+special prefix replacements:
 
-@item ^-F^/FULL_PATH_IN_BRIEF_MESSAGES^
-@cindex @option{^-F^/FULL_PATH_IN_BRIEF_MESSAGES^} (@code{gnatclean})
-When using project files, if some errors or warnings are detected during
-parsing and verbose mode is not in effect (no use of switch
-^-v^/VERBOSE^), then error lines start with the full path name of the project
-file, rather than its simple file name.
+@table @file
+@item ada-
+replaced by @file{^a^A^-}
 
-@item ^-h^/HELP^
-@cindex @option{^-h^/HELP^} (@code{gnatclean})
-Output a message explaining the usage of @code{^gnatclean^gnatclean^}.
+@item gnat-
+replaced by @file{^g^G^-}
 
-@item ^-n^/NODELETE^
-@cindex @option{^-n^/NODELETE^} (@code{gnatclean})
-Informative-only mode. Do not delete any files. Output the list of the files
-that would have been deleted if this switch was not specified.
-
-@item ^-P^/PROJECT_FILE=^@var{project}
-@cindex @option{^-P^/PROJECT_FILE^} (@code{gnatclean})
-Use project file @var{project}. Only one such switch can be used.
-When cleaning a project file, the files produced by the compilation of the
-immediate sources or inherited sources of the project files are to be
-deleted. This is not depending on the presence or not of executable names
-on the command line.
-
-@item ^-q^/QUIET^
-@cindex @option{^-q^/QUIET^} (@code{gnatclean})
-Quiet output. If there are no error, do not ouuput anything, except in
-verbose mode (switch ^-v^/VERBOSE^) or in informative-only mode
-(switch ^-n^/NODELETE^).
-
-@item ^-r^/RECURSIVE^
-@cindex @option{^-r^/RECURSIVE^} (@code{gnatclean})
-When a project file is specified (using switch ^-P^/PROJECT_FILE=^),
-clean all imported and extended project files, recursively. If this switch
-is not specified, only the files related to the main project file are to be
-deleted. This switch has no effect if no project file is specified.
-
-@item ^-v^/VERBOSE^
-@cindex @option{^-v^/VERBOSE^} (@code{gnatclean})
-Verbose mode.
-
-@item ^-vP^/MESSAGES_PROJECT_FILE=^@emph{x}
-@cindex @option{^-vP^/MESSAGES_PROJECT_FILE^} (@code{gnatclean})
-Indicates the verbosity of the parsing of GNAT project files.
-See @ref{Switches Related to Project Files}.
+@item interfaces-
+replaced by @file{^i^I^-}
 
-@item ^-X^/EXTERNAL_REFERENCE=^@var{name=value}
-@cindex @option{^-X^/EXTERNAL_REFERENCE^} (@code{gnatclean})
-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.
-See @ref{Switches Related to Project Files}.
+@item system-
+replaced by @file{^s^S^-}
+@end table
 
-@item ^-aO^/OBJECT_SEARCH=^@var{dir}
-@cindex @option{^-aO^/OBJECT_SEARCH^} (@code{gnatclean})
-When searching for ALI and object files, look in directory
-@var{dir}.
+These system files have a hyphen in the second character position. That
+is why normal user files replace such a character with a
+^tilde^dollar sign^, to
+avoid confusion with system file names.
 
-@item ^-I^/SEARCH=^@var{dir}
-@cindex @option{^-I^/SEARCH^} (@code{gnatclean})
-Equivalent to @option{^-aO^/OBJECT_SEARCH=^@var{dir}}.
+As an example of this special rule, consider
+@*@file{ada-strings-wide_fixed.adb}, which gets krunched as follows:
 
-@item ^-I-^/NOCURRENT_DIRECTORY^
-@cindex @option{^-I-^/NOCURRENT_DIRECTORY^} (@code{gnatclean})
-@cindex Source files, suppressing search
-Do not look for ALI or object files in the directory
-where @code{gnatclean} was invoked.
+@smallexample
+ada-strings-wide_fixed 22
+a-  strings wide fixed 18
+a-  string  wide fixed 17
+a-  strin   wide fixed 16
+a-  stri    wide fixed 15
+a-  stri    wide fixe  14
+a-  str     wide fixe  13
+a-  str     wid  fixe  12
+a-  str     wid  fix   11
+a-  st      wid  fix   10
+a-  st      wi   fix   9
+a-  st      wi   fi    8
+Final file name: a-stwifi.adb
+@end smallexample
+@end itemize
 
-@end table
+Of course no file shortening algorithm can guarantee uniqueness over all
+possible unit names, and if file name krunching is used then it is your
+responsibility to ensure that no name clashes occur. The utility
+program @code{gnatkr} is supplied for conveniently determining the
+krunched name of a file.
 
-@node Examples of gnatclean Usage
-@section Examples of @code{gnatclean} Usage
+@node Examples of gnatkr Usage
+@section Examples of @code{gnatkr} Usage
 
+@smallexample
+@iftex
+@leftskip=0cm
+@end iftex
 @ifclear vms
-@node GNAT and Libraries
-@chapter GNAT and Libraries
-@cindex Library, building, installing, using
+$ gnatkr very_long_unit_name.ads      --> velounna.ads
+$ gnatkr grandparent-parent-child.ads --> grparchi.ads
+$ gnatkr Grandparent.Parent.Child.ads --> grparchi.ads
+$ gnatkr grandparent-parent-child     --> grparchi
+@end ifclear
+$ gnatkr very_long_unit_name.ads/count=6 --> vlunna.ads
+$ gnatkr very_long_unit_name.ads/count=0 --> very_long_unit_name.ads
+@end smallexample
+
+@node Preprocessing Using gnatprep
+@chapter Preprocessing Using @code{gnatprep}
+@findex gnatprep
 
 @noindent
-This chapter addresses the issues related to building and using
-libraries with GNAT. It also shows how the GNAT run-time library can be
-recompiled. It is recommended that the user understands how to use the
-@ref{GNAT Project Manager} facility before reading this chapter.
+This chapter discusses how to use GNAT's @code{gnatprep} utility for simple
+preprocessing.
+Although designed for use with GNAT, @code{gnatprep} does not depend on any
+special GNAT features.
+For further discussion of conditional compilation in general, see
+@ref{Conditional Compilation}.
 
 @menu
-* Introduction to Libraries in GNAT::
-* General Ada Libraries::
-* Stand-alone Ada Libraries::
-* Rebuilding the GNAT Run-Time Library::
+* Using gnatprep::
+* Switches for gnatprep::
+* Form of Definitions File::
+* Form of Input Text for gnatprep::
 @end menu
 
-@node Introduction to Libraries in GNAT
-@section Introduction to Libraries in GNAT
 
-@noindent
-A library is, conceptually, a collection of objects which does not have its
-own main thread of execution, but rather provides certain services to the
-applications that use it. A library can be either statically linked with the
-application, in which case its code is directly included in the application,
-or, on platforms that support it, be dynamically linked, in which case
-its code is shared by all applications making use of this library. GNAT
-supports both types of libraries. In the static case, the compiled code can
-be provided in different ways. The simplest way is to provide directly the
-set of objects produced by the compiler during the compilation of the library.
-It is also possible to group the objects into an archive using whatever
-commands are provided by the operating system. For the later case, the objects
-are grouped into a shared library.
-
-In the GNAT environment, a library has two types of components:
-@itemize @bullet
-@item
-Source files.
-@item
-Compiled code and Ali files. See @ref{The Ada Library Information Files}.
-@end itemize
+@node Using gnatprep
+@section Using @code{gnatprep}
 
 @noindent
-GNAT libraries can either completely expose their source files to the
-compilation context of the user's application, or alternatively only expose
-a limited set of source files, called interface units, in which case they are
-called @ref{Stand-alone Ada Libraries}. In addition, GNAT provides full support
-for foreign libraries which are only available in the object format.
-
-Ada semantics requires that all compilation units comprising the application
-are elaborated in the timely fashion. Where possible, GNAT provides facilities
-to ensure that compilation units of a library are automatically elaborated;
-however, there are cases where this must be responsibility of a user. This will
-be addressed in greater detail further on.
-
-@node General Ada Libraries
-@section General Ada Libraries
-
-@menu
-* Building the library::
-* Installing the library::
-* Using the library::
-@end menu
+To call @code{gnatprep} use
 
-@node Building the library
-@subsection Building the library
+@smallexample
+$ gnatprep [switches] infile outfile [deffile]
+@end smallexample
 
 @noindent
-The easiest way to build a library is to use the @ref{GNAT Project Manager},
-which supports a special type of projects called @ref{Library Projects}.
+where
+@table @code
+@item switches
+is an optional sequence of switches as described in the next section.
 
-A project is considered a library project, when two project-level attributes
-are defined in it: @code{Library_Name} and @code{Library_Dir}. In order to
-control different aspects of library configuration, additional optional
-project-level attributes can be specified:
-@itemize
-@item @code{Library_Kind}
-This attribute controls whether the library is to be static or shared
-@item @code{Library_Version}
-This attribute specifies what is the library version; this value is used
-during dynamic linking of shared libraries to determine if the currently
-installed versions of the binaries are compatible.
-@item @code{Library_Options}, @code{Library_GCC}
-These attributes specify additional low-level options to be used during
-library generation, and redefine the actual application used to generate
-library.
-@end itemize
+@item infile
+is the full name of the input file, which is an Ada source
+file containing preprocessor directives.
 
-@noindent
-GNAT Project Manager takes full care of the library maintenance task,
-including recompilation of the source files for which objects do not exist
-or are not up to date, assembly of the library archive, and installation of
-the library, i.e. the copy of associated source, object and ALI files to the
-specific location.
+@item outfile
+is the full name of the output file, which is an Ada source
+in standard Ada form. When used with GNAT, this file name will
+normally have an ads or adb suffix.
 
-It is not entirely trivial to correctly do all the steps required to
-produce a library. We recommend that you use @ref{GNAT Project Manager}
-for this task. In special cases where this is not desired, the necessary
-steps are discussed below.
+@item deffile
+is the full name of a text file containing definitions of
+symbols to be referenced by the preprocessor. This argument is
+optional, and can be replaced by the use of the @option{-D} switch.
 
-There are various possibilities for compiling the units that make up the
-library: for example with a Makefile @ref{Using the GNU make Utility},
-or with a conventional script.
-For simple libraries, it is also possible to create a
-dummy main program which depends upon all the packages that comprise the
-interface of the library. This dummy main program can then be given to
-gnatmake, which will ensure that all necessary objects are built.
+@end table
 
-After this task is accomplished, the user should follow the standard procedure
-of the underlying operating system to produce the static or shared library.
+@node Switches for gnatprep
+@section Switches for @code{gnatprep}
 
-Below is an example of such a dummy program and the generic commands used to
-build an archive or a shared library.
+@table @option
+@c !sort!
 
-@smallexample @c ada
-@iftex
-@leftskip=.7cm
-@end iftex
-with My_Lib.Service1;
-with My_Lib.Service2;
-with My_Lib.Service3;
-procedure My_Lib_Dummy is
-begin
-   null;
-end;
-@end smallexample
+@item ^-b^/BLANK_LINES^
+@cindex @option{^-b^/BLANK_LINES^} (@command{gnatprep})
+Causes both preprocessor lines and the lines deleted by
+preprocessing to be replaced by blank lines in the output source file,
+preserving line numbers in the output file.
 
-@smallexample
-# compiling the library
-$ gnatmake -c my_lib_dummy.adb
+@item ^-c^/COMMENTS^
+@cindex @option{^-c^/COMMENTS^} (@command{gnatprep})
+Causes both preprocessor lines and the lines deleted
+by preprocessing to be retained in the output source as comments marked
+with the special string @code{"--! "}. This option will result in line numbers
+being preserved in the output file.
 
-# we don't need the dummy object itself
-$ rm my_lib_dummy.o my_lib_dummy.ali
+@item ^-C^/REPLACE_IN_COMMENTS^
+@cindex @option{^-C^/REPLACE_IN_COMMENTS^} (@command{gnatprep})
+Causes comments to be scanned. Normally comments are ignored by gnatprep.
+If this option is specified, then comments are scanned and any $symbol
+substitutions performed as in program text. This is particularly useful
+when structured comments are used (e.g. when writing programs in the
+SPARK dialect of Ada). Note that this switch is not available when
+doing integrated preprocessing (it would be useless in this context
+since comments are ignored by the compiler in any case).
 
-# create an archive with the remaining objects
-$ ar rc libmy_lib.a *.o
-# some systems may require "ranlib" to be run as well
+@item ^-Dsymbol=value^/ASSOCIATE="symbol=value"^
+@cindex @option{^-D^/ASSOCIATE^} (@command{gnatprep})
+Defines a new symbol, associated with value. If no value is given on the
+command line, then symbol is considered to be @code{True}. This switch
+can be used in place of a definition file.
 
-# or create a shared library
-$ gcc -shared -o libmy_lib.so *.o
-# some systems may require the code to have been compiled with -fPIC
+@ifset vms
+@item /REMOVE
+@cindex @option{/REMOVE} (@command{gnatprep})
+This is the default setting which causes lines deleted by preprocessing
+to be entirely removed from the output file.
+@end ifset
 
-# remove the object files that are now in the library
-$ rm *.o
+@item ^-r^/REFERENCE^
+@cindex @option{^-r^/REFERENCE^} (@command{gnatprep})
+Causes a @code{Source_Reference} pragma to be generated that
+references the original input file, so that error messages will use
+the file name of this original file. The use of this switch implies
+that preprocessor lines are not to be removed from the file, so its
+use will force @option{^-b^/BLANK_LINES^} mode if
+@option{^-c^/COMMENTS^}
+has not been specified explicitly.
 
-# Make the ALI files read-only so that gnatmake will not try to
-# regenerate the objects that are in the library
-$ chmod -w *.ali
+Note that if the file to be preprocessed contains multiple units, then
+it will be necessary to @code{gnatchop} the output file from
+@code{gnatprep}. If a @code{Source_Reference} pragma is present
+in the preprocessed file, it will be respected by
+@code{gnatchop ^-r^/REFERENCE^}
+so that the final chopped files will correctly refer to the original
+input source file for @code{gnatprep}.
 
-@end smallexample
+@item ^-s^/SYMBOLS^
+@cindex @option{^-s^/SYMBOLS^} (@command{gnatprep})
+Causes a sorted list of symbol names and values to be
+listed on the standard output file.
 
-@noindent
-Please note that the library must have a name of the form libxxx.a or
-libxxx.so in order to be accessed by the directive -lxxx at link
-time.
+@item ^-u^/UNDEFINED^
+@cindex @option{^-u^/UNDEFINED^} (@command{gnatprep})
+Causes undefined symbols to be treated as having the value FALSE in the context
+of a preprocessor test. In the absence of this option, an undefined symbol in
+a @code{#if} or @code{#elsif} test will be treated as an error.
 
-@node Installing the library
-@subsection Installing the library
+@end table
 
+@ifclear vms
 @noindent
-In the GNAT model, installing a library consists in copying into a specific
-location the files that make up this library. When the library is built using
-projects, it is automatically installed in the location specified in the
-project by means of the attribute @code{Library_Dir}, otherwise it is
-responsibility of the user. GNAT also supports installing the sources in a
-different directory from the other files (ALI, objects, archives) since the
-source path and the object path can be specified separately.
-
-For general purpose libraries, it is possible for the system
-administrator to put those libraries in the default compiler paths. To
-achieve this, he must specify their location in the configuration files
-@file{ada_source_path} and @file{ada_object_path} that must be located in
-the GNAT
-installation tree at the same place as the gcc spec file. The location of
-the gcc spec file can be determined as follows:
-@smallexample
-$ gcc -v
-@end smallexample
+Note: if neither @option{-b} nor @option{-c} is present,
+then preprocessor lines and
+deleted lines are completely removed from the output, unless -r is
+specified, in which case -b is assumed.
+@end ifclear
+
+@node Form of Definitions File
+@section Form of Definitions File
 
 @noindent
-The configuration files mentioned above have simple format: each line in them
-must contain one unique
-directory name. Those names are added to the corresponding path
-in their order of appearance in the file. The names can be either absolute
-or relative, in the latter case, they are relative to where theses files
-are located.
+The definitions file contains lines of the form
 
-@file{ada_source_path} and @file{ada_object_path} might actually not be
-present in a
-GNAT installation, in which case, GNAT will look for its run-time library in
-he directories @file{adainclude} for the sources and @file{adalib} for the
-objects and @file{ALI} files. When the files exist, the compiler does not
-look in @file{adainclude} and @file{adalib} at all, and thus the
-@file{ada_source_path} file
-must contain the location for the GNAT run-time sources (which can simply
-be @file{adainclude}). In the same way, the @file{ada_object_path} file must
-contain the location for the GNAT run-time objects (which can simply
-be @file{adalib}).
+@smallexample
+symbol := value
+@end smallexample
 
-You can also specify a new default path to the runtime library at compilation
-time with the switch @option{--RTS=rts-path}. You can easily choose and change
-the runtime you want your program to be compiled with. This switch is
-recognized by gcc, gnatmake, gnatbind, gnatls, gnatfind and gnatxref.
+@noindent
+where symbol is an identifier, following normal Ada (case-insensitive)
+rules for its syntax, and value is one of the following:
 
-It is possible to install a library before or after the standard GNAT
-library, by reordering the lines in the configuration files. In general, a
-library must be installed before the GNAT library if it redefines
-any part of it.
+@itemize @bullet
+@item
+Empty, corresponding to a null substitution
+@item
+A string literal using normal Ada syntax
+@item
+Any sequence of characters from the set
+(letters, digits, period, underline).
+@end itemize
 
+@noindent
+Comment lines may also appear in the definitions file, starting with
+the usual @code{--},
+and comments may be added to the definitions lines.
 
-@node Using the library
-@subsection Using the library
+@node Form of Input Text for gnatprep
+@section Form of Input Text for @code{gnatprep}
 
 @noindent
-Once again, the project facility greatly simplifies the addition of libraries
-to the compilation. If the project file for an application lists a library
-project in its @code{with} clause, the project manager will ensure that the
-library files are consistent, and are considered during compilation and
-linking of the main application.
+The input text may contain preprocessor conditional inclusion lines,
+as well as general symbol substitution sequences.
 
-Even if you have a third-party, non-Ada library, you can still use GNAT
-Project facility to provide a wrapper for it. The following project for
-example, when "withed" in your main project, will link with the third-party
-library liba.a:
+The preprocessor conditional inclusion commands have the form
 
-@smallexample @c projectfile
+@smallexample
 @group
-project Liba is
-   for Source_Dirs use ();
-   for Library_Dir use "lib";
-   for Library_Name use "a";
-   for Library_Kind use "static";
-end Liba;
+@cartouche
+#if @i{expression} [then]
+   lines
+#elsif @i{expression} [then]
+   lines
+#elsif @i{expression} [then]
+   lines
+@dots{}
+#else
+   lines
+#end if;
+@end cartouche
 @end group
 @end smallexample
 
 @noindent
-In order to use an Ada library manually, you need to make sure that this
-library is on both your source and object path
-@ref{Search Paths and the Run-Time Library (RTL)}
-and @ref{Search Paths for gnatbind}. Furthermore, when the objects are grouped
-in an archive or a shared library, the user needs to specify the desired
-library at link time.
-
-By means of example, you can use the library @file{mylib} installed in
-@file{/dir/my_lib_src} and @file{/dir/my_lib_obj} with the following commands:
-
+In this example, @i{expression} is defined by the following grammar:
 @smallexample
-$ gnatmake -aI/dir/my_lib_src -aO/dir/my_lib_obj my_appl \
-  -largs -lmy_lib
+@i{expression} ::=  <symbol>
+@i{expression} ::=  <symbol> = "<value>"
+@i{expression} ::=  <symbol> = <symbol>
+@i{expression} ::=  <symbol> 'Defined
+@i{expression} ::=  not @i{expression}
+@i{expression} ::=  @i{expression} and @i{expression}
+@i{expression} ::=  @i{expression} or @i{expression}
+@i{expression} ::=  @i{expression} and then @i{expression}
+@i{expression} ::=  @i{expression} or else @i{expression}
+@i{expression} ::=  ( @i{expression} )
 @end smallexample
 
 @noindent
-This can be simplified down to the following:
-@smallexample
-$ gnatmake my_appl
-@end smallexample
-when the following conditions are met:
-@itemize @bullet
-@item
-@file{/dir/my_lib_src} has been added by the user to the environment
-variable @code{ADA_INCLUDE_PATH}, or by the administrator to the file
-@file{ada_source_path}
-@item
-@file{/dir/my_lib_obj} has been added by the user to the environment
-variable @code{ADA_OBJECTS_PATH}, or by the administrator to the file
-@file{ada_object_path}
-@item
-a pragma @code{Linker_Options}, has been added to one of the sources.
-For example:
-
-@smallexample @c ada
-pragma Linker_Options ("-lmy_lib");
-@end smallexample
-@end itemize
-
-
-@node Stand-alone Ada Libraries
-@section Stand-alone Ada Libraries
-@cindex Stand-alone library, building, using
+For the first test (@i{expression} ::= <symbol>) the symbol must have
+either the value true or false, that is to say the right-hand of the
+symbol definition must be one of the (case-insensitive) literals
+@code{True} or @code{False}. If the value is true, then the
+corresponding lines are included, and if the value is false, they are
+excluded.
 
-@menu
-* Introduction to Stand-Alone Libraries::
-* Building SAL::
-* Creating SAL to be used in a non-Ada context::
-* Restrictions in SALs::
-@end menu
+The test (@i{expression} ::= <symbol> @code{'Defined}) is true only if
+the symbol has been defined in the definition file or by a @option{-D}
+switch on the command line. Otherwise, the test is false.
 
-@node Introduction to Stand-Alone Libraries
-@subsection Introduction to Stand-Alone Libraries
+The equality tests are case insensitive, as are all the preprocessor lines.
 
-@noindent
-A Stand-alone Library (SAL) is a library that contains the necessary code to
-elaborate the Ada units that are included in the library. Different from
-ordinary libraries, which consist of all sources, objects and ALI files of the
-library, the SAL creator can specify a restricted subset of compilation units
-comprising SAL to serve as a library interface. In this case, the fully
-self-sufficient set of files of such library will normally consist of objects
-archive, sources of interface units specs, and ALI files of interface units.
-Note that if interface specs contain generics or inlined subprograms, body
-source must also be provided; if the units that must be provided in the source
-form depend on other units, the source and ALIs of those must also be provided.
+If the symbol referenced is not defined in the symbol definitions file,
+then the effect depends on whether or not switch @option{-u}
+is specified. If so, then the symbol is treated as if it had the value
+false and the test fails. If this switch is not specified, then
+it is an error to reference an undefined symbol. It is also an error to
+reference a symbol that is defined with a value other than @code{True}
+or @code{False}.
 
-The main purpose of SAL is to minimize the recompilation overhead of client
-applications when the new version of the library is installed. Specifically,
-if the interface sources have not changed, client applications do not need to
-be recompiled. If, furthermore, SAL is provided in the shared form and its
-version, controlled by @code{Library_Version} attribute, is not changed, the
-clients don't need to be relinked, either.
+The use of the @code{not} operator inverts the sense of this logical test.
+The @code{not} operator cannot be combined with the @code{or} or @code{and}
+operators, without parentheses. For example, "if not X or Y then" is not
+allowed, but "if (not X) or Y then" and "if not (X or Y) then" are.
 
-SALs also allow the library providers to minimize amount of library source
-text exposed to the clients, which might be necessary for different reasons.
+The @code{then} keyword is optional as shown
 
-Stand-alone libraries are also well suited to be used in an executable which
-main is not written in Ada.
+The @code{#} must be the first non-blank character on a line, but
+otherwise the format is free form. Spaces or tabs may appear between
+the @code{#} and the keyword. The keywords and the symbols are case
+insensitive as in normal Ada code. Comments may be used on a
+preprocessor line, but other than that, no other tokens may appear on a
+preprocessor line. Any number of @code{elsif} clauses can be present,
+including none at all. The @code{else} is optional, as in Ada.
 
-@node Building SAL
-@subsection Building SAL
+The @code{#} marking the start of a preprocessor line must be the first
+non-blank character on the line, i.e. it must be preceded only by
+spaces or horizontal tabs.
 
-@noindent
-GNAT Project facility provides a simple way of building and installing
-stand-alone libraries, see @ref{Stand-alone Library Projects}.
-To be a Stand-alone Library Project, in addition to the two attributes
-that make a project a Library Project (@code{Library_Name} and
-@code{Library_Dir}, see @ref{Library Projects}), the attribute
-@code{Library_Interface} must be defined.
+Symbol substitution outside of preprocessor lines is obtained by using
+the sequence
 
-@smallexample @c projectfile
-@group
-   for Library_Dir use "lib_dir";
-   for Library_Name use "dummy";
-   for Library_Interface use ("int1", "int1.child");
-@end group
+@smallexample
+$symbol
 @end smallexample
 
-Attribute @code{Library_Interface} has a non empty string list value,
-each string in the list designating a unit contained in an immediate source
-of the project file.
-
-When a Stand-alone Library is built, first the binder is invoked to build
-a package whose name depends on the library name
-(^b~dummy.ads/b^B$DUMMY.ADS/B^ in the example above).
-This binder-generated package includes initialization and
-finalization procedures whose
-names depend on the library name (dummyinit and dummyfinal in the example
-above). The object corresponding to this package is included in the library.
-
-The user must ensure timely (e.g. prior to any use of interfaces in the SAL)
-calling of these procedures if static SAL is built, or shared SAL is built
-with project-level attribute @code{Library_Auto_Init} set to "false".
-
-For a Stand-Alone Library, only the @file{ALI} files of the Interface Units
-(those that are listed in attribute @code{Library_Interface}) are copied to
-the Library Directory. As a consequence, only the Interface Units may be
-imported from Ada units outside of the library. If other units are imported,
-the binding phase will fail.
+@noindent
+anywhere within a source line, except in a comment or within a
+string literal. The identifier
+following the @code{$} must match one of the symbols defined in the symbol
+definition file, and the result is to substitute the value of the
+symbol in place of @code{$symbol} in the output file.
 
-The attribute @code{Library_Src_Dir}, may be specified for a
-Stand-Alone Library. @code{Library_Src_Dir} is a simple attribute that has a
-single string value. Its value must be the path (absolute or relative to the
-project directory) of an existing directory. This directory cannot be the
-object directory or one of the source directories, but it can be the same as
-the library directory. The sources of the Interface
-Units of the library, necessary to an Ada client of the library, will be
-copied to the designated directory, called Interface Copy directory.
-These sources includes the specs of the Interface Units, but they may also
-include bodies and subunits, when pragmas @code{Inline} or @code{Inline_Always}
-are used, or when there is a generic units in the spec. Before the sources
-are copied to the Interface Copy directory, an attempt is made to delete all
-files in the Interface Copy directory.
+Note that although the substitution of strings within a string literal
+is not possible, it is possible to have a symbol whose defined value is
+a string literal. So instead of setting XYZ to @code{hello} and writing:
 
-Building stand-alone libraries by hand is difficult. Below are listed the steps
-necessary to be done by the user:
-@itemize @bullet
-@item
-compile all library sources
-@item
-invoke the binder with the switch -n (No Ada main program),
-with all the ALI files of the interfaces, and
-with the switch -L to give specific names to the init and final
-procedure.
 @smallexample
-  gnatbind -n int1.ali int2.ali -Lsal1
-@end smallexample
-@item
-compile the binder generated file
-@smallexample
-  gcc -c b~int2.adb
+Header : String := "$XYZ";
 @end smallexample
-@item
-link the dynamic library with all the necessary object files,
-indicating to the linker the names of the init (and possibly
-final) procedures for automatic initialization (and finalization).
-The built library should be put in a directory different from
-the object directory.
-@item
-copy the ALI files of the interface to the library directory,
-add in the copy the indication that it is an interface to a SAL
-(i.e. add a word @option{SL} on the line in ALI file that starts
-with letter P) and make the modified copy of the ALI file read-only.
-@end itemize
 
 @noindent
-Using SALs is not different from using other libraries
-(see @ref{Using the library}).
+you should set XYZ to @code{"hello"} and write:
 
-@node Creating SAL to be used in a non-Ada context
-@subsection Creating SAL to be used in a non-Ada context
+@smallexample
+Header : String := $XYZ;
+@end smallexample
 
 @noindent
-It is easy to adapt SAL build procedure discussed above for use of SAL in
-a non-Ada context.
+and then the substitution will occur as desired.
 
-The only extra step required is to ensure that library interface subprograms
-are compatible with the main program, by means of @code{pragma Export}
-or @code{pragma Convention}.
+@ifset vms
+@node The GNAT Run-Time Library Builder gnatlbr
+@chapter The GNAT Run-Time Library Builder @code{gnatlbr}
+@findex gnatlbr
+@cindex Library builder
 
-Here is an example of simple library interface for use with C main program:
+@noindent
+@code{gnatlbr} is a tool for rebuilding the GNAT run time with user
+supplied configuration pragmas.
 
-@smallexample @c ada
-package Interface is
+@menu
+* Running gnatlbr::
+* Switches for gnatlbr::
+* Examples of gnatlbr Usage::
+@end menu
 
-   procedure Do_Something;
-   pragma Export (C, Do_Something, "do_something");
+@node Running gnatlbr
+@section Running @code{gnatlbr}
 
-   procedure Do_Something_Else;
-   pragma Export (C, Do_Something_Else, "do_something_else");
+@noindent
+The @code{gnatlbr} command has the form
 
-end Interface;
+@smallexample
+$ GNAT LIBRARY /[CREATE | SET | DELETE]=directory [/CONFIG=file]
 @end smallexample
 
+@node Switches for gnatlbr
+@section Switches for @code{gnatlbr}
+
 @noindent
-On the foreign language side, you must provide a ``foreign'' view of the
-library interface; remeber that it should contain elaboration routines in
-addition to interface subrporams.
+@code{gnatlbr} recognizes the following switches:
 
-The example below shows the content of @code{mylib_interface.h} (note
-that there is no rule for the naming of this file, any name can be used)
-@smallexample
-/* the library elaboration procedure */
-extern void mylibinit (void);
+@table @option
+@c !sort!
+@item /CREATE=directory
+@cindex @code{/CREATE} (@code{gnatlbr})
+     Create the new run-time library in the specified directory.
 
-/* the library finalization procedure */
-extern void mylibfinal (void);
+@item /SET=directory
+@cindex @code{/SET} (@code{gnatlbr})
+     Make the library in the specified directory the current run-time
+     library.
 
-/* the interface exported by the library */
-extern void do_something (void);
-extern void do_something_else (void);
-@end smallexample
+@item /DELETE=directory
+@cindex @code{/DELETE} (@code{gnatlbr})
+     Delete the run-time library in the specified directory.
 
-@noindent
-Libraries built as explained above can be used from any program, provided
-that the elaboration procedures (named @code{mylibinit} in the previous
-example) are called before the library services are used. Any number of
-libraries can be used simultaneously, as long as the elaboration
-procedure of each library is called.
+@item /CONFIG=file
+@cindex @code{/CONFIG} (@code{gnatlbr})
+     With /CREATE:
+     Use the configuration pragmas in the specified file when building
+     the library.
+
+     With /SET:
+     Use the configuration pragmas in the specified file when compiling.
+
+@end table
 
-Below is an example of C program that uses our @code{mylib} library.
+@node Examples of gnatlbr Usage
+@section Example of @code{gnatlbr} Usage
 
 @smallexample
-#include "mylib_interface.h"
+Contents of VAXFLOAT.ADC:
+pragma Float_Representation (VAX_Float);
 
-int
-main (void)
-@{
-   /* First, elaborate the library before using it */
-   mylibinit ();
+$ GNAT LIBRARY /CREATE=[.VAXFLOAT] /CONFIG=VAXFLOAT.ADC
 
-   /* Main program, using the library exported entities */
-   do_something ();
-   do_something_else ();
+GNAT LIBRARY rebuilds the run-time library in directory [.VAXFLOAT]
 
-   /* Library finalization at the end of the program */
-   mylibfinal ();
-   return 0;
-@}
 @end smallexample
+@end ifset
 
-@noindent
-Note that invoking any library finalization procedure generated by
-@code{gnatbind} shuts down the Ada run time permanently. Consequently, the
-finalization of all Ada libraries must be performed at the end of the program.
-No call to these libraries nor the Ada run time should be made past the
-finalization phase.
-
-@node Restrictions in SALs
-@subsection Restrictions in SALs
+@node The GNAT Library Browser gnatls
+@chapter The GNAT Library Browser @code{gnatls}
+@findex gnatls
+@cindex Library browser
 
 @noindent
-The pragmas listed below should be used with caution inside libraries,
-as they can create incompatibilities with other Ada libraries:
-@itemize @bullet
-@item pragma @code{Locking_Policy}
-@item pragma @code{Queuing_Policy}
-@item pragma @code{Task_Dispatching_Policy}
-@item pragma @code{Unreserve_All_Interrupts}
-@end itemize
-When using a library that contains such pragmas, the user must make sure
-that all libraries use the same pragmas with the same values. Otherwise,
-a @code{Program_Error} will
-be raised during the elaboration of the conflicting
-libraries. The usage of these pragmas and its consequences for the user
-should therefore be well documented.
+@code{gnatls} is a tool that outputs information about compiled
+units. It gives the relationship between objects, unit names and source
+files. It can also be used to check the source dependencies of a unit
+as well as various characteristics.
 
-Similarly, the traceback in exception occurrences mechanism should be
-enabled or disabled in a consistent manner across all libraries.
-Otherwise, a Program_Error will be raised during the elaboration of the
-conflicting libraries.
+Note: to invoke @code{gnatls} with a project file, use the @code{gnat}
+driver (see @ref{The GNAT Driver and Project Files}).
 
-If the @code{'Version} and @code{'Body_Version}
-attributes are used inside a library, then it is necessary to
-perform a @code{gnatbind} step that mentions all @file{ALI} files in all
-libraries, so that version identifiers can be properly computed.
-In practice these attributes are rarely used, so this is unlikely
-to be a consideration.
+@menu
+* Running gnatls::
+* Switches for gnatls::
+* Examples of gnatls Usage::
+@end menu
 
-@node  Rebuilding the GNAT Run-Time Library
-@section Rebuilding the GNAT Run-Time Library
-@cindex GNAT Run-Time Library, rebuilding
+@node Running gnatls
+@section Running @code{gnatls}
 
 @noindent
-It may be useful to recompile the GNAT library in various contexts, the
-most important one being the use of partition-wide configuration pragmas
-such as @code{Normalize_Scalars}. A special Makefile called
-@code{Makefile.adalib} is provided to that effect and can be found in
-the directory containing the GNAT library. The location of this
-directory depends on the way the GNAT environment has been installed and can
-be determined by means of the command:
+The @code{gnatls} command has the form
 
 @smallexample
-$ gnatls -v
+$ gnatls switches @var{object_or_ali_file}
 @end smallexample
 
 @noindent
-The last entry in the object search path usually contains the
-gnat library. This Makefile contains its own documentation and in
-particular the set of instructions needed to rebuild a new library and
-to use it.
+The main argument is the list of object or @file{ali} files
+(@pxref{The Ada Library Information Files})
+for which information is requested.
 
+In normal mode, without additional option, @code{gnatls} produces a
+four-column listing. Each line represents information for a specific
+object. The first column gives the full path of the object, the second
+column gives the name of the principal unit in this object, the third
+column gives the status of the source and the fourth column gives the
+full path of the source representing this unit.
+Here is a simple example of use:
 
-@node Using the GNU make Utility
-@chapter Using the GNU @code{make} Utility
-@findex make
+@smallexample
+$ gnatls *.o
+^./^[]^demo1.o            demo1            DIF demo1.adb
+^./^[]^demo2.o            demo2             OK demo2.adb
+^./^[]^hello.o            h1                OK hello.adb
+^./^[]^instr-child.o      instr.child      MOK instr-child.adb
+^./^[]^instr.o            instr             OK instr.adb
+^./^[]^tef.o              tef              DIF tef.adb
+^./^[]^text_io_example.o  text_io_example   OK text_io_example.adb
+^./^[]^tgef.o             tgef             DIF tgef.adb
+@end smallexample
 
 @noindent
-This chapter offers some examples of makefiles that solve specific
-problems. It does not explain how to write a makefile (see the GNU make
-documentation), nor does it try to replace the @code{gnatmake} utility
-(@pxref{The GNAT Make Program gnatmake}).
+The first line can be interpreted as follows: the main unit which is
+contained in
+object file @file{demo1.o} is demo1, whose main source is in
+@file{demo1.adb}. Furthermore, the version of the source used for the
+compilation of demo1 has been modified (DIF). Each source file has a status
+qualifier which can be:
 
-All the examples in this section are specific to the GNU version of
-make. Although @code{make} is a standard utility, and the basic language
-is the same, these examples use some advanced features found only in
-@code{GNU make}.
+@table @code
+@item OK (unchanged)
+The version of the source file used for the compilation of the
+specified unit corresponds exactly to the actual source file.
 
-@menu
-* Using gnatmake in a Makefile::
-* Automatically Creating a List of Directories::
-* Generating the Command Line Switches::
-* Overcoming Command Line Length Limits::
-@end menu
+@item MOK (slightly modified)
+The version of the source file used for the compilation of the
+specified unit differs from the actual source file but not enough to
+require recompilation. If you use gnatmake with the qualifier
+@option{^-m (minimal recompilation)^/MINIMAL_RECOMPILATION^}, a file marked
+MOK will not be recompiled.
 
-@node Using gnatmake in a Makefile
-@section Using gnatmake in a Makefile
-@findex makefile
-@cindex GNU make
+@item DIF (modified)
+No version of the source found on the path corresponds to the source
+used to build this object.
 
-@noindent
-Complex project organizations can be handled in a very powerful way by
-using GNU make combined with gnatmake. For instance, here is a Makefile
-which allows you to build each subsystem of a big project into a separate
-shared library. Such a makefile allows you to significantly reduce the link
-time of very big applications while maintaining full coherence at
-each step of the build process.
+@item ??? (file not found)
+No source file was found for this unit.
 
-The list of dependencies are handled automatically by
-@code{gnatmake}. The Makefile is simply used to call gnatmake in each of
-the appropriate directories.
+@item HID (hidden,  unchanged version not first on PATH)
+The version of the source that corresponds exactly to the source used
+for compilation has been found on the path but it is hidden by another
+version of the same source that has been modified.
 
-Note that you should also read the example on how to automatically
-create the list of directories
-(@pxref{Automatically Creating a List of Directories})
-which might help you in case your project has a lot of subdirectories.
+@end table
 
-@smallexample
-@iftex
-@leftskip=0cm
-@font@heightrm=cmr8
-@heightrm
-@end iftex
-## This Makefile is intended to be used with the following directory
-## configuration:
-##  - The sources are split into a series of csc (computer software components)
-##    Each of these csc is put in its own directory.
-##    Their name are referenced by the directory names.
-##    They will be compiled into shared library (although this would also work
-##    with static libraries
-##  - The main program (and possibly other packages that do not belong to any
-##    csc is put in the top level directory (where the Makefile is).
-##       toplevel_dir __ first_csc  (sources) __ lib (will contain the library)
-##                    \_ second_csc (sources) __ lib (will contain the library)
-##                    \_ ...
-## Although this Makefile is build for shared library, it is easy to modify
-## to build partial link objects instead (modify the lines with -shared and
-## gnatlink below)
-##
-## With this makefile, you can change any file in the system or add any new
-## file, and everything will be recompiled correctly (only the relevant shared
-## objects will be recompiled, and the main program will be re-linked).
+@node Switches for gnatls
+@section Switches for @code{gnatls}
 
-# The list of computer software component for your project. This might be
-# generated automatically.
-CSC_LIST=aa bb cc
+@noindent
+@code{gnatls} recognizes the following switches:
 
-# Name of the main program (no extension)
-MAIN=main
+@table @option
+@c !sort!
+@cindex @option{--version} @command{gnatls}
+Display Copyright and version, then exit disregarding all other options.
 
-# If we need to build objects with -fPIC, uncomment the following line
-#NEED_FPIC=-fPIC
+@item --help
+@cindex @option{--help} @command{gnatls}
+If @option{--version} was not used, display usage, then exit disregarding
+all other options.
 
-# The following variable should give the directory containing libgnat.so
-# You can get this directory through 'gnatls -v'. This is usually the last
-# directory in the Object_Path.
-GLIB=...
+@item ^-a^/ALL_UNITS^
+@cindex @option{^-a^/ALL_UNITS^} (@code{gnatls})
+Consider all units, including those of the predefined Ada library.
+Especially useful with @option{^-d^/DEPENDENCIES^}.
 
-# The directories for the libraries
-# (This macro expands the list of CSC to the list of shared libraries, you
-# could simply use the expanded form :
-# LIB_DIR=aa/lib/libaa.so bb/lib/libbb.so cc/lib/libcc.so
-LIB_DIR=$@{foreach dir,$@{CSC_LIST@},$@{dir@}/lib/lib$@{dir@}.so@}
+@item ^-d^/DEPENDENCIES^
+@cindex @option{^-d^/DEPENDENCIES^} (@code{gnatls})
+List sources from which specified units depend on.
 
-$@{MAIN@}: objects $@{LIB_DIR@}
-    gnatbind $@{MAIN@} $@{CSC_LIST:%=-aO%/lib@} -shared
-    gnatlink $@{MAIN@} $@{CSC_LIST:%=-l%@}
+@item ^-h^/OUTPUT=OPTIONS^
+@cindex @option{^-h^/OUTPUT=OPTIONS^} (@code{gnatls})
+Output the list of options.
 
-objects::
-    # recompile the sources
-    gnatmake -c -i $@{MAIN@}.adb $@{NEED_FPIC@} $@{CSC_LIST:%=-I%@}
+@item ^-o^/OUTPUT=OBJECTS^
+@cindex @option{^-o^/OUTPUT=OBJECTS^} (@code{gnatls})
+Only output information about object files.
 
-# Note: In a future version of GNAT, the following commands will be simplified
-# by a new tool, gnatmlib
-$@{LIB_DIR@}:
-    mkdir -p $@{dir $@@ @}
-    cd $@{dir $@@ @}; gcc -shared -o $@{notdir $@@ @} ../*.o -L$@{GLIB@} -lgnat
-    cd $@{dir $@@ @}; cp -f ../*.ali .
-
-# The dependencies for the modules
-# Note that we have to force the expansion of *.o, since in some cases
-# make won't be able to do it itself.
-aa/lib/libaa.so: $@{wildcard aa/*.o@}
-bb/lib/libbb.so: $@{wildcard bb/*.o@}
-cc/lib/libcc.so: $@{wildcard cc/*.o@}
-
-# Make sure all of the shared libraries are in the path before starting the
-# program
-run::
-    LD_LIBRARY_PATH=`pwd`/aa/lib:`pwd`/bb/lib:`pwd`/cc/lib ./$@{MAIN@}
+@item ^-s^/OUTPUT=SOURCES^
+@cindex @option{^-s^/OUTPUT=SOURCES^} (@code{gnatls})
+Only output information about source files.
 
-clean::
-    $@{RM@} -rf $@{CSC_LIST:%=%/lib@}
-    $@{RM@} $@{CSC_LIST:%=%/*.ali@}
-    $@{RM@} $@{CSC_LIST:%=%/*.o@}
-    $@{RM@} *.o *.ali $@{MAIN@}
-@end smallexample
+@item ^-u^/OUTPUT=UNITS^
+@cindex @option{^-u^/OUTPUT=UNITS^} (@code{gnatls})
+Only output information about compilation units.
 
-@node Automatically Creating a List of Directories
-@section Automatically Creating a List of Directories
+@item ^-files^/FILES^=@var{file}
+@cindex @option{^-files^/FILES^} (@code{gnatls})
+Take as arguments the files listed in text file @var{file}.
+Text file @var{file} may contain empty lines that are ignored.
+Each non empty line should contain the name of an existing file.
+Several such switches may be specified simultaneously.
 
-@noindent
-In most makefiles, you will have to specify a list of directories, and
-store it in a variable. For small projects, it is often easier to
-specify each of them by hand, since you then have full control over what
-is the proper order for these directories, which ones should be
-included...
+@item ^-aO^/OBJECT_SEARCH=^@var{dir}
+@itemx ^-aI^/SOURCE_SEARCH=^@var{dir}
+@itemx ^-I^/SEARCH=^@var{dir}
+@itemx  ^-I-^/NOCURRENT_DIRECTORY^
+@itemx -nostdinc
+@cindex @option{^-aO^/OBJECT_SEARCH^} (@code{gnatls})
+@cindex @option{^-aI^/SOURCE_SEARCH^} (@code{gnatls})
+@cindex @option{^-I^/SEARCH^} (@code{gnatls})
+@cindex @option{^-I-^/NOCURRENT_DIRECTORY^} (@code{gnatls})
+Source path manipulation. Same meaning as the equivalent @command{gnatmake}
+flags (@pxref{Switches for gnatmake}).
 
-However, in larger projects, which might involve hundreds of
-subdirectories, it might be more convenient to generate this list
-automatically.
+@item --RTS=@var{rts-path}
+@cindex @option{--RTS} (@code{gnatls})
+Specifies the default location of the runtime library. Same meaning as the
+equivalent @command{gnatmake} flag (@pxref{Switches for gnatmake}).
 
-The example below presents two methods. The first one, although less
-general, gives you more control over the list. It involves wildcard
-characters, that are automatically expanded by @code{make}. Its
-shortcoming is that you need to explicitly specify some of the
-organization of your project, such as for instance the directory tree
-depth, whether some directories are found in a separate tree,...
+@item ^-v^/OUTPUT=VERBOSE^
+@cindex @option{^-v^/OUTPUT=VERBOSE^} (@code{gnatls})
+Verbose mode. Output the complete source, object and project paths. Do not use
+the default column layout but instead use long format giving as much as
+information possible on each requested units, including special
+characteristics such as:
 
-The second method is the most general one. It requires an external
-program, called @code{find}, which is standard on all Unix systems. All
-the directories found under a given root directory will be added to the
-list.
+@table @code
+@item  Preelaborable
+The unit is preelaborable in the Ada sense.
 
-@smallexample
-@iftex
-@leftskip=0cm
-@font@heightrm=cmr8
-@heightrm
-@end iftex
-# The examples below are based on the following directory hierarchy:
-# All the directories can contain any number of files
-# ROOT_DIRECTORY ->  a  ->  aa  ->  aaa
-#                       ->  ab
-#                       ->  ac
-#                ->  b  ->  ba  ->  baa
-#                       ->  bb
-#                       ->  bc
-# This Makefile creates a variable called DIRS, that can be reused any time
-# you need this list (see the other examples in this section)
+@item No_Elab_Code
+No elaboration code has been produced by the compiler for this unit.
 
-# The root of your project's directory hierarchy
-ROOT_DIRECTORY=.
+@item Pure
+The unit is pure in the Ada sense.
 
-####
-# First method: specify explicitly the list of directories
-# This allows you to specify any subset of all the directories you need.
-####
+@item Elaborate_Body
+The unit contains a pragma Elaborate_Body.
 
-DIRS := a/aa/ a/ab/ b/ba/
+@item Remote_Types
+The unit contains a pragma Remote_Types.
 
-####
-# Second method: use wildcards
-# Note that the argument(s) to wildcard below should end with a '/'.
-# Since wildcards also return file names, we have to filter them out
-# to avoid duplicate directory names.
-# We thus use make's @code{dir} and @code{sort} functions.
-# It sets DIRs to the following value (note that the directories aaa and baa
-# are not given, unless you change the arguments to wildcard).
-# DIRS= ./a/a/ ./b/ ./a/aa/ ./a/ab/ ./a/ac/ ./b/ba/ ./b/bb/ ./b/bc/
-####
+@item Shared_Passive
+The unit contains a pragma Shared_Passive.
 
-DIRS := $@{sort $@{dir $@{wildcard $@{ROOT_DIRECTORY@}/*/
-                    $@{ROOT_DIRECTORY@}/*/*/@}@}@}
+@item Predefined
+This unit is part of the predefined environment and cannot be modified
+by the user.
 
-####
-# Third method: use an external program
-# This command is much faster if run on local disks, avoiding NFS slowdowns.
-# This is the most complete command: it sets DIRs to the following value:
-# DIRS= ./a ./a/aa ./a/aa/aaa ./a/ab ./a/ac ./b ./b/ba ./b/ba/baa ./b/bb ./b/bc
-####
+@item Remote_Call_Interface
+The unit contains a pragma Remote_Call_Interface.
 
-DIRS := $@{shell find $@{ROOT_DIRECTORY@} -type d -print@}
+@end table
 
-@end smallexample
+@end table
 
-@node Generating the Command Line Switches
-@section Generating the Command Line Switches
+@node Examples of gnatls Usage
+@section Example of @code{gnatls} Usage
+@ifclear vms
 
 @noindent
-Once you have created the list of directories as explained in the
-previous section (@pxref{Automatically Creating a List of Directories}),
-you can easily generate the command line arguments to pass to gnatmake.
-
-For the sake of completeness, this example assumes that the source path
-is not the same as the object path, and that you have two separate lists
-of directories.
+Example of using the verbose switch. Note how the source and
+object paths are affected by the -I switch.
 
 @smallexample
-# see "Automatically creating a list of directories" to create
-# these variables
-SOURCE_DIRS=
-OBJECT_DIRS=
-
-GNATMAKE_SWITCHES := $@{patsubst %,-aI%,$@{SOURCE_DIRS@}@}
-GNATMAKE_SWITCHES += $@{patsubst %,-aO%,$@{OBJECT_DIRS@}@}
-
-all:
-        gnatmake $@{GNATMAKE_SWITCHES@} main_unit
-@end smallexample
+$ gnatls -v -I.. demo1.o
 
-@node Overcoming Command Line Length Limits
-@section Overcoming Command Line Length Limits
+GNATLS 5.03w (20041123-34)
+Copyright 1997-2004 Free Software Foundation, Inc.
 
-@noindent
-One problem that might be encountered on big projects is that many
-operating systems limit the length of the command line. It is thus hard to give
-gnatmake the list of source and object directories.
+Source Search Path:
+   <Current_Directory>
+   ../
+   /home/comar/local/adainclude/
 
-This example shows how you can set up environment variables, which will
-make @code{gnatmake} behave exactly as if the directories had been
-specified on the command line, but have a much higher length limit (or
-even none on most systems).
+Object Search Path:
+   <Current_Directory>
+   ../
+   /home/comar/local/lib/gcc-lib/x86-linux/3.4.3/adalib/
 
-It assumes that you have created a list of directories in your Makefile,
-using one of the methods presented in
-@ref{Automatically Creating a List of Directories}.
-For the sake of completeness, we assume that the object
-path (where the ALI files are found) is different from the sources patch.
+Project Search Path:
+   <Current_Directory>
+   /home/comar/local/lib/gnat/
 
-Note a small trick in the Makefile below: for efficiency reasons, we
-create two temporary variables (SOURCE_LIST and OBJECT_LIST), that are
-expanded immediately by @code{make}. This way we overcome the standard
-make behavior which is to expand the variables only when they are
-actually used.
+./demo1.o
+   Unit =>
+     Name   => demo1
+     Kind   => subprogram body
+     Flags  => No_Elab_Code
+     Source => demo1.adb    modified
+@end smallexample
 
-On Windows, if you are using the standard Windows command shell, you must
-replace colons with semicolons in the assignments to these variables.
+@noindent
+The following is an example of use of the dependency list.
+Note the use of the -s switch
+which gives a straight list of source files. This can be useful for
+building specialized scripts.
 
 @smallexample
-@iftex
-@leftskip=0cm
-@font@heightrm=cmr8
-@heightrm
-@end iftex
-# In this example, we create both ADA_INCLUDE_PATH and ADA_OBJECT_PATH.
-# This is the same thing as putting the -I arguments on the command line.
-# (the equivalent of using -aI on the command line would be to define
-#  only ADA_INCLUDE_PATH, the equivalent of -aO is ADA_OBJECT_PATH).
-# You can of course have different values for these variables.
-#
-# Note also that we need to keep the previous values of these variables, since
-# they might have been set before running 'make' to specify where the GNAT
-# library is installed.
-
-# see "Automatically creating a list of directories" to create these
-# variables
-SOURCE_DIRS=
-OBJECT_DIRS=
-
-empty:=
-space:=$@{empty@} $@{empty@}
-SOURCE_LIST := $@{subst $@{space@},:,$@{SOURCE_DIRS@}@}
-OBJECT_LIST := $@{subst $@{space@},:,$@{OBJECT_DIRS@}@}
-ADA_INCLUDE_PATH += $@{SOURCE_LIST@}
-ADA_OBJECT_PATH += $@{OBJECT_LIST@}
-export ADA_INCLUDE_PATH
-export ADA_OBJECT_PATH
+$ gnatls -d demo2.o
+./demo2.o   demo2        OK demo2.adb
+                         OK gen_list.ads
+                         OK gen_list.adb
+                         OK instr.ads
+                         OK instr-child.ads
 
-all:
-        gnatmake main_unit
+$ gnatls -d -s -a demo1.o
+demo1.adb
+/home/comar/local/adainclude/ada.ads
+/home/comar/local/adainclude/a-finali.ads
+/home/comar/local/adainclude/a-filico.ads
+/home/comar/local/adainclude/a-stream.ads
+/home/comar/local/adainclude/a-tags.ads
+gen_list.ads
+gen_list.adb
+/home/comar/local/adainclude/gnat.ads
+/home/comar/local/adainclude/g-io.ads
+instr.ads
+/home/comar/local/adainclude/system.ads
+/home/comar/local/adainclude/s-exctab.ads
+/home/comar/local/adainclude/s-finimp.ads
+/home/comar/local/adainclude/s-finroo.ads
+/home/comar/local/adainclude/s-secsta.ads
+/home/comar/local/adainclude/s-stalib.ads
+/home/comar/local/adainclude/s-stoele.ads
+/home/comar/local/adainclude/s-stratt.ads
+/home/comar/local/adainclude/s-tasoli.ads
+/home/comar/local/adainclude/s-unstyp.ads
+/home/comar/local/adainclude/unchconv.ads
 @end smallexample
 @end ifclear
 
+@ifset vms
+@smallexample
+GNAT LIST /DEPENDENCIES /OUTPUT=SOURCES /ALL_UNITS DEMO1.ADB
 
-@node Finding Memory Problems
-@chapter Finding Memory Problems
-
-@noindent
-This chapter describes
-@ifclear vms
-the @command{gnatmem} tool, which can be used to track down
-``memory leaks'', and
-@end ifclear
-the GNAT Debug Pool facility, which can be used to detect incorrect uses of
-access values (including ``dangling references'').
-
-@menu
-@ifclear vms
-* The gnatmem Tool::
-@end ifclear
-* The GNAT Debug Pool Facility::
-@end menu
-
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]ada.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]a-finali.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]a-filico.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]a-stream.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]a-tags.ads
+demo1.adb
+gen_list.ads
+gen_list.adb
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]gnat.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]g-io.ads
+instr.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]system.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-exctab.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-finimp.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-finroo.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-secsta.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-stalib.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-stoele.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-stratt.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-tasoli.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]s-unstyp.ads
+GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]unchconv.ads
+@end smallexample
+@end ifset
 
-@ifclear vms
-@node The gnatmem Tool
-@section The @command{gnatmem} Tool
-@findex gnatmem
+@node Cleaning Up Using gnatclean
+@chapter Cleaning Up Using @code{gnatclean}
+@findex gnatclean
+@cindex Cleaning tool
 
 @noindent
-The @code{gnatmem} utility monitors dynamic allocation and
-deallocation activity in a program, and displays information about
-incorrect deallocations and possible sources of memory leaks.
-It provides three type of information:
-@itemize @bullet
-@item
-General information concerning memory management, such as the total
-number of allocations and deallocations, the amount of allocated
-memory and the high water mark, i.e. the largest amount of allocated
-memory in the course of program execution.
-
-@item
-Backtraces for all incorrect deallocations, that is to say deallocations
-which do not correspond to a valid allocation.
-
-@item
-Information on each allocation that is potentially the origin of a memory
-leak.
-@end itemize
+@code{gnatclean} is a tool that allows the deletion of files produced by the
+compiler, binder and linker, including ALI files, object files, tree files,
+expanded source files, library files, interface copy source files, binder
+generated files and executable files.
 
 @menu
-* Running gnatmem::
-* Switches for gnatmem::
-* Example of gnatmem Usage::
+* Running gnatclean::
+* Switches for gnatclean::
+@c * Examples of gnatclean Usage::
 @end menu
 
-@node Running gnatmem
-@subsection Running @code{gnatmem}
-
-@noindent
-@code{gnatmem} makes use of the output created by the special version of
-allocation and deallocation routines that record call information. This
-allows to obtain accurate dynamic memory usage history at a minimal cost to
-the execution speed. Note however, that @code{gnatmem} is not supported on
-all platforms (currently, it is supported on AIX, HP-UX, GNU/Linux x86,
-Solaris (sparc and x86) and Windows NT/2000/XP (x86).
+@node Running gnatclean
+@section Running @code{gnatclean}
 
 @noindent
-The @code{gnatmem} command has the form
+The @code{gnatclean} command has the form:
 
 @smallexample
-   $ gnatmem [switches] user_program
+$ gnatclean switches @var{names}
 @end smallexample
 
 @noindent
-The program must have been linked with the instrumented version of the
-allocation and deallocation routines. This is done by linking with the
-@file{libgmem.a} library. For correct symbolic backtrace information,
-the user program should be compiled with debugging options
-@ref{Switches for gcc}. For example to build @file{my_program}:
-
-@smallexample
-$ gnatmake -g my_program -largs -lgmem
-@end smallexample
+@var{names} is a list of source file names. Suffixes @code{.^ads^ADS^} and
+@code{^adb^ADB^} may be omitted. If a project file is specified using switch
+@code{^-P^/PROJECT_FILE=^}, then @var{names} may be completely omitted.
 
 @noindent
-When running @file{my_program} the file @file{gmem.out} is produced. This file
-contains information about all allocations and deallocations done by the
-program. It is produced by the instrumented allocations and
-deallocations routines and will be used by @code{gnatmem}.
+In normal mode, @code{gnatclean} delete the files produced by the compiler and,
+if switch @code{^-c^/COMPILER_FILES_ONLY^} is not specified, by the binder and
+the linker. In informative-only mode, specified by switch
+@code{^-n^/NODELETE^}, the list of files that would have been deleted in
+normal mode is listed, but no file is actually deleted.
+
+@node Switches for gnatclean
+@section Switches for @code{gnatclean}
 
 @noindent
-Gnatmem must be supplied with the @file{gmem.out} file and the executable to
-examine. If the location of @file{gmem.out} file was not explicitly supplied by
-@code{-i} switch, gnatmem will assume that this file can be found in the
-current directory. For example, after you have executed @file{my_program},
-@file{gmem.out} can be analyzed by @code{gnatmem} using the command:
+@code{gnatclean} recognizes the following switches:
 
-@smallexample
-$ gnatmem my_program
-@end smallexample
+@table @option
+@c !sort!
+@cindex @option{--version} @command{gnatclean}
+Display Copyright and version, then exit disregarding all other options.
 
-@noindent
-This will produce the output with the following format:
+@item --help
+@cindex @option{--help} @command{gnatclean}
+If @option{--version} was not used, display usage, then exit disregarding
+all other options.
 
-*************** debut cc
-@smallexample
-$ gnatmem my_program
+@item ^-c^/COMPILER_FILES_ONLY^
+@cindex @option{^-c^/COMPILER_FILES_ONLY^} (@code{gnatclean})
+Only attempt to delete the files produced by the compiler, not those produced
+by the binder or the linker. The files that are not to be deleted are library
+files, interface copy files, binder generated files and executable files.
 
-Global information
-------------------
-   Total number of allocations        :  45
-   Total number of deallocations      :   6
-   Final Water Mark (non freed mem)   :  11.29 Kilobytes
-   High Water Mark                    :  11.40 Kilobytes
+@item ^-D ^/DIRECTORY_OBJECTS=^@var{dir}
+@cindex @option{^-D^/DIRECTORY_OBJECTS^} (@code{gnatclean})
+Indicate that ALI and object files should normally be found in directory
+@var{dir}.
 
-.
-.
-.
-Allocation Root # 2
--------------------
- Number of non freed allocations    :  11
- Final Water Mark (non freed mem)   :   1.16 Kilobytes
- High Water Mark                    :   1.27 Kilobytes
- Backtrace                          :
-   my_program.adb:23 my_program.alloc
-.
-.
-.
-@end smallexample
+@item ^-F^/FULL_PATH_IN_BRIEF_MESSAGES^
+@cindex @option{^-F^/FULL_PATH_IN_BRIEF_MESSAGES^} (@code{gnatclean})
+When using project files, if some errors or warnings are detected during
+parsing and verbose mode is not in effect (no use of switch
+^-v^/VERBOSE^), then error lines start with the full path name of the project
+file, rather than its simple file name.
 
-The first block of output gives general information. In this case, the
-Ada construct ``@code{@b{new}}'' was executed 45 times, and only 6 calls to an
-Unchecked_Deallocation routine occurred.
+@item ^-h^/HELP^
+@cindex @option{^-h^/HELP^} (@code{gnatclean})
+Output a message explaining the usage of @code{^gnatclean^gnatclean^}.
 
-@noindent
-Subsequent paragraphs display  information on all allocation roots.
-An allocation root is a specific point in the execution of the program
-that generates some dynamic allocation, such as a ``@code{@b{new}}''
-construct. This root is represented by an execution backtrace (or subprogram
-call stack). By default the backtrace depth for allocations roots is 1, so
-that a root corresponds exactly to a source location. The backtrace can
-be made deeper, to make the root more specific.
+@item ^-n^/NODELETE^
+@cindex @option{^-n^/NODELETE^} (@code{gnatclean})
+Informative-only mode. Do not delete any files. Output the list of the files
+that would have been deleted if this switch was not specified.
 
-@node Switches for gnatmem
-@subsection Switches for @code{gnatmem}
+@item ^-P^/PROJECT_FILE=^@var{project}
+@cindex @option{^-P^/PROJECT_FILE^} (@code{gnatclean})
+Use project file @var{project}. Only one such switch can be used.
+When cleaning a project file, the files produced by the compilation of the
+immediate sources or inherited sources of the project files are to be
+deleted. This is not depending on the presence or not of executable names
+on the command line.
 
-@noindent
-@code{gnatmem} recognizes the following switches:
+@item ^-q^/QUIET^
+@cindex @option{^-q^/QUIET^} (@code{gnatclean})
+Quiet output. If there are no errors, do not output anything, except in
+verbose mode (switch ^-v^/VERBOSE^) or in informative-only mode
+(switch ^-n^/NODELETE^).
 
-@table @option
+@item ^-r^/RECURSIVE^
+@cindex @option{^-r^/RECURSIVE^} (@code{gnatclean})
+When a project file is specified (using switch ^-P^/PROJECT_FILE=^),
+clean all imported and extended project files, recursively. If this switch
+is not specified, only the files related to the main project file are to be
+deleted. This switch has no effect if no project file is specified.
 
-@item -q
-@cindex @option{-q} (@code{gnatmem})
-Quiet. Gives the minimum output needed to identify the origin of the
-memory leaks. Omits statistical information.
+@item ^-v^/VERBOSE^
+@cindex @option{^-v^/VERBOSE^} (@code{gnatclean})
+Verbose mode.
 
-@item @var{N}
-@cindex @var{N} (@code{gnatmem})
-N is an integer literal (usually between 1 and 10) which controls the
-depth of the backtraces defining allocation root. The default value for
-N is 1. The deeper the backtrace, the more precise the localization of
-the root. Note that the total number of roots can depend on this
-parameter. This parameter must be specified @emph{before} the name of the
-executable to be analyzed, to avoid ambiguity.
+@item ^-vP^/MESSAGES_PROJECT_FILE=^@emph{x}
+@cindex @option{^-vP^/MESSAGES_PROJECT_FILE^} (@code{gnatclean})
+Indicates the verbosity of the parsing of GNAT project files.
+@xref{Switches Related to Project Files}.
 
-@item -b n
-@cindex @option{-b} (@code{gnatmem})
-This switch has the same effect as just depth parameter.
+@item ^-X^/EXTERNAL_REFERENCE=^@var{name=value}
+@cindex @option{^-X^/EXTERNAL_REFERENCE^} (@code{gnatclean})
+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.
+@xref{Switches Related to Project Files}.
 
-@item -i @var{file}
-@cindex @option{-i} (@code{gnatmem})
-Do the @code{gnatmem} processing starting from @file{file}, rather than
-@file{gmem.out} in the current directory.
+@item ^-aO^/OBJECT_SEARCH=^@var{dir}
+@cindex @option{^-aO^/OBJECT_SEARCH^} (@code{gnatclean})
+When searching for ALI and object files, look in directory
+@var{dir}.
 
-@item -m n
-@cindex @option{-m} (@code{gnatmem})
-This switch causes @code{gnatmem} to mask the allocation roots that have less
-than n leaks. The default value is 1. Specifying the value of 0 will allow to
-examine even the roots that didn't result in leaks.
+@item ^-I^/SEARCH=^@var{dir}
+@cindex @option{^-I^/SEARCH^} (@code{gnatclean})
+Equivalent to @option{^-aO^/OBJECT_SEARCH=^@var{dir}}.
 
-@item -s order
-@cindex @option{-s} (@code{gnatmem})
-This switch causes @code{gnatmem} to sort the allocation roots according to the
-specified order of sort criteria, each identified by a single letter. The
-currently supported criteria are @code{n, h, w} standing respectively for
-number of unfreed allocations, high watermark, and final watermark
-corresponding to a specific root. The default order is @code{nwh}.
+@item ^-I-^/NOCURRENT_DIRECTORY^
+@cindex @option{^-I-^/NOCURRENT_DIRECTORY^} (@code{gnatclean})
+@cindex Source files, suppressing search
+Do not look for ALI or object files in the directory
+where @code{gnatclean} was invoked.
 
 @end table
 
-@node Example of gnatmem Usage
-@subsection Example of @code{gnatmem} Usage
+@c @node Examples of gnatclean Usage
+@c @section Examples of @code{gnatclean} Usage
+
+@ifclear vms
+@node GNAT and Libraries
+@chapter GNAT and Libraries
+@cindex Library, building, installing, using
 
 @noindent
-The following example shows the use of @code{gnatmem}
-on a simple memory-leaking program.
-Suppose that we have the following Ada program:
+This chapter describes how to build and use libraries with GNAT, and also shows
+how to recompile the GNAT run-time library. You should be familiar with the
+Project Manager facility (@pxref{GNAT Project Manager}) before reading this
+chapter.
 
-@smallexample @c ada
-@group
-@cartouche
-with Unchecked_Deallocation;
-procedure Test_Gm is
+@menu
+* Introduction to Libraries in GNAT::
+* General Ada Libraries::
+* Stand-alone Ada Libraries::
+* Rebuilding the GNAT Run-Time Library::
+@end menu
 
-   type T is array (1..1000) of Integer;
-   type Ptr is access T;
-   procedure Free is new Unchecked_Deallocation (T, Ptr);
-   A : Ptr;
+@node Introduction to Libraries in GNAT
+@section Introduction to Libraries in GNAT
 
-   procedure My_Alloc is
-   begin
-      A := new T;
-   end My_Alloc;
+@noindent
+A library is, conceptually, a collection of objects which does not have its
+own main thread of execution, but rather provides certain services to the
+applications that use it. A library can be either statically linked with the
+application, in which case its code is directly included in the application,
+or, on platforms that support it, be dynamically linked, in which case
+its code is shared by all applications making use of this library.
 
-   procedure My_DeAlloc is
-      B : Ptr := A;
-   begin
-      Free (B);
-   end My_DeAlloc;
+GNAT supports both types of libraries.
+In the static case, the compiled code can be provided in different ways. The
+simplest approach is to provide directly the set of objects resulting from
+compilation of the library source files. Alternatively, you can group the
+objects into an archive using whatever commands are provided by the operating
+system. For the latter case, the objects are grouped into a shared library.
 
-begin
-   My_Alloc;
-   for I in 1 .. 5 loop
-      for J in I .. 5 loop
-         My_Alloc;
-      end loop;
-      My_Dealloc;
-   end loop;
-end;
-@end cartouche
-@end group
-@end smallexample
+In the GNAT environment, a library has three types of components:
+@itemize @bullet
+@item
+Source files.
+@item
+@file{ALI} files.
+@xref{The Ada Library Information Files}.
+@item
+Object files, an archive or a shared library.
+@end itemize
 
 @noindent
-The program needs to be compiled with debugging option and linked with
-@code{gmem} library:
+A GNAT library may expose all its source files, which is useful for
+documentation purposes. Alternatively, it may expose only the units needed by
+an external user to make use of the library. That is to say, the specs
+reflecting the library services along with all the units needed to compile
+those specs, which can include generic bodies or any body implementing an
+inlined routine. In the case of @emph{stand-alone libraries} those exposed
+units are called @emph{interface units} (@pxref{Stand-alone Ada Libraries}).
 
-@smallexample
-$ gnatmake -g test_gm -largs -lgmem
-@end smallexample
+All compilation units comprising an application, including those in a library,
+need to be elaborated in an order partially defined by Ada's semantics. GNAT
+computes the elaboration order from the @file{ALI} files and this is why they
+constitute a mandatory part of GNAT libraries. Except in the case of
+@emph{stand-alone libraries}, where a specific library elaboration routine is
+produced independently of the application(s) using the library.
 
-@noindent
-Then we execute the program as usual:
+@node General Ada Libraries
+@section General Ada Libraries
 
-@smallexample
-$ test_gm
-@end smallexample
+@menu
+* Building a library::
+* Installing a library::
+* Using a library::
+@end menu
 
-@noindent
-Then @code{gnatmem} is invoked simply with
-@smallexample
-$ gnatmem test_gm
-@end smallexample
+@node Building a library
+@subsection Building a library
 
 @noindent
-which produces the following output (result may vary on different platforms):
-
-@smallexample
-Global information
-------------------
-   Total number of allocations        :  18
-   Total number of deallocations      :   5
-   Final Water Mark (non freed mem)   :  53.00 Kilobytes
-   High Water Mark                    :  56.90 Kilobytes
+The easiest way to build a library is to use the Project Manager,
+which supports a special type of project called a @emph{Library Project}
+(@pxref{Library Projects}).
 
-Allocation Root # 1
--------------------
- Number of non freed allocations    :  11
- Final Water Mark (non freed mem)   :  42.97 Kilobytes
- High Water Mark                    :  46.88 Kilobytes
- Backtrace                          :
-   test_gm.adb:11 test_gm.my_alloc
+A project is considered a library project, when two project-level attributes
+are defined in it: @code{Library_Name} and @code{Library_Dir}. In order to
+control different aspects of library configuration, additional optional
+project-level attributes can be specified:
+@table @code
+@item Library_Kind
+This attribute controls whether the library is to be static or dynamic
 
-Allocation Root # 2
--------------------
- Number of non freed allocations    :   1
- Final Water Mark (non freed mem)   :  10.02 Kilobytes
- High Water Mark                    :  10.02 Kilobytes
- Backtrace                          :
-   s-secsta.adb:81 system.secondary_stack.ss_init
+@item Library_Version
+This attribute specifies the library version; this value is used
+during dynamic linking of shared libraries to determine if the currently
+installed versions of the binaries are compatible.
 
-Allocation Root # 3
--------------------
- Number of non freed allocations    :   1
- Final Water Mark (non freed mem)   :  12 Bytes
- High Water Mark                    :  12 Bytes
- Backtrace                          :
-   s-secsta.adb:181 system.secondary_stack.ss_init
-@end smallexample
+@item Library_Options
+@item Library_GCC
+These attributes specify additional low-level options to be used during
+library generation, and redefine the actual application used to generate
+library.
+@end table
 
 @noindent
-Note that the GNAT run time contains itself a certain number of
-allocations that have no  corresponding deallocation,
-as shown here for root #2 and root
-#3. This is a normal behavior when the number of non freed allocations
-is one, it allocates dynamic data structures that the run time needs for
-the complete lifetime of the program. Note also that there is only one
-allocation root in the user program with a single line back trace:
-test_gm.adb:11 test_gm.my_alloc, whereas a careful analysis of the
-program shows that 'My_Alloc' is called at 2 different points in the
-source (line 21 and line 24). If those two allocation roots need to be
-distinguished, the backtrace depth parameter can be used:
+The GNAT Project Manager takes full care of the library maintenance task,
+including recompilation of the source files for which objects do not exist
+or are not up to date, assembly of the library archive, and installation of
+the library (i.e., copying associated source, object and @file{ALI} files
+to the specified location).
 
-@smallexample
-$ gnatmem 3 test_gm
+Here is a simple library project file:
+@smallexample @c ada
+project My_Lib is
+   for Source_Dirs use ("src1", "src2");
+   for Object_Dir use "obj";
+   for Library_Name use "mylib";
+   for Library_Dir use "lib";
+   for Library_Kind use "dynamic";
+end My_lib;
 @end smallexample
 
 @noindent
-which will give the following output:
+and the compilation command to build and install the library:
 
-@smallexample
-Global information
-------------------
-   Total number of allocations        :  18
-   Total number of deallocations      :   5
-   Final Water Mark (non freed mem)   :  53.00 Kilobytes
-   High Water Mark                    :  56.90 Kilobytes
+@smallexample @c ada
+  $ gnatmake -Pmy_lib
+@end smallexample
 
-Allocation Root # 1
--------------------
- Number of non freed allocations    :  10
- Final Water Mark (non freed mem)   :  39.06 Kilobytes
- High Water Mark                    :  42.97 Kilobytes
- Backtrace                          :
-   test_gm.adb:11 test_gm.my_alloc
-   test_gm.adb:24 test_gm
-   b_test_gm.c:52 main
+@noindent
+It is not entirely trivial to perform manually all the steps required to
+produce a library. We recommend that you use the GNAT Project Manager
+for this task. In special cases where this is not desired, the necessary
+steps are discussed below.
 
-Allocation Root # 2
--------------------
- Number of non freed allocations    :   1
- Final Water Mark (non freed mem)   :  10.02 Kilobytes
- High Water Mark                    :  10.02 Kilobytes
- Backtrace                          :
-   s-secsta.adb:81  system.secondary_stack.ss_init
-   s-secsta.adb:283 <system__secondary_stack___elabb>
-   b_test_gm.c:33   adainit
+There are various possibilities for compiling the units that make up the
+library: for example with a Makefile (@pxref{Using the GNU make Utility}) or
+with a conventional script. For simple libraries, it is also possible to create
+a dummy main program which depends upon all the packages that comprise the
+interface of the library. This dummy main program can then be given to
+@command{gnatmake}, which will ensure that all necessary objects are built.
 
-Allocation Root # 3
--------------------
- Number of non freed allocations    :   1
- Final Water Mark (non freed mem)   :   3.91 Kilobytes
- High Water Mark                    :   3.91 Kilobytes
- Backtrace                          :
-   test_gm.adb:11 test_gm.my_alloc
-   test_gm.adb:21 test_gm
-   b_test_gm.c:52 main
+After this task is accomplished, you should follow the standard procedure
+of the underlying operating system to produce the static or shared library.
 
-Allocation Root # 4
--------------------
- Number of non freed allocations    :   1
- Final Water Mark (non freed mem)   :  12 Bytes
- High Water Mark                    :  12 Bytes
- Backtrace                          :
-   s-secsta.adb:181 system.secondary_stack.ss_init
-   s-secsta.adb:283 <system__secondary_stack___elabb>
-   b_test_gm.c:33   adainit
+Here is an example of such a dummy program:
+@smallexample @c ada
+@group
+with My_Lib.Service1;
+with My_Lib.Service2;
+with My_Lib.Service3;
+procedure My_Lib_Dummy is
+begin
+   null;
+end;
+@end group
 @end smallexample
 
 @noindent
-The allocation root #1 of the first example has been split in 2 roots #1
-and #3 thanks to the more precise associated backtrace.
+Here are the generic commands that will build an archive or a shared library.
 
-@end ifclear
+@smallexample
+# compiling the library
+$ gnatmake -c my_lib_dummy.adb
 
+# we don't need the dummy object itself
+$ rm my_lib_dummy.o my_lib_dummy.ali
 
-@node The GNAT Debug Pool Facility
-@section The GNAT Debug Pool Facility
-@findex Debug Pool
-@cindex storage, pool, memory corruption
+# create an archive with the remaining objects
+$ ar rc libmy_lib.a *.o
+# some systems may require "ranlib" to be run as well
 
-@noindent
-The use of unchecked deallocation and unchecked conversion can easily
-lead to incorrect memory references. The problems generated by such
-references are usually difficult to tackle because the symptoms can be
-very remote from the origin of the problem. In such cases, it is
-very helpful to detect the problem as early as possible. This is the
-purpose of the Storage Pool provided by @code{GNAT.Debug_Pools}.
+# or create a shared library
+$ gcc -shared -o libmy_lib.so *.o
+# some systems may require the code to have been compiled with -fPIC
 
-In order to use the GNAT specific debugging pool, the user must
-associate a debug pool object with each of the access types that may be
-related to suspected memory problems. See Ada Reference Manual 13.11.
-@smallexample @c ada
-type Ptr is access Some_Type;
-Pool : GNAT.Debug_Pools.Debug_Pool;
-for Ptr'Storage_Pool use Pool;
+# remove the object files that are now in the library
+$ rm *.o
+
+# Make the ALI files read-only so that gnatmake will not try to
+# regenerate the objects that are in the library
+$ chmod -w *.ali
 @end smallexample
 
 @noindent
-@code{GNAT.Debug_Pools} is derived from a GNAT-specific kind of
-pool: the @code{Checked_Pool}. Such pools, like standard Ada storage pools,
-allow the user to redefine allocation and deallocation strategies. They
-also provide a checkpoint for each dereference, through the use of
-the primitive operation @code{Dereference} which is implicitly called at
-each dereference of an access value.
+Please note that the library must have a name of the form @file{libxxx.a} or
+@file{libxxx.so} (or @file{libxxx.dll} on Windows) in order to be accessed by
+the directive @option{-lxxx} at link time.
 
-Once an access type has been associated with a debug pool, operations on
-values of the type may raise four distinct exceptions,
-which correspond to four potential kinds of memory corruption:
-@itemize @bullet
-@item
-@code{GNAT.Debug_Pools.Accessing_Not_Allocated_Storage}
-@item
-@code{GNAT.Debug_Pools.Accessing_Deallocated_Storage}
-@item
-@code{GNAT.Debug_Pools.Freeing_Not_Allocated_Storage}
-@item
-@code{GNAT.Debug_Pools.Freeing_Deallocated_Storage }
-@end itemize
+@node Installing a library
+@subsection Installing a library
+@cindex @code{ADA_PROJECT_PATH}
 
 @noindent
-For types associated with a Debug_Pool, dynamic allocation is performed using
-the standard
-GNAT allocation routine. References to all allocated chunks of memory
-are kept in an internal dictionary.
-Several deallocation strategies are provided, whereupon the user can choose
-to release the memory to the system, keep it allocated for further invalid
-access checks, or fill it with an easily recognizable pattern for debug
-sessions.
-The memory pattern is the old IBM hexadecimal convention: @code{16#DEADBEEF#}.
+If you use project files, library installation is part of the library build
+process. Thus no further action is needed in order to make use of the
+libraries that are built as part of the general application build. A usable
+version of the library is installed in the directory specified by the
+@code{Library_Dir} attribute of the library project file.
 
-See the documentation in the file g-debpoo.ads for more information on the
-various strategies.
+You may want to install a library in a context different from where the library
+is built. This situation arises with third party suppliers, who may want
+to distribute a library in binary form where the user is not expected to be
+able to recompile the library. The simplest option in this case is to provide
+a project file slightly different from the one used to build the library, by
+using the @code{externally_built} attribute. For instance, the project
+file used to build the library in the previous section can be changed into the
+following one when the library is installed:
 
-Upon each dereference, a check is made that the access value denotes a
-properly allocated memory location. Here is a complete example of use of
-@code{Debug_Pools}, that includes typical instances of  memory corruption:
-@smallexample @c ada
-@iftex
-@leftskip=0cm
-@end iftex
-with Gnat.Io; use Gnat.Io;
-with Unchecked_Deallocation;
-with Unchecked_Conversion;
-with GNAT.Debug_Pools;
-with System.Storage_Elements;
-with Ada.Exceptions; use Ada.Exceptions;
-procedure Debug_Pool_Test is
-
-   type T is access Integer;
-   type U is access all T;
+@smallexample @c projectfile
+project My_Lib is
+   for Source_Dirs use ("src1", "src2");
+   for Library_Name use "mylib";
+   for Library_Dir use "lib";
+   for Library_Kind use "dynamic";
+   for Externally_Built use "true";
+end My_lib;
+@end smallexample
+
+@noindent
+This project file assumes that the directories @file{src1},
+@file{src2}, and @file{lib} exist in
+the directory containing the project file. The @code{externally_built}
+attribute makes it clear to the GNAT builder that it should not attempt to
+recompile any of the units from this library. It allows the library provider to
+restrict the source set to the minimum necessary for clients to make use of the
+library as described in the first section of this chapter. It is the
+responsibility of the library provider to install the necessary sources, ALI
+files and libraries in the directories mentioned in the project file. For
+convenience, the user's library project file should be installed in a location
+that will be searched automatically by the GNAT
+builder. These are the directories referenced in the @env{ADA_PROJECT_PATH}
+environment variable (@pxref{Importing Projects}), and also the default GNAT
+library location that can be queried with @command{gnatls -v} and is usually of
+the form $gnat_install_root/lib/gnat.
+
+When project files are not an option, it is also possible, but not recommended,
+to install the library so that the sources needed to use the library are on the
+Ada source path and the ALI files & libraries be on the Ada Object path (see
+@ref{Search Paths and the Run-Time Library (RTL)}. Alternatively, the system
+administrator can place general-purpose libraries in the default compiler
+paths, by specifying the libraries' location in the configuration files
+@file{ada_source_path} and @file{ada_object_path}. These configuration files
+must be located in the GNAT installation tree at the same place as the gcc spec
+file. The location of the gcc spec file can be determined as follows:
+@smallexample
+$ gcc -v
+@end smallexample
 
-   P : GNAT.Debug_Pools.Debug_Pool;
-   for T'Storage_Pool use P;
+@noindent
+The configuration files mentioned above have a simple format: each line
+must contain one unique directory name.
+Those names are added to the corresponding path
+in their order of appearance in the file. The names can be either absolute
+or relative; in the latter case, they are relative to where theses files
+are located.
 
-   procedure Free is new Unchecked_Deallocation (Integer, T);
-   function UC is new Unchecked_Conversion (U, T);
-   A, B : aliased T;
+The files @file{ada_source_path} and @file{ada_object_path} might not be
+present in a
+GNAT installation, in which case, GNAT will look for its run-time library in
+the directories @file{adainclude} (for the sources) and @file{adalib} (for the
+objects and @file{ALI} files). When the files exist, the compiler does not
+look in @file{adainclude} and @file{adalib}, and thus the
+@file{ada_source_path} file
+must contain the location for the GNAT run-time sources (which can simply
+be @file{adainclude}). In the same way, the @file{ada_object_path} file must
+contain the location for the GNAT run-time objects (which can simply
+be @file{adalib}).
 
-   procedure Info is new GNAT.Debug_Pools.Print_Info(Put_Line);
+You can also specify a new default path to the run-time library at compilation
+time with the switch @option{--RTS=rts-path}. You can thus choose / change
+the run-time library you want your program to be compiled with. This switch is
+recognized by @command{gcc}, @command{gnatmake}, @command{gnatbind},
+@command{gnatls}, @command{gnatfind} and @command{gnatxref}.
 
-begin
-   Info (P);
-   A := new Integer;
-   B := new Integer;
-   B := A;
-   Info (P);
-   Free (A);
-   begin
-      Put_Line (Integer'Image(B.all));
-   exception
-      when E : others => Put_Line ("raised: " & Exception_Name (E));
-   end;
-   begin
-      Free (B);
-   exception
-      when E : others => Put_Line ("raised: " & Exception_Name (E));
-   end;
-   B := UC(A'Access);
-   begin
-      Put_Line (Integer'Image(B.all));
-   exception
-      when E : others => Put_Line ("raised: " & Exception_Name (E));
-   end;
-   begin
-      Free (B);
-   exception
-      when E : others => Put_Line ("raised: " & Exception_Name (E));
-   end;
-   Info (P);
-end Debug_Pool_Test;
-@end smallexample
+It is possible to install a library before or after the standard GNAT
+library, by reordering the lines in the configuration files. In general, a
+library must be installed before the GNAT library if it redefines
+any part of it.
 
-@noindent
-The debug pool mechanism provides the following precise diagnostics on the
-execution of this erroneous program:
-@smallexample
-Debug Pool info:
-  Total allocated bytes :  0
-  Total deallocated bytes :  0
-  Current Water Mark:  0
-  High Water Mark:  0
+@node Using a library
+@subsection Using a library
 
-Debug Pool info:
-  Total allocated bytes :  8
-  Total deallocated bytes :  0
-  Current Water Mark:  8
-  High Water Mark:  8
+@noindent Once again, the project facility greatly simplifies the use of
+libraries. In this context, using a library is just a matter of adding a
+@code{with} clause in the user project. For instance, to make use of the
+library @code{My_Lib} shown in examples in earlier sections, you can
+write:
 
-raised: GNAT.DEBUG_POOLS.ACCESSING_DEALLOCATED_STORAGE
-raised: GNAT.DEBUG_POOLS.FREEING_DEALLOCATED_STORAGE
-raised: GNAT.DEBUG_POOLS.ACCESSING_NOT_ALLOCATED_STORAGE
-raised: GNAT.DEBUG_POOLS.FREEING_NOT_ALLOCATED_STORAGE
-Debug Pool info:
-  Total allocated bytes :  8
-  Total deallocated bytes :  4
-  Current Water Mark:  4
-  High Water Mark:  8
+@smallexample @c projectfile
+with "my_lib";
+project My_Proj is
+  @dots{}
+end My_Proj;
 @end smallexample
 
+Even if you have a third-party, non-Ada library, you can still use GNAT's
+Project Manager facility to provide a wrapper for it. For example, the
+following project, when @code{with}ed by your main project, will link with the
+third-party library @file{liba.a}:
 
-@node Creating Sample Bodies Using gnatstub
-@chapter Creating Sample Bodies Using @command{gnatstub}
-@findex gnatstub
+@smallexample @c projectfile
+@group
+project Liba is
+   for Externally_Built use "true";
+   for Source_Files use ();
+   for Library_Dir use "lib";
+   for Library_Name use "a";
+   for Library_Kind use "static";
+end Liba;
+@end group
+@end smallexample
+This is an alternative to the use of @code{pragma Linker_Options}. It is
+especially interesting in the context of systems with several interdependent
+static libraries where finding a proper linker order is not easy and best be
+left to the tools having visibility over project dependence information.
 
 @noindent
-@command{gnatstub} creates body stubs, that is, empty but compilable bodies
-for library unit declarations.
-
-To create a body stub, @command{gnatstub} has to compile the library
-unit declaration. Therefore, bodies can be created only for legal
-library units. Moreover, if a library unit depends semantically upon
-units located outside the current directory, you have to provide
-the source search path when calling @command{gnatstub}, see the description
-of @command{gnatstub} switches below.
+In order to use an Ada library manually, you need to make sure that this
+library is on both your source and object path
+(see @ref{Search Paths and the Run-Time Library (RTL)}
+and @ref{Search Paths for gnatbind}). Furthermore, when the objects are grouped
+in an archive or a shared library, you need to specify the desired
+library at link time.
 
-@menu
-* Running gnatstub::
-* Switches for gnatstub::
-@end menu
+For example, you can use the library @file{mylib} installed in
+@file{/dir/my_lib_src} and @file{/dir/my_lib_obj} with the following commands:
 
-@node Running gnatstub
-@section Running @command{gnatstub}
+@smallexample
+$ gnatmake -aI/dir/my_lib_src -aO/dir/my_lib_obj my_appl \
+  -largs -lmy_lib
+@end smallexample
 
 @noindent
-@command{gnatstub} has the command-line interface of the form
-
+This can be expressed more simply:
 @smallexample
-$ gnatstub [switches] filename [directory]
+$ gnatmake my_appl
 @end smallexample
-
 @noindent
-where
-@table @emph
-@item filename
-is the name of the source file that contains a library unit declaration
-for which a body must be created. The file name may contain the path
-information.
-The file name does not have to follow the GNAT file name conventions. If the
-name
-does not follow GNAT file naming conventions, the name of the body file must
-be provided
-explicitly as the value of the @option{^-o^/BODY=^@var{body-name}} option.
-If the file name follows the GNAT file naming
-conventions and the name of the body file is not provided,
-@command{gnatstub}
-creates the name
-of the body file from the argument file name by replacing the @file{.ads}
-suffix
-with the @file{.adb} suffix.
-
-@item directory
-indicates the directory in which the body stub is to be placed (the default
-is the
-current directory)
+when the following conditions are met:
+@itemize @bullet
+@item
+@file{/dir/my_lib_src} has been added by the user to the environment
+variable @env{ADA_INCLUDE_PATH}, or by the administrator to the file
+@file{ada_source_path}
+@item
+@file{/dir/my_lib_obj} has been added by the user to the environment
+variable @env{ADA_OBJECTS_PATH}, or by the administrator to the file
+@file{ada_object_path}
+@item
+a pragma @code{Linker_Options} has been added to one of the sources.
+For example:
 
-@item switches
-is an optional sequence of switches as described in the next section
-@end table
+@smallexample @c ada
+pragma Linker_Options ("-lmy_lib");
+@end smallexample
+@end itemize
 
-@node Switches for gnatstub
-@section Switches for @command{gnatstub}
+@node Stand-alone Ada Libraries
+@section Stand-alone Ada Libraries
+@cindex Stand-alone library, building, using
 
-@table @option
-@c !sort!
+@menu
+* Introduction to Stand-alone Libraries::
+* Building a Stand-alone Library::
+* Creating a Stand-alone Library to be used in a non-Ada context::
+* Restrictions in Stand-alone Libraries::
+@end menu
 
-@item ^-f^/FULL^
-@cindex @option{^-f^/FULL^} (@command{gnatstub})
-If the destination directory already contains a file with the name of the
-body file
-for the argument spec file, replace it with the generated body stub.
+@node Introduction to Stand-alone Libraries
+@subsection Introduction to Stand-alone Libraries
+
+@noindent
+A Stand-alone Library (abbreviated ``SAL'') is a library that contains the
+necessary code to
+elaborate the Ada units that are included in the library. In contrast with
+an ordinary library, which consists of all sources, objects and @file{ALI}
+files of the
+library, a SAL may specify a restricted subset of compilation units
+to serve as a library interface. In this case, the fully
+self-sufficient set of files will normally consist of an objects
+archive, the sources of interface units' specs, and the @file{ALI}
+files of interface units.
+If an interface spec contains a generic unit or an inlined subprogram,
+the body's
+source must also be provided; if the units that must be provided in the source
+form depend on other units, the source and @file{ALI} files of those must
+also be provided.
 
-@item ^-hs^/HEADER=SPEC^
-@cindex @option{^-hs^/HEADER=SPEC^} (@command{gnatstub})
-Put the comment header (i.e., all the comments preceding the
-compilation unit) from the source of the library unit declaration
-into the body stub.
+The main purpose of a SAL is to minimize the recompilation overhead of client
+applications when a new version of the library is installed. Specifically,
+if the interface sources have not changed, client applications do not need to
+be recompiled. If, furthermore, a SAL is provided in the shared form and its
+version, controlled by @code{Library_Version} attribute, is not changed,
+then the clients do not need to be relinked.
 
-@item ^-hg^/HEADER=GENERAL^
-@cindex @option{^-hg^/HEADER=GENERAL^} (@command{gnatstub})
-Put a sample comment header into the body stub.
+SALs also allow the library providers to minimize the amount of library source
+text exposed to the clients.  Such ``information hiding'' might be useful or
+necessary for various reasons.
 
-@ifclear vms
-@item -IDIR
-@cindex @option{-IDIR} (@command{gnatstub})
-@itemx -I-
-@cindex @option{-I-} (@command{gnatstub})
-@end ifclear
-@ifset vms
-@item /NOCURRENT_DIRECTORY
-@cindex @option{/NOCURRENT_DIRECTORY} (@command{gnatstub})
-@end ifset
-^These switches have ^This switch has^ the same meaning as in calls to
-@command{gcc}.
-^They define ^It defines ^ the source search path in the call to
-@command{gcc} issued
-by @command{gnatstub} to compile an argument source file.
+Stand-alone libraries are also well suited to be used in an executable whose
+main routine is not written in Ada.
 
-@item ^-gnatec^/CONFIGURATION_PRAGMAS_FILE=^@var{PATH}
-@cindex @option{^-gnatec^/CONFIGURATION_PRAGMAS_FILE^} (@command{gnatstub})
-This switch has the same meaning as in calls to @command{gcc}.
-It defines the additional configuration file to be passed to the call to
-@command{gcc} issued
-by @command{gnatstub} to compile an argument source file.
+@node Building a Stand-alone Library
+@subsection Building a Stand-alone Library
 
-@item ^-gnatyM^/MAX_LINE_LENGTH=^@var{n}
-@cindex @option{^-gnatyM^/MAX_LINE_LENGTH^} (@command{gnatstub})
-(@var{n} is a non-negative integer). Set the maximum line length in the
-body stub to @var{n}; the default is 79. The maximum value that can be
-specified is 32767. Note that in the special case of configuration
-pragma files, the maximum is always 32767 regardless of whether or
-not this switch appears.
+@noindent
+GNAT's Project facility provides a simple way of building and installing
+stand-alone libraries; see @ref{Stand-alone Library Projects}.
+To be a Stand-alone Library Project, in addition to the two attributes
+that make a project a Library Project (@code{Library_Name} and
+@code{Library_Dir}; see @ref{Library Projects}), the attribute
+@code{Library_Interface} must be defined.  For example:
 
-@item ^-gnaty^/STYLE_CHECKS=^@var{n}
-@cindex @option{^-gnaty^/STYLE_CHECKS=^} (@command{gnatstub})
-(@var{n} is a non-negative integer from 1 to 9). Set the indentation level in
-the generated body sample to @var{n}.
-The default indentation is 3.
+@smallexample @c projectfile
+@group
+   for Library_Dir use "lib_dir";
+   for Library_Name use "dummy";
+   for Library_Interface use ("int1", "int1.child");
+@end group
+@end smallexample
 
-@item ^-gnatyo^/ORDERED_SUBPROGRAMS^
-@cindex @option{^-gnato^/ORDERED_SUBPROGRAMS^} (@command{gnatstub})
-Order local bodies alphabetically. (By default local bodies are ordered
-in the same way as the corresponding local specs in the argument spec file.)
+@noindent
+Attribute @code{Library_Interface} has a non-empty string list value,
+each string in the list designating a unit contained in an immediate source
+of the project file.
 
-@item ^-i^/INDENTATION=^@var{n}
-@cindex @option{^-i^/INDENTATION^} (@command{gnatstub})
-Same as @option{^-gnaty^/STYLE_CHECKS=^@var{n}}
+When a Stand-alone Library is built, first the binder is invoked to build
+a package whose name depends on the library name
+(@file{^b~dummy.ads/b^B$DUMMY.ADS/B^} in the example above).
+This binder-generated package includes initialization and
+finalization procedures whose
+names depend on the library name (@code{dummyinit} and @code{dummyfinal}
+in the example
+above). The object corresponding to this package is included in the library.
 
-@item ^-k^/TREE_FILE=SAVE^
-@cindex @option{^-k^/TREE_FILE=SAVE^} (@command{gnatstub})
-Do not remove the tree file (i.e., the snapshot of the compiler internal
-structures used by @command{gnatstub}) after creating the body stub.
+You must ensure timely (e.g., prior to any use of interfaces in the SAL)
+calling of these procedures if a static SAL is built, or if a shared SAL
+is built
+with the project-level attribute @code{Library_Auto_Init} set to
+@code{"false"}.
 
-@item ^-l^/LINE_LENGTH=^@var{n}
-@cindex @option{^-l^/LINE_LENGTH^} (@command{gnatstub})
-Same as @option{^-gnatyM^/MAX_LINE_LENGTH=^@var{n}}
+For a Stand-Alone Library, only the @file{ALI} files of the Interface Units
+(those that are listed in attribute @code{Library_Interface}) are copied to
+the Library Directory. As a consequence, only the Interface Units may be
+imported from Ada units outside of the library. If other units are imported,
+the binding phase will fail.
 
-@item ^-o^/BODY=^@var{body-name}
-@cindex @option{^-o^/BODY^} (@command{gnatstub})
-Body file name.  This should be set if the argument file name does not
-follow
-the GNAT file naming
-conventions. If this switch is omitted the default name for the body will be
-obtained
-from the argument file name according to the GNAT file naming conventions.
+The attribute @code{Library_Src_Dir} may be specified for a
+Stand-Alone Library. @code{Library_Src_Dir} is a simple attribute that has a
+single string value. Its value must be the path (absolute or relative to the
+project directory) of an existing directory. This directory cannot be the
+object directory or one of the source directories, but it can be the same as
+the library directory. The sources of the Interface
+Units of the library that are needed by an Ada client of the library will be
+copied to the designated directory, called the Interface Copy directory.
+These sources include the specs of the Interface Units, but they may also
+include bodies and subunits, when pragmas @code{Inline} or @code{Inline_Always}
+are used, or when there is a generic unit in the spec. Before the sources
+are copied to the Interface Copy directory, an attempt is made to delete all
+files in the Interface Copy directory.
 
-@item ^-q^/QUIET^
-@cindex @option{^-q^/QUIET^} (@command{gnatstub})
-Quiet mode: do not generate a confirmation when a body is
-successfully created, and do not generate a message when a body is not
-required for an
-argument unit.
+Building stand-alone libraries by hand is somewhat tedious, but for those
+occasions when it is necessary here are the steps that you need to perform:
+@itemize @bullet
+@item
+Compile all library sources.
 
-@item ^-r^/TREE_FILE=REUSE^
-@cindex @option{^-r^/TREE_FILE=REUSE^} (@command{gnatstub})
-Reuse the tree file (if it exists) instead of creating it.  Instead of
-creating the tree file for the library unit declaration, @command{gnatstub}
-tries to find it in the current directory and use it for creating
-a body. If the tree file is not found, no body is created. This option
-also implies @option{^-k^/SAVE^}, whether or not
-the latter is set explicitly.
+@item
+Invoke the binder with the switch @option{-n} (No Ada main program),
+with all the @file{ALI} files of the interfaces, and
+with the switch @option{-L} to give specific names to the @code{init}
+and @code{final} procedures.  For example:
+@smallexample
+  gnatbind -n int1.ali int2.ali -Lsal1
+@end smallexample
 
-@item ^-t^/TREE_FILE=OVERWRITE^
-@cindex @option{^-t^/TREE_FILE=OVERWRITE^} (@command{gnatstub})
-Overwrite the existing tree file.  If the current directory already
-contains the file which, according to the GNAT file naming rules should
-be considered as a tree file for the argument source file,
-@command{gnatstub}
-will refuse to create the tree file needed to create a sample body
-unless this option is set.
+@item
+Compile the binder generated file:
+@smallexample
+  gcc -c b~int2.adb
+@end smallexample
 
-@item ^-v^/VERBOSE^
-@cindex @option{^-v^/VERBOSE^} (@command{gnatstub})
-Verbose mode: generate version information.
+@item
+Link the dynamic library with all the necessary object files,
+indicating to the linker the names of the @code{init} (and possibly
+@code{final}) procedures for automatic initialization (and finalization).
+The built library should be placed in a directory different from
+the object directory.
 
-@end table
+@item
+Copy the @code{ALI} files of the interface to the library directory,
+add in this copy an indication that it is an interface to a SAL
+(i.e. add a word @option{SL} on the line in the @file{ALI} file that starts
+with letter ``P'') and make the modified copy of the @file{ALI} file
+read-only.
+@end itemize
 
+@noindent
+Using SALs is not different from using other libraries
+(see @ref{Using a library}).
 
-@node Other Utility Programs
-@chapter Other Utility Programs
+@node Creating a Stand-alone Library to be used in a non-Ada context
+@subsection Creating a Stand-alone Library to be used in a non-Ada context
 
 @noindent
-This chapter discusses some other utility programs available in the Ada
-environment.
+It is easy to adapt the SAL build procedure discussed above for use of a SAL in
+a non-Ada context.
 
-@menu
-* Using Other Utility Programs with GNAT::
-* The External Symbol Naming Scheme of GNAT::
-@ifclear vms
-* Ada Mode for Glide::
-@end ifclear
-* Converting Ada Files to html with gnathtml::
-* Installing gnathtml::
-@ifset vms
-* LSE::
-* Profiling::
-@end ifset
-@end menu
+The only extra step required is to ensure that library interface subprograms
+are compatible with the main program, by means of @code{pragma Export}
+or @code{pragma Convention}.
 
-@node Using Other Utility Programs with GNAT
-@section Using Other Utility Programs with GNAT
+Here is an example of simple library interface for use with C main program:
 
-@noindent
-The object files generated by GNAT are in standard system format and in
-particular the debugging information uses this format. This means
-programs generated by GNAT can be used with existing utilities that
-depend on these formats.
+@smallexample @c ada
+package Interface is
 
-@ifclear vms
-In general, any utility program that works with C will also often work with
-Ada programs generated by GNAT. This includes software utilities such as
-gprof (a profiling program), @code{gdb} (the FSF debugger), and utilities such
-as Purify.
-@end ifclear
+   procedure Do_Something;
+   pragma Export (C, Do_Something, "do_something");
 
-@node The External Symbol Naming Scheme of GNAT
-@section The External Symbol Naming Scheme of GNAT
+   procedure Do_Something_Else;
+   pragma Export (C, Do_Something_Else, "do_something_else");
+
+end Interface;
+@end smallexample
 
 @noindent
-In order to interpret the output from GNAT, when using tools that are
-originally intended for use with other languages, it is useful to
-understand the conventions used to generate link names from the Ada
-entity names.
+On the foreign language side, you must provide a ``foreign'' view of the
+library interface; remember that it should contain elaboration routines in
+addition to interface subprograms.
 
-All link names are in all lowercase letters. With the exception of library
-procedure names, the mechanism used is simply to use the full expanded
-Ada name with dots replaced by double underscores. For example, suppose
-we have the following package spec:
+The example below shows the content of @code{mylib_interface.h} (note
+that there is no rule for the naming of this file, any name can be used)
+@smallexample
+/* the library elaboration procedure */
+extern void mylibinit (void);
 
-@smallexample @c ada
-@group
-@cartouche
-package QRS is
-   MN : Integer;
-end QRS;
-@end cartouche
-@end group
+/* the library finalization procedure */
+extern void mylibfinal (void);
+
+/* the interface exported by the library */
+extern void do_something (void);
+extern void do_something_else (void);
 @end smallexample
 
 @noindent
-The variable @code{MN} has a full expanded Ada name of @code{QRS.MN}, so
-the corresponding link name is @code{qrs__mn}.
-@findex Export
-Of course if a @code{pragma Export} is used this may be overridden:
+Libraries built as explained above can be used from any program, provided
+that the elaboration procedures (named @code{mylibinit} in the previous
+example) are called before the library services are used. Any number of
+libraries can be used simultaneously, as long as the elaboration
+procedure of each library is called.
 
-@smallexample @c ada
-@group
-@cartouche
-package Exports is
-   Var1 : Integer;
-   pragma Export (Var1, C, External_Name => "var1_name");
-   Var2 : Integer;
-   pragma Export (Var2, C, Link_Name => "var2_link_name");
-end Exports;
-@end cartouche
-@end group
-@end smallexample
+Below is an example of a C program that uses the @code{mylib} library.
 
-@noindent
-In this case, the link name for @var{Var1} is whatever link name the
-C compiler would assign for the C function @var{var1_name}. This typically
-would be either @var{var1_name} or @var{_var1_name}, depending on operating
-system conventions, but other possibilities exist. The link name for
-@var{Var2} is @var{var2_link_name}, and this is not operating system
-dependent.
+@smallexample
+#include "mylib_interface.h"
 
-@findex _main
-One exception occurs for library level procedures. A potential ambiguity
-arises between the required name @code{_main} for the C main program,
-and the name we would otherwise assign to an Ada library level procedure
-called @code{Main} (which might well not be the main program).
+int
+main (void)
+@{
+   /* First, elaborate the library before using it */
+   mylibinit ();
 
-To avoid this ambiguity, we attach the prefix @code{_ada_} to such
-names. So if we have a library level procedure such as
+   /* Main program, using the library exported entities */
+   do_something ();
+   do_something_else ();
 
-@smallexample @c ada
-@group
-@cartouche
-procedure Hello (S : String);
-@end cartouche
-@end group
+   /* Library finalization at the end of the program */
+   mylibfinal ();
+   return 0;
+@}
 @end smallexample
 
 @noindent
-the external name of this procedure will be @var{_ada_hello}.
+Note that invoking any library finalization procedure generated by
+@code{gnatbind} shuts down the Ada run-time environment.
+Consequently, the
+finalization of all Ada libraries must be performed at the end of the program.
+No call to these libraries or to the Ada run-time library should be made
+after the finalization phase.
 
-@ifclear vms
-@node Ada Mode for Glide
-@section Ada Mode for @code{Glide}
-@cindex Ada mode (for Glide)
+@node Restrictions in Stand-alone Libraries
+@subsection Restrictions in Stand-alone Libraries
 
 @noindent
-The Glide mode for programming in Ada (both Ada83 and Ada95) helps the
-user to understand and navigate existing code, and facilitates writing
-new code. It furthermore provides some utility functions for easier
-integration of standard Emacs features when programming in Ada.
-
-Its general features include:
-
-@itemize @bullet
-@item
-An Integrated Development Environment with functionality such as the
-following
-
+The pragmas listed below should be used with caution inside libraries,
+as they can create incompatibilities with other Ada libraries:
 @itemize @bullet
-@item
-``Project files'' for configuration-specific aspects
-(e.g. directories and compilation options)
-
-@item
-Compiling and stepping through error messages.
-
-@item
-Running and debugging an applications within Glide.
+@item pragma @code{Locking_Policy}
+@item pragma @code{Queuing_Policy}
+@item pragma @code{Task_Dispatching_Policy}
+@item pragma @code{Unreserve_All_Interrupts}
 @end itemize
 
-@item
-Pull-down menus
+@noindent
+When using a library that contains such pragmas, the user must make sure
+that all libraries use the same pragmas with the same values. Otherwise,
+@code{Program_Error} will
+be raised during the elaboration of the conflicting
+libraries. The usage of these pragmas and its consequences for the user
+should therefore be well documented.
 
-@item
-User configurability
-@end itemize
+Similarly, the traceback in the exception occurrence mechanism should be
+enabled or disabled in a consistent manner across all libraries.
+Otherwise, Program_Error will be raised during the elaboration of the
+conflicting libraries.
 
-Some of the specific Ada mode features are:
+If the @code{Version} or @code{Body_Version}
+attributes are used inside a library, then you need to
+perform a @code{gnatbind} step that specifies all @file{ALI} files in all
+libraries, so that version identifiers can be properly computed.
+In practice these attributes are rarely used, so this is unlikely
+to be a consideration.
 
-@itemize @bullet
-@item
-Functions for easy and quick stepping through Ada code
+@node  Rebuilding the GNAT Run-Time Library
+@section Rebuilding the GNAT Run-Time Library
+@cindex GNAT Run-Time Library, rebuilding
+@cindex Building the GNAT Run-Time Library
+@cindex Rebuilding the GNAT Run-Time Library
+@cindex Run-Time Library, rebuilding
 
-@item
-Getting cross reference information for identifiers (e.g., finding a
-defining occurrence)
+@noindent
+It may be useful to recompile the GNAT library in various contexts, the
+most important one being the use of partition-wide configuration pragmas
+such as @code{Normalize_Scalars}. A special Makefile called
+@code{Makefile.adalib} is provided to that effect and can be found in
+the directory containing the GNAT library. The location of this
+directory depends on the way the GNAT environment has been installed and can
+be determined by means of the command:
 
-@item
-Displaying an index menu of types and subprograms, allowing
-direct selection for browsing
+@smallexample
+$ gnatls -v
+@end smallexample
 
-@item
-Automatic color highlighting of the various Ada entities
-@end itemize
+@noindent
+The last entry in the object search path usually contains the
+gnat library. This Makefile contains its own documentation and in
+particular the set of instructions needed to rebuild a new library and
+to use it.
 
-Glide directly supports writing Ada code, via several facilities:
+@node Using the GNU make Utility
+@chapter Using the GNU @code{make} Utility
+@findex make
 
-@itemize @bullet
-@item
-Switching between spec and body files with possible
-autogeneration of body files
-
-@item
-Automatic formating of subprogram parameter lists
+@noindent
+This chapter offers some examples of makefiles that solve specific
+problems. It does not explain how to write a makefile (see the GNU make
+documentation), nor does it try to replace the @command{gnatmake} utility
+(@pxref{The GNAT Make Program gnatmake}).
 
-@item
-Automatic indentation according to Ada syntax
+All the examples in this section are specific to the GNU version of
+make. Although @command{make} is a standard utility, and the basic language
+is the same, these examples use some advanced features found only in
+@code{GNU make}.
 
-@item
-Automatic completion of identifiers
+@menu
+* Using gnatmake in a Makefile::
+* Automatically Creating a List of Directories::
+* Generating the Command Line Switches::
+* Overcoming Command Line Length Limits::
+@end menu
 
-@item
-Automatic (and configurable) casing of identifiers, keywords, and attributes
+@node Using gnatmake in a Makefile
+@section Using gnatmake in a Makefile
+@findex makefile
+@cindex GNU make
 
-@item
-Insertion of syntactic templates
+@noindent
+Complex project organizations can be handled in a very powerful way by
+using GNU make combined with gnatmake. For instance, here is a Makefile
+which allows you to build each subsystem of a big project into a separate
+shared library. Such a makefile allows you to significantly reduce the link
+time of very big applications while maintaining full coherence at
+each step of the build process.
 
-@item
-Block commenting / uncommenting
-@end itemize
+The list of dependencies are handled automatically by
+@command{gnatmake}. The Makefile is simply used to call gnatmake in each of
+the appropriate directories.
 
-@noindent
-For more information, please refer to the online documentation
-available in the @code{Glide} @result{} @code{Help} menu.
-@end ifclear
+Note that you should also read the example on how to automatically
+create the list of directories
+(@pxref{Automatically Creating a List of Directories})
+which might help you in case your project has a lot of subdirectories.
 
+@smallexample
+@iftex
+@leftskip=0cm
+@font@heightrm=cmr8
+@heightrm
+@end iftex
+## This Makefile is intended to be used with the following directory
+## configuration:
+##  - The sources are split into a series of csc (computer software components)
+##    Each of these csc is put in its own directory.
+##    Their name are referenced by the directory names.
+##    They will be compiled into shared library (although this would also work
+##    with static libraries
+##  - The main program (and possibly other packages that do not belong to any
+##    csc is put in the top level directory (where the Makefile is).
+##       toplevel_dir __ first_csc  (sources) __ lib (will contain the library)
+##                    \_ second_csc (sources) __ lib (will contain the library)
+##                    \_ @dots{}
+## Although this Makefile is build for shared library, it is easy to modify
+## to build partial link objects instead (modify the lines with -shared and
+## gnatlink below)
+##
+## With this makefile, you can change any file in the system or add any new
+## file, and everything will be recompiled correctly (only the relevant shared
+## objects will be recompiled, and the main program will be re-linked).
 
-@node Converting Ada Files to html with gnathtml
-@section Converting Ada Files to HTML with @code{gnathtml}
+# The list of computer software component for your project. This might be
+# generated automatically.
+CSC_LIST=aa bb cc
 
-@noindent
-This @code{Perl} script allows Ada source files to be browsed using
-standard Web browsers. For installation procedure, see the section
-@xref{Installing gnathtml}.
+# Name of the main program (no extension)
+MAIN=main
 
-Ada reserved keywords are highlighted in a bold font and Ada comments in
-a blue font. Unless your program was compiled with the gcc @option{-gnatx}
-switch to suppress the generation of cross-referencing information, user
-defined variables and types will appear in a different color; you will
-be able to click on any identifier and go to its declaration.
+# If we need to build objects with -fPIC, uncomment the following line
+#NEED_FPIC=-fPIC
 
-The command line is as follow:
-@smallexample
-$ perl gnathtml.pl [switches] ada-files
-@end smallexample
+# The following variable should give the directory containing libgnat.so
+# You can get this directory through 'gnatls -v'. This is usually the last
+# directory in the Object_Path.
+GLIB=@dots{}
 
-@noindent
-You can pass it as many Ada files as you want. @code{gnathtml} will generate
-an html file for every ada file, and a global file called @file{index.htm}.
-This file is an index of every identifier defined in the files.
+# The directories for the libraries
+# (This macro expands the list of CSC to the list of shared libraries, you
+# could simply use the expanded form:
+# LIB_DIR=aa/lib/libaa.so bb/lib/libbb.so cc/lib/libcc.so
+LIB_DIR=$@{foreach dir,$@{CSC_LIST@},$@{dir@}/lib/lib$@{dir@}.so@}
 
-The available switches are the following ones :
+$@{MAIN@}: objects $@{LIB_DIR@}
+    gnatbind $@{MAIN@} $@{CSC_LIST:%=-aO%/lib@} -shared
+    gnatlink $@{MAIN@} $@{CSC_LIST:%=-l%@}
 
-@table @option
-@item -83
-@cindex @option{-83} (@code{gnathtml})
-Only the subset on the Ada 83 keywords will be highlighted, not the full
-Ada 95 keywords set.
+objects::
+    # recompile the sources
+    gnatmake -c -i $@{MAIN@}.adb $@{NEED_FPIC@} $@{CSC_LIST:%=-I%@}
 
-@item -cc @var{color}
-@cindex @option{-cc} (@code{gnathtml})
-This option allows you to change the color used for comments. The default
-value is green. The color argument can be any name accepted by html.
+# Note: In a future version of GNAT, the following commands will be simplified
+# by a new tool, gnatmlib
+$@{LIB_DIR@}:
+    mkdir -p $@{dir $@@ @}
+    cd $@{dir $@@ @} && gcc -shared -o $@{notdir $@@ @} ../*.o -L$@{GLIB@} -lgnat
+    cd $@{dir $@@ @} && cp -f ../*.ali .
 
-@item -d
-@cindex @option{-d} (@code{gnathtml})
-If the ada files depend on some other files (using for instance the
-@code{with} command, the latter will also be converted to html.
-Only the files in the user project will be converted to html, not the files
-in the run-time library itself.
+# The dependencies for the modules
+# Note that we have to force the expansion of *.o, since in some cases
+# make won't be able to do it itself.
+aa/lib/libaa.so: $@{wildcard aa/*.o@}
+bb/lib/libbb.so: $@{wildcard bb/*.o@}
+cc/lib/libcc.so: $@{wildcard cc/*.o@}
 
-@item -D
-@cindex @option{-D} (@code{gnathtml})
-This command is the same as @option{-d} above, but @command{gnathtml} will
-also look for files in the run-time library, and generate html files for them.
+# Make sure all of the shared libraries are in the path before starting the
+# program
+run::
+    LD_LIBRARY_PATH=`pwd`/aa/lib:`pwd`/bb/lib:`pwd`/cc/lib ./$@{MAIN@}
 
-@item -ext @var{extension}
-@cindex @option{-ext} (@code{gnathtml})
-This option allows you to change the extension of the generated HTML files.
-If you do not specify an extension, it will default to @file{htm}.
+clean::
+    $@{RM@} -rf $@{CSC_LIST:%=%/lib@}
+    $@{RM@} $@{CSC_LIST:%=%/*.ali@}
+    $@{RM@} $@{CSC_LIST:%=%/*.o@}
+    $@{RM@} *.o *.ali $@{MAIN@}
+@end smallexample
 
-@item -f
-@cindex @option{-f} (@code{gnathtml})
-By default, gnathtml will generate html links only for global entities
-('with'ed units, global variables and types,...). If you specify the
-@option{-f} on the command line, then links will be generated for local
-entities too.
+@node Automatically Creating a List of Directories
+@section Automatically Creating a List of Directories
 
-@item -l @var{number}
-@cindex @option{-l} (@code{gnathtml})
-If this switch is provided and @var{number} is not 0, then @code{gnathtml}
-will number the html files every @var{number} line.
+@noindent
+In most makefiles, you will have to specify a list of directories, and
+store it in a variable. For small projects, it is often easier to
+specify each of them by hand, since you then have full control over what
+is the proper order for these directories, which ones should be
+included.
 
-@item -I @var{dir}
-@cindex @option{-I} (@code{gnathtml})
-Specify a directory to search for library files (@file{.ALI} files) and
-source files. You can provide several -I switches on the command line,
-and the directories will be parsed in the order of the command line.
+However, in larger projects, which might involve hundreds of
+subdirectories, it might be more convenient to generate this list
+automatically.
 
-@item -o @var{dir}
-@cindex @option{-o} (@code{gnathtml})
-Specify the output directory for html files. By default, gnathtml will
-saved the generated html files in a subdirectory named @file{html/}.
+The example below presents two methods. The first one, although less
+general, gives you more control over the list. It involves wildcard
+characters, that are automatically expanded by @command{make}. Its
+shortcoming is that you need to explicitly specify some of the
+organization of your project, such as for instance the directory tree
+depth, whether some directories are found in a separate tree, @enddots{}
 
-@item -p @var{file}
-@cindex @option{-p} (@code{gnathtml})
-If you are using Emacs and the most recent Emacs Ada mode, which provides
-a full Integrated Development Environment for compiling, checking,
-running and debugging applications, you may use @file{.gpr} files
-to give the directories where Emacs can find sources and object files.
+The second method is the most general one. It requires an external
+program, called @command{find}, which is standard on all Unix systems. All
+the directories found under a given root directory will be added to the
+list.
 
-Using this switch, you can tell gnathtml to use these files. This allows
-you to get an html version of your application, even if it is spread
-over multiple directories.
+@smallexample
+@iftex
+@leftskip=0cm
+@font@heightrm=cmr8
+@heightrm
+@end iftex
+# The examples below are based on the following directory hierarchy:
+# All the directories can contain any number of files
+# ROOT_DIRECTORY ->  a  ->  aa  ->  aaa
+#                       ->  ab
+#                       ->  ac
+#                ->  b  ->  ba  ->  baa
+#                       ->  bb
+#                       ->  bc
+# This Makefile creates a variable called DIRS, that can be reused any time
+# you need this list (see the other examples in this section)
 
-@item -sc @var{color}
-@cindex @option{-sc} (@code{gnathtml})
-This option allows you to change the color used for symbol definitions.
-The default value is red. The color argument can be any name accepted by html.
+# The root of your project's directory hierarchy
+ROOT_DIRECTORY=.
 
-@item -t @var{file}
-@cindex @option{-t} (@code{gnathtml})
-This switch provides the name of a file. This file contains a list of
-file names to be converted, and the effect is exactly as though they had
-appeared explicitly on the command line. This
-is the recommended way to work around the command line length limit on some
-systems.
+####
+# First method: specify explicitly the list of directories
+# This allows you to specify any subset of all the directories you need.
+####
 
-@end table
+DIRS := a/aa/ a/ab/ b/ba/
 
-@node Installing gnathtml
-@section Installing @code{gnathtml}
+####
+# Second method: use wildcards
+# Note that the argument(s) to wildcard below should end with a '/'.
+# Since wildcards also return file names, we have to filter them out
+# to avoid duplicate directory names.
+# We thus use make's @code{dir} and @code{sort} functions.
+# It sets DIRs to the following value (note that the directories aaa and baa
+# are not given, unless you change the arguments to wildcard).
+# DIRS= ./a/a/ ./b/ ./a/aa/ ./a/ab/ ./a/ac/ ./b/ba/ ./b/bb/ ./b/bc/
+####
 
-@noindent
-@code{Perl} needs to be installed on your machine to run this script.
-@code{Perl} is freely available for almost every architecture and
-Operating System via the Internet.
+DIRS := $@{sort $@{dir $@{wildcard $@{ROOT_DIRECTORY@}/*/
+                    $@{ROOT_DIRECTORY@}/*/*/@}@}@}
 
-On Unix systems, you  may want to modify  the  first line of  the script
-@code{gnathtml},  to explicitly  tell  the Operating  system  where Perl
-is. The syntax of this line is :
-@smallexample
-#!full_path_name_to_perl
-@end smallexample
+####
+# Third method: use an external program
+# This command is much faster if run on local disks, avoiding NFS slowdowns.
+# This is the most complete command: it sets DIRs to the following value:
+# DIRS= ./a ./a/aa ./a/aa/aaa ./a/ab ./a/ac ./b ./b/ba ./b/ba/baa ./b/bb ./b/bc
+####
 
-@noindent
-Alternatively, you may run the script using the following command line:
+DIRS := $@{shell find $@{ROOT_DIRECTORY@} -type d -print@}
 
-@smallexample
-$ perl gnathtml.pl [switches] files
 @end smallexample
 
-@ifset vms
-@node LSE
-@section LSE
-@findex LSE
+@node Generating the Command Line Switches
+@section Generating the Command Line Switches
 
 @noindent
-The GNAT distribution provides an Ada 95 template for the Digital Language
-Sensitive Editor (LSE), a component of DECset. In order to
-access it, invoke LSE with the qualifier /ENVIRONMENT=GNU:[LIB]ADA95.ENV.
-
-@node Profiling
-@section Profiling
-@findex PCA
+Once you have created the list of directories as explained in the
+previous section (@pxref{Automatically Creating a List of Directories}),
+you can easily generate the command line arguments to pass to gnatmake.
 
-@noindent
-GNAT supports The Digital Performance Coverage Analyzer (PCA), a component
-of DECset. To use it proceed as outlined under ``HELP PCA'', except for running
-the collection phase with the /DEBUG qualifier.
+For the sake of completeness, this example assumes that the source path
+is not the same as the object path, and that you have two separate lists
+of directories.
 
 @smallexample
-$ GNAT MAKE /DEBUG <PROGRAM_NAME>
-$ DEFINE LIB$DEBUG PCA$COLLECTOR
-$ RUN/DEBUG <PROGRAM_NAME>
-@end smallexample
-@noindent
-@end ifset
-
-@node Running and Debugging Ada Programs
-@chapter Running and Debugging Ada Programs
-@cindex Debugging
-
-@noindent
-This chapter discusses how to debug Ada programs. An incorrect Ada program
-may be handled in three ways by the GNAT compiler:
+# see "Automatically creating a list of directories" to create
+# these variables
+SOURCE_DIRS=
+OBJECT_DIRS=
 
-@enumerate
-@item
-The illegality may be a violation of the static semantics of Ada. In
-that case GNAT diagnoses the constructs in the program that are illegal.
-It is then a straightforward matter for the user to modify those parts of
-the program.
+GNATMAKE_SWITCHES := $@{patsubst %,-aI%,$@{SOURCE_DIRS@}@}
+GNATMAKE_SWITCHES += $@{patsubst %,-aO%,$@{OBJECT_DIRS@}@}
 
-@item
-The illegality may be a violation of the dynamic semantics of Ada. In
-that case the program compiles and executes, but may generate incorrect
-results, or may terminate abnormally with some exception.
+all:
+        gnatmake $@{GNATMAKE_SWITCHES@} main_unit
+@end smallexample
 
-@item
-When presented with a program that contains convoluted errors, GNAT
-itself may terminate abnormally without providing full diagnostics on
-the incorrect user program.
-@end enumerate
+@node Overcoming Command Line Length Limits
+@section Overcoming Command Line Length Limits
 
-@menu
-* The GNAT Debugger GDB::
-* Running GDB::
-* Introduction to GDB Commands::
-* Using Ada Expressions::
-* Calling User-Defined Subprograms::
-* Using the Next Command in a Function::
-* Ada Exceptions::
-* Ada Tasks::
-* Debugging Generic Units::
-* GNAT Abnormal Termination or Failure to Terminate::
-* Naming Conventions for GNAT Source Files::
-* Getting Internal Debugging Information::
-* Stack Traceback::
-@end menu
+@noindent
+One problem that might be encountered on big projects is that many
+operating systems limit the length of the command line. It is thus hard to give
+gnatmake the list of source and object directories.
 
-@cindex Debugger
-@findex gdb
+This example shows how you can set up environment variables, which will
+make @command{gnatmake} behave exactly as if the directories had been
+specified on the command line, but have a much higher length limit (or
+even none on most systems).
 
-@node The GNAT Debugger GDB
-@section The GNAT Debugger GDB
+It assumes that you have created a list of directories in your Makefile,
+using one of the methods presented in
+@ref{Automatically Creating a List of Directories}.
+For the sake of completeness, we assume that the object
+path (where the ALI files are found) is different from the sources patch.
 
-@noindent
-@code{GDB} is a general purpose, platform-independent debugger that
-can be used to debug mixed-language programs compiled with @code{GCC},
-and in particular is capable of debugging Ada programs compiled with
-GNAT. The latest versions of @code{GDB} are Ada-aware and can handle
-complex Ada data structures.
+Note a small trick in the Makefile below: for efficiency reasons, we
+create two temporary variables (SOURCE_LIST and OBJECT_LIST), that are
+expanded immediately by @code{make}. This way we overcome the standard
+make behavior which is to expand the variables only when they are
+actually used.
 
-The manual @cite{Debugging with GDB}
-@ifset vms
-, located in the GNU:[DOCS] directory,
-@end ifset
-contains full details on the usage of @code{GDB}, including a section on
-its usage on programs. This manual should be consulted for full
-details. The section that follows is a brief introduction to the
-philosophy and use of @code{GDB}.
+On Windows, if you are using the standard Windows command shell, you must
+replace colons with semicolons in the assignments to these variables.
 
-When GNAT programs are compiled, the compiler optionally writes debugging
-information into the generated object file, including information on
-line numbers, and on declared types and variables. This information is
-separate from the generated code. It makes the object files considerably
-larger, but it does not add to the size of the actual executable that
-will be loaded into memory, and has no impact on run-time performance. The
-generation of debug information is triggered by the use of the
-^-g^/DEBUG^ switch in the gcc or gnatmake command used to carry out
-the compilations. It is important to emphasize that the use of these
-options does not change the generated code.
+@smallexample
+@iftex
+@leftskip=0cm
+@font@heightrm=cmr8
+@heightrm
+@end iftex
+# In this example, we create both ADA_INCLUDE_PATH and ADA_OBJECT_PATH.
+# This is the same thing as putting the -I arguments on the command line.
+# (the equivalent of using -aI on the command line would be to define
+#  only ADA_INCLUDE_PATH, the equivalent of -aO is ADA_OBJECT_PATH).
+# You can of course have different values for these variables.
+#
+# Note also that we need to keep the previous values of these variables, since
+# they might have been set before running 'make' to specify where the GNAT
+# library is installed.
 
-The debugging information is written in standard system formats that
-are used by many tools, including debuggers and profilers. The format
-of the information is typically designed to describe C types and
-semantics, but GNAT implements a translation scheme which allows full
-details about Ada types and variables to be encoded into these
-standard C formats. Details of this encoding scheme may be found in
-the file exp_dbug.ads in the GNAT source distribution. However, the
-details of this encoding are, in general, of no interest to a user,
-since @code{GDB} automatically performs the necessary decoding.
+# see "Automatically creating a list of directories" to create these
+# variables
+SOURCE_DIRS=
+OBJECT_DIRS=
 
-When a program is bound and linked, the debugging information is
-collected from the object files, and stored in the executable image of
-the program. Again, this process significantly increases the size of
-the generated executable file, but it does not increase the size of
-the executable program itself. Furthermore, if this program is run in
-the normal manner, it runs exactly as if the debug information were
-not present, and takes no more actual memory.
+empty:=
+space:=$@{empty@} $@{empty@}
+SOURCE_LIST := $@{subst $@{space@},:,$@{SOURCE_DIRS@}@}
+OBJECT_LIST := $@{subst $@{space@},:,$@{OBJECT_DIRS@}@}
+ADA_INCLUDE_PATH += $@{SOURCE_LIST@}
+ADA_OBJECT_PATH += $@{OBJECT_LIST@}
+export ADA_INCLUDE_PATH
+export ADA_OBJECT_PATH
 
-However, if the program is run under control of @code{GDB}, the
-debugger is activated.  The image of the program is loaded, at which
-point it is ready to run.  If a run command is given, then the program
-will run exactly as it would have if @code{GDB} were not present. This
-is a crucial part of the @code{GDB} design philosophy.  @code{GDB} is
-entirely non-intrusive until a breakpoint is encountered.  If no
-breakpoint is ever hit, the program will run exactly as it would if no
-debugger were present. When a breakpoint is hit, @code{GDB} accesses
-the debugging information and can respond to user commands to inspect
-variables, and more generally to report on the state of execution.
+all:
+        gnatmake main_unit
+@end smallexample
+@end ifclear
 
-@c **************
-@node Running GDB
-@section Running GDB
+@node Memory Management Issues
+@chapter Memory Management Issues
 
 @noindent
-The debugger can be launched directly and simply from @code{glide} or
-through its graphical interface: @code{gvd}. It can also be used
-directly in text mode. Here is described the basic use of @code{GDB}
-in text mode. All the commands described below can be used in the
-@code{gvd} console window even though there is usually other more
-graphical ways to achieve the same goals.
+This chapter describes some useful memory pools provided in the GNAT library
+and in particular the GNAT Debug Pool facility, which can be used to detect
+incorrect uses of access values (including ``dangling references'').
+@ifclear vms
+It also describes the @command{gnatmem} tool, which can be used to track down
+``memory leaks''.
+@end ifclear
 
+@menu
+* Some Useful Memory Pools::
+* The GNAT Debug Pool Facility::
 @ifclear vms
+* The gnatmem Tool::
+@end ifclear
+@end menu
+
+@node Some Useful Memory Pools
+@section Some Useful Memory Pools
+@findex Memory Pool
+@cindex storage, pool
+
 @noindent
-The command to run the graphical interface of the debugger is
-@smallexample
-$ gvd program
+The @code{System.Pool_Global} package offers the Unbounded_No_Reclaim_Pool
+storage pool. Allocations use the standard system call @code{malloc} while
+deallocations use the standard system call @code{free}. No reclamation is
+performed when the pool goes out of scope. For performance reasons, the
+standard default Ada allocators/deallocators do not use any explicit storage
+pools but if they did, they could use this storage pool without any change in
+behavior. That is why this storage pool is used  when the user
+manages to make the default implicit allocator explicit as in this example:
+@smallexample @c ada
+   type T1 is access Something;
+    -- no Storage pool is defined for T2
+   type T2 is access Something_Else;
+   for T2'Storage_Pool use T1'Storage_Pool;
+   -- the above is equivalent to
+   for T2'Storage_Pool use System.Pool_Global.Global_Pool_Object;
 @end smallexample
-@end ifclear
 
 @noindent
-The command to run @code{GDB} in text mode is
+The @code{System.Pool_Local} package offers the Unbounded_Reclaim_Pool storage
+pool. The allocation strategy is similar to @code{Pool_Local}'s
+except that the all
+storage allocated with this pool is reclaimed when the pool object goes out of
+scope. This pool provides a explicit mechanism similar to the implicit one
+provided by several Ada 83 compilers for allocations performed through a local
+access type and whose purpose was to reclaim memory when exiting the
+scope of a given local access. As an example, the following program does not
+leak memory even though it does not perform explicit deallocation:
 
-@smallexample
-$ ^gdb program^$ GDB PROGRAM^
+@smallexample @c ada
+with System.Pool_Local;
+procedure Pooloc1 is
+   procedure Internal is
+      type A is access Integer;
+      X : System.Pool_Local.Unbounded_Reclaim_Pool;
+      for A'Storage_Pool use X;
+      v : A;
+   begin
+      for I in  1 .. 50 loop
+         v := new Integer;
+      end loop;
+   end Internal;
+begin
+   for I in  1 .. 100 loop
+      Internal;
+   end loop;
+end Pooloc1;
 @end smallexample
 
 @noindent
-where @code{^program^PROGRAM^} is the name of the executable file. This
-activates the debugger and results in a prompt for debugger commands.
-The simplest command is simply @code{run}, which causes the program to run
-exactly as if the debugger were not present. The following section
-describes some of the additional commands that can be given to @code{GDB}.
+The @code{System.Pool_Size} package implements the Stack_Bounded_Pool used when
+@code{Storage_Size} is specified for an access type.
+The whole storage for the pool is
+allocated at once, usually on the stack at the point where the access type is
+elaborated. It is automatically reclaimed when exiting the scope where the
+access type is defined. This package is not intended to be used directly by the
+user and it is implicitly used for each such declaration:
 
+@smallexample @c ada
+   type T1 is access Something;
+   for T1'Storage_Size use 10_000;
+@end smallexample
 
-@c *******************************
-@node Introduction to GDB Commands
-@section Introduction to GDB Commands
+@node The GNAT Debug Pool Facility
+@section The GNAT Debug Pool Facility
+@findex Debug Pool
+@cindex storage, pool, memory corruption
 
 @noindent
-@code{GDB} contains a large repertoire of commands. The manual
-@cite{Debugging with GDB}
-@ifset vms
-, located in the GNU:[DOCS] directory,
-@end ifset
-includes extensive documentation on the use
-of these commands, together with examples of their use. Furthermore,
-the command @var{help} invoked from within @code{GDB} activates a simple help
-facility which summarizes the available commands and their options.
-In this section we summarize a few of the most commonly
-used commands to give an idea of what @code{GDB} is about. You should create
-a simple program with debugging information and experiment with the use of
-these @code{GDB} commands on the program as you read through the
-following section.
+The use of unchecked deallocation and unchecked conversion can easily
+lead to incorrect memory references. The problems generated by such
+references are usually difficult to tackle because the symptoms can be
+very remote from the origin of the problem. In such cases, it is
+very helpful to detect the problem as early as possible. This is the
+purpose of the Storage Pool provided by @code{GNAT.Debug_Pools}.
 
-@table @code
-@item set args @var{arguments}
-The @var{arguments} list above is a list of arguments to be passed to
-the program on a subsequent run command, just as though the arguments
-had been entered on a normal invocation of the program. The @code{set args}
-command is not needed if the program does not require arguments.
+In order to use the GNAT specific debugging pool, the user must
+associate a debug pool object with each of the access types that may be
+related to suspected memory problems. See Ada Reference Manual 13.11.
+@smallexample @c ada
+type Ptr is access Some_Type;
+Pool : GNAT.Debug_Pools.Debug_Pool;
+for Ptr'Storage_Pool use Pool;
+@end smallexample
 
-@item run
-The @code{run} command causes execution of the program to start from
-the beginning. If the program is already running, that is to say if
-you are currently positioned at a breakpoint, then a prompt will ask
-for confirmation that you want to abandon the current execution and
-restart.
+@noindent
+@code{GNAT.Debug_Pools} is derived from a GNAT-specific kind of
+pool: the @code{Checked_Pool}. Such pools, like standard Ada storage pools,
+allow the user to redefine allocation and deallocation strategies. They
+also provide a checkpoint for each dereference, through the use of
+the primitive operation @code{Dereference} which is implicitly called at
+each dereference of an access value.
 
-@item breakpoint @var{location}
-The breakpoint command sets a breakpoint, that is to say a point at which
-execution will halt and @code{GDB} will await further
-commands. @var{location} is
-either a line number within a file, given in the format @code{file:linenumber},
-or it is the name of a subprogram. If you request that a breakpoint be set on
-a subprogram that is overloaded, a prompt will ask you to specify on which of
-those subprograms you want to breakpoint. You can also
-specify that all of them should be breakpointed. If the program is run
-and execution encounters the breakpoint, then the program
-stops and @code{GDB} signals that the breakpoint was encountered by
-printing the line of code before which the program is halted.
-
-@item breakpoint exception @var{name}
-A special form of the breakpoint command which breakpoints whenever
-exception @var{name} is raised.
-If @var{name} is omitted,
-then a breakpoint will occur when any exception is raised.
+Once an access type has been associated with a debug pool, operations on
+values of the type may raise four distinct exceptions,
+which correspond to four potential kinds of memory corruption:
+@itemize @bullet
+@item
+@code{GNAT.Debug_Pools.Accessing_Not_Allocated_Storage}
+@item
+@code{GNAT.Debug_Pools.Accessing_Deallocated_Storage}
+@item
+@code{GNAT.Debug_Pools.Freeing_Not_Allocated_Storage}
+@item
+@code{GNAT.Debug_Pools.Freeing_Deallocated_Storage }
+@end itemize
 
-@item print @var{expression}
-This will print the value of the given expression. Most simple
-Ada expression formats are properly handled by @code{GDB}, so the expression
-can contain function calls, variables, operators, and attribute references.
+@noindent
+For types associated with a Debug_Pool, dynamic allocation is performed using
+the standard GNAT allocation routine. References to all allocated chunks of
+memory are kept in an internal dictionary. Several deallocation strategies are
+provided, whereupon the user can choose to release the memory to the system,
+keep it allocated for further invalid access checks, or fill it with an easily
+recognizable pattern for debug sessions. The memory pattern is the old IBM
+hexadecimal convention: @code{16#DEADBEEF#}.
 
-@item continue
-Continues execution following a breakpoint, until the next breakpoint or the
-termination of the program.
+See the documentation in the file g-debpoo.ads for more information on the
+various strategies.
 
-@item step
-Executes a single line after a breakpoint. If the next statement
-is a subprogram call, execution continues into (the first statement of)
-the called subprogram.
+Upon each dereference, a check is made that the access value denotes a
+properly allocated memory location. Here is a complete example of use of
+@code{Debug_Pools}, that includes typical instances of  memory corruption:
+@smallexample @c ada
+@iftex
+@leftskip=0cm
+@end iftex
+with Gnat.Io; use Gnat.Io;
+with Unchecked_Deallocation;
+with Unchecked_Conversion;
+with GNAT.Debug_Pools;
+with System.Storage_Elements;
+with Ada.Exceptions; use Ada.Exceptions;
+procedure Debug_Pool_Test is
 
-@item next
-Executes a single line. If this line is a subprogram call, executes and
-returns from the call.
+   type T is access Integer;
+   type U is access all T;
 
-@item list
-Lists a few lines around the current source location. In practice, it
-is usually more convenient to have a separate edit window open with the
-relevant source file displayed. Successive applications of this command
-print subsequent lines. The command can be given an argument which is a
-line number, in which case it displays a few lines around the specified one.
+   P : GNAT.Debug_Pools.Debug_Pool;
+   for T'Storage_Pool use P;
 
-@item backtrace
-Displays a backtrace of the call chain. This command is typically
-used after a breakpoint has occurred, to examine the sequence of calls that
-leads to the current breakpoint. The display includes one line for each
-activation record (frame) corresponding to an active subprogram.
+   procedure Free is new Unchecked_Deallocation (Integer, T);
+   function UC is new Unchecked_Conversion (U, T);
+   A, B : aliased T;
 
-@item up
-At a breakpoint, @code{GDB} can display the values of variables local
-to the current frame. The command @code{up} can be used to
-examine the contents of other active frames, by moving the focus up
-the stack, that is to say from callee to caller, one frame at a time.
+   procedure Info is new GNAT.Debug_Pools.Print_Info(Put_Line);
 
-@item down
-Moves the focus of @code{GDB} down from the frame currently being
-examined to the frame of its callee (the reverse of the previous command),
+begin
+   Info (P);
+   A := new Integer;
+   B := new Integer;
+   B := A;
+   Info (P);
+   Free (A);
+   begin
+      Put_Line (Integer'Image(B.all));
+   exception
+      when E : others => Put_Line ("raised: " & Exception_Name (E));
+   end;
+   begin
+      Free (B);
+   exception
+      when E : others => Put_Line ("raised: " & Exception_Name (E));
+   end;
+   B := UC(A'Access);
+   begin
+      Put_Line (Integer'Image(B.all));
+   exception
+      when E : others => Put_Line ("raised: " & Exception_Name (E));
+   end;
+   begin
+      Free (B);
+   exception
+      when E : others => Put_Line ("raised: " & Exception_Name (E));
+   end;
+   Info (P);
+end Debug_Pool_Test;
+@end smallexample
 
-@item frame @var{n}
-Inspect the frame with the given number. The value 0 denotes the frame
-of the current breakpoint, that is to say the top of the call stack.
+@noindent
+The debug pool mechanism provides the following precise diagnostics on the
+execution of this erroneous program:
+@smallexample
+Debug Pool info:
+  Total allocated bytes :  0
+  Total deallocated bytes :  0
+  Current Water Mark:  0
+  High Water Mark:  0
 
-@end table
+Debug Pool info:
+  Total allocated bytes :  8
+  Total deallocated bytes :  0
+  Current Water Mark:  8
+  High Water Mark:  8
 
-The above list is a very short introduction to the commands that
-@code{GDB} provides. Important additional capabilities, including conditional
-breakpoints, the ability to execute command sequences on a breakpoint,
-the ability to debug at the machine instruction level and many other
-features are described in detail in @cite{Debugging with GDB}.
-Note that most commands can be abbreviated
-(for example, c for continue, bt for backtrace).
+raised: GNAT.DEBUG_POOLS.ACCESSING_DEALLOCATED_STORAGE
+raised: GNAT.DEBUG_POOLS.FREEING_DEALLOCATED_STORAGE
+raised: GNAT.DEBUG_POOLS.ACCESSING_NOT_ALLOCATED_STORAGE
+raised: GNAT.DEBUG_POOLS.FREEING_NOT_ALLOCATED_STORAGE
+Debug Pool info:
+  Total allocated bytes :  8
+  Total deallocated bytes :  4
+  Current Water Mark:  4
+  High Water Mark:  8
+@end smallexample
 
-@node Using Ada Expressions
-@section Using Ada Expressions
-@cindex Ada expressions
+@ifclear vms
+@node The gnatmem Tool
+@section The @command{gnatmem} Tool
+@findex gnatmem
 
 @noindent
-@code{GDB} supports a fairly large subset of Ada expression syntax, with some
-extensions. The philosophy behind the design of this subset is
-
+The @code{gnatmem} utility monitors dynamic allocation and
+deallocation activity in a program, and displays information about
+incorrect deallocations and possible sources of memory leaks.
+It provides three type of information:
 @itemize @bullet
 @item
-That @code{GDB} should provide basic literals and access to operations for
-arithmetic, dereferencing, field selection, indexing, and subprogram calls,
-leaving more sophisticated computations to subprograms written into the
-program (which therefore may be called from @code{GDB}).
+General information concerning memory management, such as the total
+number of allocations and deallocations, the amount of allocated
+memory and the high water mark, i.e. the largest amount of allocated
+memory in the course of program execution.
 
 @item
-That type safety and strict adherence to Ada language restrictions
-are not particularly important to the @code{GDB} user.
+Backtraces for all incorrect deallocations, that is to say deallocations
+which do not correspond to a valid allocation.
 
 @item
-That brevity is important to the @code{GDB} user.
+Information on each allocation that is potentially the origin of a memory
+leak.
 @end itemize
 
-Thus, for brevity, the debugger acts as if there were
-implicit @code{with} and @code{use} clauses in effect for all user-written
-packages, thus making it unnecessary to fully qualify most names with
-their packages, regardless of context. Where this causes ambiguity,
-@code{GDB} asks the user's intent.
+@menu
+* Running gnatmem::
+* Switches for gnatmem::
+* Example of gnatmem Usage::
+@end menu
 
-For details on the supported Ada syntax, see @cite{Debugging with GDB}.
+@node Running gnatmem
+@subsection Running @code{gnatmem}
 
-@node Calling User-Defined Subprograms
-@section Calling User-Defined Subprograms
+@noindent
+@code{gnatmem} makes use of the output created by the special version of
+allocation and deallocation routines that record call information. This
+allows to obtain accurate dynamic memory usage history at a minimal cost to
+the execution speed. Note however, that @code{gnatmem} is not supported on
+all platforms (currently, it is supported on AIX, HP-UX, GNU/Linux,
+Solaris and Windows NT/2000/XP (x86).
 
 @noindent
-An important capability of @code{GDB} is the ability to call user-defined
-subprograms while debugging. This is achieved simply by entering
-a subprogram call statement in the form:
+The @code{gnatmem} command has the form
 
 @smallexample
-call subprogram-name (parameters)
+   $ gnatmem [switches] user_program
 @end smallexample
 
 @noindent
-The keyword @code{call} can be omitted in the normal case where the
-@code{subprogram-name} does not coincide with any of the predefined
-@code{GDB} commands.
-
-The effect is to invoke the given subprogram, passing it the
-list of parameters that is supplied. The parameters can be expressions and
-can include variables from the program being debugged. The
-subprogram must be defined
-at the library level within your program, and @code{GDB} will call the
-subprogram within the environment of your program execution (which
-means that the subprogram is free to access or even modify variables
-within your program).
-
-The most important use of this facility is in allowing the inclusion of
-debugging routines that are tailored to particular data structures
-in your program. Such debugging routines can be written to provide a suitably
-high-level description of an abstract type, rather than a low-level dump
-of its physical layout. After all, the standard
-@code{GDB print} command only knows the physical layout of your
-types, not their abstract meaning. Debugging routines can provide information
-at the desired semantic level and are thus enormously useful.
+The program must have been linked with the instrumented version of the
+allocation and deallocation routines. This is done by linking with the
+@file{libgmem.a} library. For correct symbolic backtrace information,
+the user program should be compiled with debugging options
+(see @ref{Switches for gcc}). For example to build @file{my_program}:
 
-For example, when debugging GNAT itself, it is crucial to have access to
-the contents of the tree nodes used to represent the program internally.
-But tree nodes are represented simply by an integer value (which in turn
-is an index into a table of nodes).
-Using the @code{print} command on a tree node would simply print this integer
-value, which is not very useful. But the PN routine (defined in file
-treepr.adb in the GNAT sources) takes a tree node as input, and displays
-a useful high level representation of the tree node, which includes the
-syntactic category of the node, its position in the source, the integers
-that denote descendant nodes and parent node, as well as varied
-semantic information. To study this example in more detail, you might want to
-look at the body of the PN procedure in the stated file.
+@smallexample
+$ gnatmake -g my_program -largs -lgmem
+@end smallexample
 
-@node Using the Next Command in a Function
-@section Using the Next Command in a Function
+@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 you use the @code{next} command in a function, the current source
-location will advance to the next statement as usual. A special case
-arises in the case of a @code{return} statement.
+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
+deallocations routines and will be used by @code{gnatmem}.
 
-Part of the code for a return statement is the ``epilog'' of the function.
-This is the code that returns to the caller. There is only one copy of
-this epilog code, and it is typically associated with the last return
-statement in the function if there is more than one return. In some
-implementations, this epilog is associated with the first statement
-of the function.
+In order to produce symbolic backtrace information for allocations and
+deallocations performed by the GNAT run-time library, you need to use a
+version of that library that has been compiled with the @option{-g} switch
+(see @ref{Rebuilding the GNAT Run-Time Library}).
 
-The result is that if you use the @code{next} command from a return
-statement that is not the last return statement of the function you
-may see a strange apparent jump to the last return statement or to
-the start of the function. You should simply ignore this odd jump.
-The value returned is always that from the first return statement
-that was stepped through.
+Gnatmem must be supplied with the @file{gmem.out} file and the executable to
+examine. If the location of @file{gmem.out} file was not explicitly supplied by
+@option{-i} switch, gnatmem will assume that this file can be found in the
+current directory. For example, after you have executed @file{my_program},
+@file{gmem.out} can be analyzed by @code{gnatmem} using the command:
 
-@node Ada Exceptions
-@section Breaking on Ada Exceptions
-@cindex Exceptions
+@smallexample
+$ gnatmem my_program
+@end smallexample
 
 @noindent
-You can set breakpoints that trip when your program raises
-selected exceptions.
-
-@table @code
-@item break exception
-Set a breakpoint that trips whenever (any task in the) program raises
-any exception.
+This will produce the output with the following format:
 
-@item break exception @var{name}
-Set a breakpoint that trips whenever (any task in the) program raises
-the exception @var{name}.
+*************** debut cc
+@smallexample
+$ gnatmem my_program
 
-@item break exception unhandled
-Set a breakpoint that trips whenever (any task in the) program raises an
-exception for which there is no handler.
+Global information
+------------------
+   Total number of allocations        :  45
+   Total number of deallocations      :   6
+   Final Water Mark (non freed mem)   :  11.29 Kilobytes
+   High Water Mark                    :  11.40 Kilobytes
 
-@item info exceptions
-@itemx info exceptions @var{regexp}
-The @code{info exceptions} command permits the user to examine all defined
-exceptions within Ada programs. With a regular expression, @var{regexp}, as
-argument, prints out only those exceptions whose name matches @var{regexp}.
-@end table
+.
+.
+.
+Allocation Root # 2
+-------------------
+ Number of non freed allocations    :  11
+ Final Water Mark (non freed mem)   :   1.16 Kilobytes
+ High Water Mark                    :   1.27 Kilobytes
+ Backtrace                          :
+   my_program.adb:23 my_program.alloc
+.
+.
+.
+@end smallexample
 
-@node Ada Tasks
-@section Ada Tasks
-@cindex Tasks
+The first block of output gives general information. In this case, the
+Ada construct ``@code{@b{new}}'' was executed 45 times, and only 6 calls to an
+Unchecked_Deallocation routine occurred.
 
 @noindent
-@code{GDB} allows the following task-related commands:
-
-@table @code
-@item info tasks
-This command shows a list of current Ada tasks, as in the following example:
+Subsequent paragraphs display  information on all allocation roots.
+An allocation root is a specific point in the execution of the program
+that generates some dynamic allocation, such as a ``@code{@b{new}}''
+construct. This root is represented by an execution backtrace (or subprogram
+call stack). By default the backtrace depth for allocations roots is 1, so
+that a root corresponds exactly to a source location. The backtrace can
+be made deeper, to make the root more specific.
 
-@smallexample
-@iftex
-@leftskip=0cm
-@end iftex
-(gdb) info tasks
-  ID       TID P-ID   Thread Pri State                 Name
-   1   8088000   0   807e000  15 Child Activation Wait main_task
-   2   80a4000   1   80ae000  15 Accept/Select Wait    b
-   3   809a800   1   80a4800  15 Child Activation Wait a
-*  4   80ae800   3   80b8000  15 Running               c
-@end smallexample
+@node Switches for gnatmem
+@subsection Switches for @code{gnatmem}
 
 @noindent
-In this listing, the asterisk before the first task indicates it to be the
-currently running task. The first column lists the task ID that is used
-to refer to tasks in the following commands.
+@code{gnatmem} recognizes the following switches:
 
-@item break @var{linespec} task @var{taskid}
-@itemx break @var{linespec} task @var{taskid} if @dots{}
-@cindex Breakpoints and tasks
-These commands are like the @code{break @dots{} thread @dots{}}.
-@var{linespec} specifies source lines.
+@table @option
 
-Use the qualifier @samp{task @var{taskid}} with a breakpoint command
-to specify that you only want @code{GDB} to stop the program when a
-particular Ada task reaches this breakpoint. @var{taskid} is one of the
-numeric task identifiers assigned by @code{GDB}, shown in the first
-column of the @samp{info tasks} display.
+@item -q
+@cindex @option{-q} (@code{gnatmem})
+Quiet. Gives the minimum output needed to identify the origin of the
+memory leaks. Omits statistical information.
 
-If you do not specify @samp{task @var{taskid}} when you set a
-breakpoint, the breakpoint applies to @emph{all} tasks of your
-program.
+@item @var{N}
+@cindex @var{N} (@code{gnatmem})
+N is an integer literal (usually between 1 and 10) which controls the
+depth of the backtraces defining allocation root. The default value for
+N is 1. The deeper the backtrace, the more precise the localization of
+the root. Note that the total number of roots can depend on this
+parameter. This parameter must be specified @emph{before} the name of the
+executable to be analyzed, to avoid ambiguity.
 
-You can use the @code{task} qualifier on conditional breakpoints as
-well; in this case, place @samp{task @var{taskid}} before the
-breakpoint condition (before the @code{if}).
+@item -b n
+@cindex @option{-b} (@code{gnatmem})
+This switch has the same effect as just depth parameter.
 
-@item task @var{taskno}
-@cindex Task switching
+@item -i @var{file}
+@cindex @option{-i} (@code{gnatmem})
+Do the @code{gnatmem} processing starting from @file{file}, rather than
+@file{gmem.out} in the current directory.
 
-This command allows to switch to the task referred by @var{taskno}. In
-particular, This allows to browse the backtrace of the specified
-task. It is advised to switch back to the original task before
-continuing execution otherwise the scheduling of the program may be
-perturbated.
-@end table
+@item -m n
+@cindex @option{-m} (@code{gnatmem})
+This switch causes @code{gnatmem} to mask the allocation roots that have less
+than n leaks. The default value is 1. Specifying the value of 0 will allow to
+examine even the roots that didn't result in leaks.
 
-@noindent
-For more detailed information on the tasking support,
-see @cite{Debugging with GDB}.
+@item -s order
+@cindex @option{-s} (@code{gnatmem})
+This switch causes @code{gnatmem} to sort the allocation roots according to the
+specified order of sort criteria, each identified by a single letter. The
+currently supported criteria are @code{n, h, w} standing respectively for
+number of unfreed allocations, high watermark, and final watermark
+corresponding to a specific root. The default order is @code{nwh}.
 
-@node Debugging Generic Units
-@section Debugging Generic Units
-@cindex Debugging Generic Units
-@cindex Generics
+@end table
 
-@noindent
-GNAT always uses code expansion for generic instantiation. This means that
-each time an instantiation occurs, a complete copy of the original code is
-made, with appropriate substitutions of formals by actuals.
+@node Example of gnatmem Usage
+@subsection Example of @code{gnatmem} Usage
 
-It is not possible to refer to the original generic entities in
-@code{GDB}, but it is always possible to debug a particular instance of
-a generic, by using the appropriate expanded names. For example, if we have
+@noindent
+The following example shows the use of @code{gnatmem}
+on a simple memory-leaking program.
+Suppose that we have the following Ada program:
 
 @smallexample @c ada
 @group
 @cartouche
-procedure g is
-
-   generic package k is
-      procedure kp (v1 : in out integer);
-   end k;
+with Unchecked_Deallocation;
+procedure Test_Gm is
 
-   package body k is
-      procedure kp (v1 : in out integer) is
-      begin
-         v1 := v1 + 1;
-      end kp;
-   end k;
+   type T is array (1..1000) of Integer;
+   type Ptr is access T;
+   procedure Free is new Unchecked_Deallocation (T, Ptr);
+   A : Ptr;
 
-   package k1 is new k;
-   package k2 is new k;
+   procedure My_Alloc is
+   begin
+      A := new T;
+   end My_Alloc;
 
-   var : integer := 1;
+   procedure My_DeAlloc is
+      B : Ptr := A;
+   begin
+      Free (B);
+   end My_DeAlloc;
 
 begin
-   k1.kp (var);
-   k2.kp (var);
-   k1.kp (var);
-   k2.kp (var);
+   My_Alloc;
+   for I in 1 .. 5 loop
+      for J in I .. 5 loop
+         My_Alloc;
+      end loop;
+      My_Dealloc;
+   end loop;
 end;
 @end cartouche
 @end group
 @end smallexample
 
 @noindent
-Then to break on a call to procedure kp in the k2 instance, simply
-use the command:
+The program needs to be compiled with debugging option and linked with
+@code{gmem} library:
 
 @smallexample
-(gdb) break g.k2.kp
+$ gnatmake -g test_gm -largs -lgmem
 @end smallexample
 
 @noindent
-When the breakpoint occurs, you can step through the code of the
-instance in the normal manner and examine the values of local variables, as for
-other units.
+Then we execute the program as usual:
 
-@node GNAT Abnormal Termination or Failure to Terminate
-@section GNAT Abnormal Termination or Failure to Terminate
-@cindex GNAT Abnormal Termination or Failure to Terminate
+@smallexample
+$ test_gm
+@end smallexample
 
 @noindent
-When presented with programs that contain serious errors in syntax
-or semantics,
-GNAT may on rare occasions  experience problems in operation, such
-as aborting with a
-segmentation fault or illegal memory access, raising an internal
-exception, terminating abnormally, or failing to terminate at all.
-In such cases, you can activate
-various features of GNAT that can help you pinpoint the construct in your
-program that is the likely source of the problem.
+Then @code{gnatmem} is invoked simply with
+@smallexample
+$ gnatmem test_gm
+@end smallexample
 
-The following strategies are presented in increasing order of
-difficulty, corresponding to your experience in using GNAT and your
-familiarity with compiler internals.
+@noindent
+which produces the following output (result may vary on different platforms):
 
-@enumerate
-@item
-Run @code{gcc} with the @option{-gnatf}. This first
-switch causes all errors on a given line to be reported. In its absence,
-only the first error on a line is displayed.
+@smallexample
+Global information
+------------------
+   Total number of allocations        :  18
+   Total number of deallocations      :   5
+   Final Water Mark (non freed mem)   :  53.00 Kilobytes
+   High Water Mark                    :  56.90 Kilobytes
 
-The @option{-gnatdO} switch causes errors to be displayed as soon as they
-are encountered, rather than after compilation is terminated. If GNAT
-terminates prematurely or goes into an infinite loop, the last error
-message displayed may help to pinpoint the culprit.
+Allocation Root # 1
+-------------------
+ Number of non freed allocations    :  11
+ Final Water Mark (non freed mem)   :  42.97 Kilobytes
+ High Water Mark                    :  46.88 Kilobytes
+ Backtrace                          :
+   test_gm.adb:11 test_gm.my_alloc
 
-@item
-Run @code{gcc} with the @option{^-v (verbose)^/VERBOSE^} switch. In this mode,
-@code{gcc} produces ongoing information about the progress of the
-compilation and provides the name of each procedure as code is
-generated. This switch allows you to find which Ada procedure was being
-compiled when it encountered a code generation problem.
+Allocation Root # 2
+-------------------
+ Number of non freed allocations    :   1
+ Final Water Mark (non freed mem)   :  10.02 Kilobytes
+ High Water Mark                    :  10.02 Kilobytes
+ Backtrace                          :
+   s-secsta.adb:81 system.secondary_stack.ss_init
 
-@item
-@cindex @option{-gnatdc} switch
-Run @code{gcc} with the @option{-gnatdc} switch. This is a GNAT specific
-switch that does for the front-end what @option{^-v^VERBOSE^} does
-for the back end. The system prints the name of each unit,
-either a compilation unit or nested unit, as it is being analyzed.
-@item
-Finally, you can start
-@code{gdb} directly on the @code{gnat1} executable. @code{gnat1} is the
-front-end of GNAT, and can be run independently (normally it is just
-called from @code{gcc}). You can use @code{gdb} on @code{gnat1} as you
-would on a C program (but @pxref{The GNAT Debugger GDB} for caveats). The
-@code{where} command is the first line of attack; the variable
-@code{lineno} (seen by @code{print lineno}), used by the second phase of
-@code{gnat1} and by the @code{gcc} backend, indicates the source line at
-which the execution stopped, and @code{input_file name} indicates the name of
-the source file.
-@end enumerate
+Allocation Root # 3
+-------------------
+ Number of non freed allocations    :   1
+ Final Water Mark (non freed mem)   :  12 Bytes
+ High Water Mark                    :  12 Bytes
+ Backtrace                          :
+   s-secsta.adb:181 system.secondary_stack.ss_init
+@end smallexample
 
-@node Naming Conventions for GNAT Source Files
-@section Naming Conventions for GNAT Source Files
+@noindent
+Note that the GNAT run time contains itself a certain number of
+allocations that have no  corresponding deallocation,
+as shown here for root #2 and root
+#3. This is a normal behavior when the number of non freed allocations
+is one, it allocates dynamic data structures that the run time needs for
+the complete lifetime of the program. Note also that there is only one
+allocation root in the user program with a single line back trace:
+test_gm.adb:11 test_gm.my_alloc, whereas a careful analysis of the
+program shows that 'My_Alloc' is called at 2 different points in the
+source (line 21 and line 24). If those two allocation roots need to be
+distinguished, the backtrace depth parameter can be used:
+
+@smallexample
+$ gnatmem 3 test_gm
+@end smallexample
 
 @noindent
-In order to examine the workings of the GNAT system, the following
-brief description of its organization may be helpful:
+which will give the following output:
 
-@itemize @bullet
-@item
-Files with prefix @file{^sc^SC^} contain the lexical scanner.
+@smallexample
+Global information
+------------------
+   Total number of allocations        :  18
+   Total number of deallocations      :   5
+   Final Water Mark (non freed mem)   :  53.00 Kilobytes
+   High Water Mark                    :  56.90 Kilobytes
 
-@item
-All files prefixed with @file{^par^PAR^} are components of the parser. The
-numbers correspond to chapters of the Ada 95 Reference Manual. For example,
-parsing of select statements can be found in @file{par-ch9.adb}.
+Allocation Root # 1
+-------------------
+ Number of non freed allocations    :  10
+ Final Water Mark (non freed mem)   :  39.06 Kilobytes
+ High Water Mark                    :  42.97 Kilobytes
+ Backtrace                          :
+   test_gm.adb:11 test_gm.my_alloc
+   test_gm.adb:24 test_gm
+   b_test_gm.c:52 main
 
-@item
-All files prefixed with @file{^sem^SEM^} perform semantic analysis. The
-numbers correspond to chapters of the Ada standard. For example, all
-issues involving context clauses can be found in @file{sem_ch10.adb}. In
-addition, some features of the language require sufficient special processing
-to justify their own semantic files: sem_aggr for aggregates, sem_disp for
-dynamic dispatching, etc.
+Allocation Root # 2
+-------------------
+ Number of non freed allocations    :   1
+ Final Water Mark (non freed mem)   :  10.02 Kilobytes
+ High Water Mark                    :  10.02 Kilobytes
+ Backtrace                          :
+   s-secsta.adb:81  system.secondary_stack.ss_init
+   s-secsta.adb:283 <system__secondary_stack___elabb>
+   b_test_gm.c:33   adainit
 
-@item
-All files prefixed with @file{^exp^EXP^} perform normalization and
-expansion of the intermediate representation (abstract syntax tree, or AST).
-these files use the same numbering scheme as the parser and semantics files.
-For example, the construction of record initialization procedures is done in
-@file{exp_ch3.adb}.
+Allocation Root # 3
+-------------------
+ Number of non freed allocations    :   1
+ Final Water Mark (non freed mem)   :   3.91 Kilobytes
+ High Water Mark                    :   3.91 Kilobytes
+ Backtrace                          :
+   test_gm.adb:11 test_gm.my_alloc
+   test_gm.adb:21 test_gm
+   b_test_gm.c:52 main
 
-@item
-The files prefixed with @file{^bind^BIND^} implement the binder, which
-verifies the consistency of the compilation, determines an order of
-elaboration, and generates the bind file.
+Allocation Root # 4
+-------------------
+ Number of non freed allocations    :   1
+ Final Water Mark (non freed mem)   :  12 Bytes
+ High Water Mark                    :  12 Bytes
+ Backtrace                          :
+   s-secsta.adb:181 system.secondary_stack.ss_init
+   s-secsta.adb:283 <system__secondary_stack___elabb>
+   b_test_gm.c:33   adainit
+@end smallexample
 
-@item
-The files @file{atree.ads} and @file{atree.adb} detail the low-level
-data structures used by the front-end.
+@noindent
+The allocation root #1 of the first example has been split in 2 roots #1
+and #3 thanks to the more precise associated backtrace.
 
-@item
-The files @file{sinfo.ads} and @file{sinfo.adb} detail the structure of
-the abstract syntax tree as produced by the parser.
+@end ifclear
 
-@item
-The files @file{einfo.ads} and @file{einfo.adb} detail the attributes of
-all entities, computed during semantic analysis.
+@node Stack Related Facilities
+@chapter Stack Related Facilities
 
-@item
-Library management issues are dealt with in files with prefix
-@file{^lib^LIB^}.
+@noindent
+This chapter describes some useful tools associated with stack
+checking and analysis. In
+particular, it deals with dynamic and static stack usage measurements.
 
-@item
-@findex Ada
-@cindex Annex A
-Ada files with the prefix @file{^a-^A-^} are children of @code{Ada}, as
-defined in Annex A.
+@menu
+* Stack Overflow Checking::
+* Static Stack Usage Analysis::
+* Dynamic Stack Usage Analysis::
+@end menu
 
-@item
-@findex Interfaces
-@cindex Annex B
-Files with prefix @file{^i-^I-^} are children of @code{Interfaces}, as
-defined in Annex B.
+@node Stack Overflow Checking
+@section Stack Overflow Checking
+@cindex Stack Overflow Checking
+@cindex -fstack-check
 
-@item
-@findex System
-Files with prefix @file{^s-^S-^} are children of @code{System}. This includes
-both language-defined children and GNAT run-time routines.
+@noindent
+For most operating systems, @command{gcc} does not perform stack overflow
+checking by default. This means that if the main environment task or
+some other task exceeds the available stack space, then unpredictable
+behavior will occur. Most native systems offer some level of protection by
+adding a guard page at the end of each task stack. This mechanism is usually
+not enough for dealing properly with stack overflow situations because
+a large local variable could ``jump'' above the guard page.
+Furthermore, when the
+guard page is hit, there may not be any space left on the stack for executing
+the exception propagation code. Enabling stack checking avoids
+such situations.
 
-@item
-@findex GNAT
-Files with prefix @file{^g-^G-^} are children of @code{GNAT}. These are useful
-general-purpose packages, fully documented in their specifications. All
-the other @file{.c} files are modifications of common @code{gcc} files.
-@end itemize
+To activate stack checking, compile all units with the gcc option
+@option{-fstack-check}. For example:
 
-@node Getting Internal Debugging Information
-@section Getting Internal Debugging Information
+@smallexample
+gcc -c -fstack-check package1.adb
+@end smallexample
 
 @noindent
-Most compilers have internal debugging switches and modes. GNAT
-does also, except GNAT internal debugging switches and modes are not
-secret. A summary and full description of all the compiler and binder
-debug flags are in the file @file{debug.adb}. You must obtain the
-sources of the compiler to see the full detailed effects of these flags.
+Units compiled with this option will generate extra instructions to check
+that any use of the stack (for procedure calls or for declaring local
+variables in declare blocks) does not exceed the available stack space.
+If the space is exceeded, then a @code{Storage_Error} exception is raised.
 
-The switches that print the source of the program (reconstructed from
-the internal tree) are of general interest for user programs, as are the
-options to print
-the full internal tree, and the entity table (the symbol table
-information). The reconstructed source provides a readable version of the
-program after the front-end has completed analysis and  expansion,
-and is useful when studying the performance of specific constructs.
-For example, constraint checks are indicated, complex aggregates
-are replaced with loops and assignments, and tasking primitives
-are replaced with run-time calls.
+For declared tasks, the stack size is controlled by the size
+given in an applicable @code{Storage_Size} pragma or by the value specified
+at bind time with @option{-d} (@pxref{Switches for gnatbind}) or is set to
+the default size as defined in the GNAT runtime otherwise.
 
-@node Stack Traceback
-@section Stack Traceback
-@cindex traceback
-@cindex stack traceback
-@cindex stack unwinding
+For the environment task, the stack size depends on
+system defaults and is unknown to the compiler. Stack checking
+may still work correctly if a fixed
+size stack is allocated, but this cannot be guaranteed.
+@ifclear vms
+To ensure that a clean exception is signalled for stack
+overflow, set the environment variable
+@env{GNAT_STACK_LIMIT} to indicate the maximum
+stack area that can be used, as in:
+@cindex GNAT_STACK_LIMIT
+
+@smallexample
+SET GNAT_STACK_LIMIT 1600
+@end smallexample
 
 @noindent
-Traceback is a mechanism to display the sequence of subprogram calls that
-leads to a specified execution point in a program. Often (but not always)
-the execution point is an instruction at which an exception has been raised.
-This mechanism is also known as @i{stack unwinding} because it obtains
-its information by scanning the run-time stack and recovering the activation
-records of all active subprograms. Stack unwinding is one of the most
-important tools for program debugging.
+The limit is given in kilobytes, so the above declaration would
+set the stack limit of the environment task to 1.6 megabytes.
+Note that the only purpose of this usage is to limit the amount
+of stack used by the environment task. If it is necessary to
+increase the amount of stack for the environment task, then this
+is an operating systems issue, and must be addressed with the
+appropriate operating systems commands.
+@end ifclear
+@ifset vms
+To have a fixed size stack in the environment task, the stack must be put
+in the P0 address space and its size specified.  Use these switches to
+create a p0 image:
 
-The first entry stored in traceback corresponds to the deepest calling level,
-that is to say the subprogram currently executing the instruction
-from which we want to obtain the traceback.
+@smallexample
+gnatmake my_progs -largs "-Wl,--opt=STACK=4000,/p0image"
+@end smallexample
 
-Note that there is no runtime performance penalty when stack traceback
-is enabled, and no exception is raised during program execution.
+@noindent
+The quotes are required to keep case.  The number after @samp{STACK=} is the
+size of the environmental task stack in pagelets (512 bytes).  In this example
+the stack size is about 2 megabytes.
 
-@menu
-* Non-Symbolic Traceback::
-* Symbolic Traceback::
-@end menu
+@noindent
+A consequence of the @option{/p0image} qualifier is also to makes RMS buffers
+be placed in P0 space.  Refer to @cite{HP OpenVMS Linker Utility Manual} for
+more details about the @option{/p0image} qualifier and the @option{stack}
+option.
+@end ifset
 
-@node Non-Symbolic Traceback
-@subsection Non-Symbolic Traceback
-@cindex traceback, non-symbolic
+@node Static Stack Usage Analysis
+@section Static Stack Usage Analysis
+@cindex Static Stack Usage Analysis
+@cindex -fstack-usage
 
 @noindent
-Note: this feature is not supported on all platforms. See
-@file{GNAT.Traceback spec in g-traceb.ads} for a complete list of supported
-platforms.
+A unit compiled with @option{-fstack-usage} will generate an extra file
+that specifies
+the maximum amount of stack used, on a per-function basis.
+The file has the same
+basename as the target object file with a @file{.su} extension.
+Each line of this file is made up of three fields:
 
-@menu
-* Tracebacks From an Unhandled Exception::
-* Tracebacks From Exception Occurrences (non-symbolic)::
-* Tracebacks From Anywhere in a Program (non-symbolic)::
-@end menu
-
-@node Tracebacks From an Unhandled Exception
-@subsubsection Tracebacks From an Unhandled Exception
+@itemize
+@item
+The name of the function.
+@item
+A number of bytes.
+@item
+One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
+@end itemize
 
-@noindent
-A runtime non-symbolic traceback is a list of addresses of call instructions.
-To enable this feature you must use the @option{-E}
-@code{gnatbind}'s option. With this option a stack traceback is stored as part
-of exception information. You can retrieve this information using the
-@code{addr2line} tool.
+The second field corresponds to the size of the known part of the function
+frame.
 
-Here is a simple example:
+The qualifier @code{static} means that the function frame size
+is purely static.
+It usually means that all local variables have a static size.
+In this case, the second field is a reliable measure of the function stack
+utilization.
 
-@smallexample @c ada
-@cartouche
-procedure STB is
+The qualifier @code{dynamic} means that the function frame size is not static.
+It happens mainly when some local variables have a dynamic size. When this
+qualifier appears alone, the second field is not a reliable measure
+of the function stack analysis. When it is qualified with  @code{bounded}, it
+means that the second field is a reliable maximum of the function stack
+utilization.
 
-   procedure P1 is
-   begin
-      raise Constraint_Error;
-   end P1;
+@node Dynamic Stack Usage Analysis
+@section Dynamic Stack Usage Analysis
 
-   procedure P2 is
-   begin
-      P1;
-   end P2;
+@noindent
+It is possible to measure the maximum amount of stack used by a task, by
+adding a switch to @command{gnatbind}, as:
 
-begin
-   P2;
-end STB;
-@end cartouche
+@smallexample
+$ gnatbind -u0 file
 @end smallexample
 
-@smallexample
-$ gnatmake stb -bargs -E
-$ stb
+@noindent
+With this option, at each task termination, its stack usage is  output on
+@file{stderr}.
+It is not always convenient to output the stack usage when the program
+is still running. Hence, it is possible to delay this output until program
+termination. for a given number of tasks specified as the argument of the
+@option{-u} option. For instance:
 
-Execution terminated by unhandled exception
-Exception name: CONSTRAINT_ERROR
-Message: stb.adb:5
-Call stack traceback locations:
-0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4
+@smallexample
+$ gnatbind -u100 file
 @end smallexample
 
 @noindent
-As we see the traceback lists a sequence of addresses for the unhandled
-exception @code{CONSTRAINT_ERROR} raised in procedure P1. It is easy to
-guess that this exception come from procedure P1. To translate these
-addresses into the source lines where the calls appear, the
-@code{addr2line} tool, described below, is invaluable. The use of this tool
-requires the program to be compiled with debug information.
+will buffer the stack usage information of the first 100 tasks to terminate and
+output this info at program termination. Results are displayed in four
+columns:
 
-@smallexample
-$ gnatmake -g stb -bargs -E
-$ stb
+@noindent
+Index | Task Name | Stack Size | Actual Use [min - max]
 
-Execution terminated by unhandled exception
-Exception name: CONSTRAINT_ERROR
-Message: stb.adb:5
-Call stack traceback locations:
-0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4
+@noindent
+where:
 
-$ addr2line --exe=stb 0x401373 0x40138b 0x40139c 0x401335 0x4011c4
-   0x4011f1 0x77e892a4
+@table @emph
+@item Index
+is a number associated with each task.
 
-00401373 at d:/stb/stb.adb:5
-0040138B at d:/stb/stb.adb:10
-0040139C at d:/stb/stb.adb:14
-00401335 at d:/stb/b~stb.adb:104
-004011C4 at /build/.../crt1.c:200
-004011F1 at /build/.../crt1.c:222
-77E892A4 in ?? at ??:0
-@end smallexample
+@item Task Name
+is the name of the task analyzed.
 
-@noindent
-The @code{addr2line} tool has several other useful options:
+@item Stack Size
+is the maximum size for the stack.
 
-@table @code
-@item --functions
-to get the function name corresponding to any location
+@item Actual Use
+is the measure done by the stack analyzer. In order to prevent overflow,
+the stack is not entirely analyzed, and it's not possible to know exactly how
+much has actually been used. The real amount of stack used is between the min
+and max values.
 
-@item --demangle=gnat
-to use the gnat decoding mode for the function names. Note that
-for binutils version 2.9.x the option is simply @option{--demangle}.
 @end table
 
-@smallexample
-$ addr2line --exe=stb --functions --demangle=gnat 0x401373 0x40138b
-   0x40139c 0x401335 0x4011c4 0x4011f1
+@noindent
+The environment task stack, e.g. the stack that contains the main unit, is
+only processed when the environment variable GNAT_STACK_LIMIT is set.
 
-00401373 in stb.p1 at d:/stb/stb.adb:5
-0040138B in stb.p2 at d:/stb/stb.adb:10
-0040139C in stb at d:/stb/stb.adb:14
-00401335 in main at d:/stb/b~stb.adb:104
-004011C4 in <__mingw_CRTStartup> at /build/.../crt1.c:200
-004011F1 in <mainCRTStartup> at /build/.../crt1.c:222
-@end smallexample
+
+@c *********************************
+@c *            GNATCHECK          *
+@c *********************************
+@node Verifying Properties Using gnatcheck
+@chapter Verifying Properties Using @command{gnatcheck}
+@findex gnatcheck
+@cindex @command{gnatcheck}
 
 @noindent
-From this traceback we can see that the exception was raised in
-@file{stb.adb} at line 5, which was reached from a procedure call in
-@file{stb.adb} at line 10, and so on. The @file{b~std.adb} is the binder file,
-which contains the call to the main program.
-@pxref{Running gnatbind}. The remaining entries are assorted runtime routines,
-and the output will vary from platform to platform.
+The @command{gnatcheck} tool is an ASIS-based utility that checks properties
+of Ada source files according to a given set of semantic rules.
+@cindex ASIS
 
-It is also possible to use @code{GDB} with these traceback addresses to debug
-the program. For example, we can break at a given code location, as reported
-in the stack traceback:
+In order to check compliance with a given rule, @command{gnatcheck} has to
+semantically analyze the Ada sources.
+Therefore, checks can only be performed on
+legal Ada units. Moreover, when a unit depends semantically upon units located
+outside the current directory, the source search path has to be provided when
+calling @command{gnatcheck}, either through a specified project file or
+through @command{gnatcheck} switches as described below.
 
-@smallexample
-$ gdb -nw stb
-@ifclear vms
-@noindent
-Furthermore, this feature is not implemented inside Windows DLL. Only
-the non-symbolic traceback is reported in this case.
-@end ifclear
+A number of rules are predefined in @command{gnatcheck} and are described
+later in this chapter.
+You can also add new rules, by modifying the @command{gnatcheck} code and
+rebuilding the tool. In order to add a simple rule making some local checks,
+a small amount of straightforward ASIS-based programming is usually needed.
 
-(gdb) break *0x401373
-Breakpoint 1 at 0x401373: file stb.adb, line 5.
-@end smallexample
+Project support for @command{gnatcheck} is provided by the GNAT
+driver (see @ref{The GNAT Driver and Project Files}).
 
-@noindent
-It is important to note that the stack traceback addresses
-do not change when debug information is included. This is particularly useful
-because it makes it possible to release software without debug information (to
-minimize object size), get a field report that includes a stack traceback
-whenever an internal bug occurs, and then be able to retrieve the sequence
-of calls with the same program compiled with debug information.
+Invoking @command{gnatcheck} on the command line has the form:
 
-@node Tracebacks From Exception Occurrences (non-symbolic)
-@subsubsection Tracebacks From Exception Occurrences
+@smallexample
+$ gnatcheck [@i{switches}]  @{@i{filename}@}
+      [^-files^/FILES^=@{@i{arg_list_filename}@}]
+      [-cargs @i{gcc_switches}] [-rules @i{rule_options}]
+@end smallexample
 
 @noindent
-Non-symbolic tracebacks are obtained by using the @option{-E} binder argument.
-The stack traceback is attached to the exception information string, and can
-be retrieved in an exception handler within the Ada program, by means of the
-Ada95 facilities defined in @code{Ada.Exceptions}. Here is a simple example:
+where
+@itemize @bullet
+@item
+@i{switches} specify the general tool options
 
-@smallexample @c ada
-with Ada.Text_IO;
-with Ada.Exceptions;
+@item
+Each @i{filename} is the name (including the extension) of a source
+file to process. ``Wildcards'' are allowed, and
+the file name may contain path information.
 
-procedure STB is
+@item
+Each @i{arg_list_filename} is the name (including the extension) of a text
+file containing the names of the source files to process, separated by spaces
+or line breaks.
 
-   use Ada;
-   use Ada.Exceptions;
+@item
+@i{gcc_switches} is a list of switches for
+@command{gcc}. They will be passed on to all compiler invocations made by
+@command{gnatcheck} to generate the ASIS trees. Here you can provide
+@option{^-I^/INCLUDE_DIRS=^} switches to form the source search path,
+and use the @option{-gnatec} switch to set the configuration file.
 
-   procedure P1 is
-      K : Positive := 1;
-   begin
-      K := K - 1;
-   exception
-      when E : others =>
-         Text_IO.Put_Line (Exception_Information (E));
-   end P1;
+@item
+@i{rule_options} is a list of options for controlling a set of
+rules to be checked by @command{gnatcheck} (@pxref{gnatcheck Rule Options}).
+@end itemize
 
-   procedure P2 is
-   begin
-      P1;
-   end P2;
+@noindent
+Either a @i{filename} or an @i{arg_list_filename} must be supplied.
 
-begin
-   P2;
-end STB;
-@end smallexample
+@menu
+* Format of the Report File::
+* General gnatcheck Switches::
+* gnatcheck Rule Options::
+* Adding the Results of Compiler Checks to gnatcheck Output::
+* Project-Wide Checks::
+* Predefined Rules::
+@end menu
+
+@node Format of the Report File
+@section Format of the Report File
+@cindex Report file (for @code{gnatcheck})
 
 @noindent
-This program will output:
+The @command{gnatcheck} tool outputs on @file{stdout} all messages concerning
+rule violations.
+It also creates, in the current
+directory, a text file named @file{^gnatcheck.out^GNATCHECK.OUT^} that
+contains the complete report of the last gnatcheck run. This report contains:
+@itemize @bullet
+@item a list of the Ada source files being checked,
+@item a list of enabled and disabled rules,
+@item a list of the diagnostic messages, ordered in three different ways
+and collected in three separate
+sections. Section 1 contains the raw list of diagnostic messages. It
+corresponds to the output going to @file{stdout}. Section 2 contains
+messages ordered by rules.
+Section 3 contains messages ordered by source files.
+@end itemize
 
-@smallexample
-$ stb
+@node General gnatcheck Switches
+@section General @command{gnatcheck} Switches
 
-Exception name: CONSTRAINT_ERROR
-Message: stb.adb:12
-Call stack traceback locations:
-0x4015e4 0x401633 0x401644 0x401461 0x4011c4 0x4011f1 0x77e892a4
-@end smallexample
+@noindent
+The following switches control the general @command{gnatcheck} behavior
 
-@node Tracebacks From Anywhere in a Program (non-symbolic)
-@subsubsection Tracebacks From Anywhere in a Program
+@table @option
+@c !sort!
+@cindex @option{^-a^/ALL^} (@command{gnatcheck})
+@item ^-a^/ALL^
+Process all units including those with read-only ALI files such as
+those from GNAT Run-Time library.
 
-@noindent
-It is also possible to retrieve a stack traceback from anywhere in a
-program. For this you need to
-use the @code{GNAT.Traceback} API. This package includes a procedure called
-@code{Call_Chain} that computes a complete stack traceback, as well as useful
-display procedures described below. It is not necessary to use the
-@option{-E gnatbind} option in this case, because the stack traceback mechanism
-is invoked explicitly.
+@ifclear vms
+@ignore
+@cindex @option{-d} (@command{gnatcheck})
+@item -d
+Debug mode
+@end ignore
 
-@noindent
-In the following example we compute a traceback at a specific location in
-the program, and we display it using @code{GNAT.Debug_Utilities.Image} to
-convert addresses to strings:
+@cindex @option{-dd} (@command{gnatcheck})
+@item -dd
+Progress indicator mode (for use in GPS)
+@end ifclear
 
-@smallexample @c ada
-with Ada.Text_IO;
-with GNAT.Traceback;
-with GNAT.Debug_Utilities;
+@cindex @option{^-h^/HELP^} (@command{gnatcheck})
+@item ^-h^/HELP^
+List the predefined and user-defined rules. For more details see
+@ref{Predefined Rules}.
 
-procedure STB is
+@cindex @option{^-l^/LOCS^} (@command{gnatcheck})
+@item ^-l^/LOCS^
+Use full source locations references in the report file. For a construct from
+a generic instantiation a full source location is a chain from the location
+of this construct in the generic unit to the place where this unit is
+instantiated.
 
-   use Ada;
-   use GNAT;
-   use GNAT.Traceback;
+@cindex @option{^-q^/QUIET^} (@command{gnatcheck})
+@item ^-q^/QUIET^
+Quiet mode. All the diagnoses about rule violations are placed in the
+@command{gnatcheck} report file only, without duplicating in @file{stdout}.
 
-   procedure P1 is
-      TB  : Tracebacks_Array (1 .. 10);
-      --  We are asking for a maximum of 10 stack frames.
-      Len : Natural;
-      --  Len will receive the actual number of stack frames returned.
-   begin
-      Call_Chain (TB, Len);
+@cindex @option{^-s^/SHORT^} (@command{gnatcheck})
+@item ^-s^/SHORT^
+Short format of the report file (no version information, no list of applied
+rules, no list of checked sources is included)
 
-      Text_IO.Put ("In STB.P1 : ");
+@cindex @option{^-s1^/COMPILER_STYLE^} (@command{gnatcheck})
+@item ^-s1^/COMPILER_STYLE^
+Include the compiler-style section in the report file
 
-      for K in 1 .. Len loop
-         Text_IO.Put (Debug_Utilities.Image (TB (K)));
-         Text_IO.Put (' ');
-      end loop;
+@cindex @option{^-s2^/BY_RULES^} (@command{gnatcheck})
+@item ^-s2^/BY_RULES^
+Include the section containing diagnoses ordered by rules in the report file
 
-      Text_IO.New_Line;
-   end P1;
+@cindex @option{^-s3^/BY_FILES_BY_RULES^} (@command{gnatcheck})
+@item ^-s3^/BY_FILES_BY_RULES^
+Include the section containing diagnoses ordered by files and then by rules
+in the report file
 
-   procedure P2 is
-   begin
-      P1;
-   end P2;
+@cindex @option{^-v^/VERBOSE^} (@command{gnatcheck})
+@item ^-v^/VERBOSE^
+Verbose mode; @command{gnatcheck} generates version information and then
+a trace of sources being processed.
 
-begin
-   P2;
-end STB;
-@end smallexample
+@end table
 
-@smallexample
-$ gnatmake -g stb
-$ stb
+@noindent
+Note that if any of the options @option{^-s1^/COMPILER_STYLE^},
+@option{^-s2^/BY_RULES^} or
+@option{^-s3^/BY_FILES_BY_RULES^} is specified,
+then the  @command{gnatcheck} report file will only contain sections
+explicitly denoted by these options.
 
-In STB.P1 : 16#0040_F1E4# 16#0040_14F2# 16#0040_170B# 16#0040_171C#
-16#0040_1461# 16#0040_11C4# 16#0040_11F1# 16#77E8_92A4#
-@end smallexample
+@node gnatcheck Rule Options
+@section @command{gnatcheck} Rule Options
 
 @noindent
-You can then get further information by invoking the @code{addr2line}
-tool as described earlier (note that the hexadecimal addresses
-need to be specified in C format, with a leading ``0x'').
+The following options control the processing performed by
+@command{gnatcheck}.
 
+@table @option
+@cindex @option{+ALL} (@command{gnatcheck})
+@item +ALL
+Turn all the rule checks ON.
+
+@cindex @option{-ALL} (@command{gnatcheck})
+@item -ALL
+Turn all the rule checks OFF.
+
+@cindex @option{+R} (@command{gnatcheck})
+@item +R@i{rule_id[:param]}
+Turn on the check for a specified rule with the specified parameter, if any.
+@i{rule_id} must be the identifier of one of the currently implemented rules
+(use @option{^-h^/HELP^} for the list of implemented rules). Rule identifiers
+are not case-sensitive. The @i{param} item must
+be a string representing a valid parameter(s) for the specified rule.
+If it contains any space characters then this string must be enclosed in
+quotation marks.
+
+@cindex @option{-R} (@command{gnatcheck})
+@item -R@i{rule_id[:param]}
+Turn off the check for a specified rule with the specified parameter, if any.
+
+@cindex @option{-from} (@command{gnatcheck})
+@item -from=@i{rule_option_filename}
+Read the rule options from the text file @i{rule_option_filename}, referred as
+``rule file'' below.
 
-@node Symbolic Traceback
-@subsection Symbolic Traceback
-@cindex traceback, symbolic
+@end table
 
 @noindent
-A symbolic traceback is a stack traceback in which procedure names are
-associated with each code location.
+The default behavior is that all the rule checks are enabled, except for
+the checks performed by the compiler.
+@ignore
+and the checks associated with the
+global rules.
+@end ignore
 
-@noindent
-Note that this feature is not supported on all platforms. See
-@file{GNAT.Traceback.Symbolic spec in g-trasym.ads} for a complete
-list of currently supported platforms.
+A rule file is a text file containing a set of rule options.
+@cindex Rule file (for @code{gnatcheck})
+The file may contain empty lines and Ada-style comments (comment
+lines and end-of-line comments). The rule file has free format; that is,
+you do not have to start a new rule option on a new line.
 
-@noindent
-Note that the symbolic traceback requires that the program be compiled
-with debug information. If it is not compiled with debug information
-only the non-symbolic information will be valid.
+A rule file may contain other @option{-from=@i{rule_option_filename}}
+options, each such option being replaced with the content of the
+corresponding rule file during the rule files processing. In case a
+cycle is detected (that is, @i{rule_file_1} reads rule options from
+@i{rule_file_2}, and  @i{rule_file_2} reads (directly or indirectly)
+rule options from @i{rule_file_1}), the processing
+of rule files is interrupted and a part of their content is ignored.
 
-@menu
-* Tracebacks From Exception Occurrences (symbolic)::
-* Tracebacks From Anywhere in a Program (symbolic)::
-@end menu
 
-@node Tracebacks From Exception Occurrences (symbolic)
-@subsubsection Tracebacks From Exception Occurrences
+@node Adding the Results of Compiler Checks to gnatcheck Output
+@section Adding the Results of Compiler Checks to @command{gnatcheck} Output
 
-@smallexample @c ada
-with Ada.Text_IO;
-with GNAT.Traceback.Symbolic;
-
-procedure STB is
+@noindent
+The @command{gnatcheck} tool can include in the generated diagnostic messages
+and in
+the report file the results of the checks performed by the compiler. Though
+disabled by default, this effect may be obtained by using @option{+R} with
+the following rule identifiers and parameters:
 
-   procedure P1 is
-   begin
-      raise Constraint_Error;
-   end P1;
+@table @option
+@item Restrictions
+To record restrictions violations (that are performed by the compiler if the
+pragma @code{Restrictions} or @code{Restriction_Warnings} are given),
+use the rule named
+@code{Restrictions} with the same parameters as pragma
+@code{Restrictions} or @code{Restriction_Warnings}.
+
+@item Style_Checks
+To record compiler style checks, use the rule named
+@code{Style_Checks}. A parameter of this rule can be either @code{All_Checks},
+which enables all the style checks, or a string that has exactly the same
+structure and semantics as the @code{string_LITERAL} parameter of GNAT pragma
+@code{Style_Checks} (for further information about this pragma, please
+refer to the @cite{@value{EDITION} Reference Manual}).
+
+@item Warnings
+To record compiler warnings (@pxref{Warning Message Control}), use the rule
+named @code{Warnings} with a parameter that is a valid
+@i{static_string_expression} argument of GNAT pragma @code{Warnings}
+(for further information about this pragma, please
+refer to the @cite{@value{EDITION} Reference Manual}).
 
-   procedure P2 is
-   begin
-      P1;
-   end P2;
+@end table
 
-   procedure P3 is
-   begin
-      P2;
-   end P3;
+@node Project-Wide Checks
+@section Project-Wide Checks
+@cindex Project-wide checks (for @command{gnatcheck})
 
-begin
-   P3;
-exception
-   when E : others =>
-      Ada.Text_IO.Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E));
-end STB;
+@noindent
+In order to perform checks on all units of a given project, you can use
+the GNAT driver along with the @option{-P} option:
+@smallexample
+   gnat check -Pproj -rules -from=my_rules
 @end smallexample
 
+@noindent
+If the project @code{proj} depends upon other projects, you can perform
+checks on the project closure using the @option{-U} option:
 @smallexample
-$ gnatmake -g .\stb -bargs -E -largs -lgnat -laddr2line -lintl
-$ stb
-
-0040149F in stb.p1 at stb.adb:8
-004014B7 in stb.p2 at stb.adb:13
-004014CF in stb.p3 at stb.adb:18
-004015DD in ada.stb at stb.adb:22
-00401461 in main at b~stb.adb:168
-004011C4 in __mingw_CRTStartup at crt1.c:200
-004011F1 in mainCRTStartup at crt1.c:222
-77E892A4 in ?? at ??:0
+   gnat check -Pproj -U -rules -from=my_rules
 @end smallexample
 
 @noindent
-In the above example the ``.\'' syntax in the @command{gnatmake} command
-is currently required by @command{addr2line} for files that are in
-the current working directory.
-Moreover, the exact sequence of linker options may vary from platform
-to platform.
-The above @option{-largs} section is for Windows platforms. By contrast,
-under Unix there is no need for the @option{-largs} section.
-Differences across platforms are due to details of linker implementation.
-
-@node Tracebacks From Anywhere in a Program (symbolic)
-@subsubsection Tracebacks From Anywhere in a Program
+Finally, if not all the units are relevant to a particular main
+program in the project closure, you can perform checks for the set
+of units needed to create a given main program (unit closure) using
+the @option{-U} option followed by the name of the main unit:
+@smallexample
+   gnat check -Pproj -U main -rules -from=my_rules
+@end smallexample
 
-@noindent
-It is possible to get a symbolic stack traceback
-from anywhere in a program, just as for non-symbolic tracebacks.
-The first step is to obtain a non-symbolic
-traceback, and then call @code{Symbolic_Traceback} to compute the symbolic
-information. Here is an example:
 
-@smallexample @c ada
-with Ada.Text_IO;
-with GNAT.Traceback;
-with GNAT.Traceback.Symbolic;
+@node Predefined Rules
+@section Predefined Rules
+@cindex Predefined rules (for @command{gnatcheck})
 
-procedure STB is
+@ignore
+@c (Jan 2007) Since the global rules are still under development and are not
+@c documented, there is no point in explaining the difference between
+@c global and local rules
+@noindent
+A rule in @command{gnatcheck} is either local or global.
+A @emph{local rule} is a rule that applies to a well-defined section
+of a program and that can be checked by analyzing only this section.
+A @emph{global rule} requires analysis of some global properties of the
+whole program (mostly related to the program call graph).
+As of @value{NOW}, the implementation of global rules should be
+considered to be at a preliminary stage. You can use the
+@option{+GLOBAL} option to enable all the global rules, and the
+@option{-GLOBAL} rule option to disable all the global rules.
+
+All the global rules in the list below are
+so indicated by marking them ``GLOBAL''.
+This +GLOBAL and -GLOBAL options are not
+included in the list of gnatcheck options above, because at the moment they
+are considered as a temporary debug options.
+
+@command{gnatcheck} performs rule checks for generic
+instances only for global rules.  This limitation may be relaxed in a later
+release.
+@end ignore
 
-   use Ada;
-   use GNAT.Traceback;
-   use GNAT.Traceback.Symbolic;
+@noindent
+The following subsections document the rules implemented in
+@command{gnatcheck}.
+The subsection title is the same as the rule identifier, which may be
+used as a parameter of the @option{+R} or @option{-R} options.
 
-   procedure P1 is
-      TB  : Tracebacks_Array (1 .. 10);
-      --  We are asking for a maximum of 10 stack frames.
-      Len : Natural;
-      --  Len will receive the actual number of stack frames returned.
-   begin
-      Call_Chain (TB, Len);
-      Text_IO.Put_Line (Symbolic_Traceback (TB (1 .. Len)));
-   end P1;
 
-   procedure P2 is
-   begin
-      P1;
-   end P2;
+@menu
+* Abstract_Type_Declarations::
+* Anonymous_Arrays::
+* Anonymous_Subtypes::
+* Blocks::
+* Boolean_Relational_Operators::
+@ignore
+* Ceiling_Violations::
+@end ignore
+* Controlled_Type_Declarations::
+* Declarations_In_Blocks::
+* Default_Parameters::
+* Discriminated_Records::
+* Enumeration_Ranges_In_CASE_Statements::
+* Exceptions_As_Control_Flow::
+* EXIT_Statements_With_No_Loop_Name::
+* Expanded_Loop_Exit_Names::
+* Explicit_Full_Discrete_Ranges::
+* Float_Equality_Checks::
+* Forbidden_Pragmas::
+* Function_Style_Procedures::
+* Generics_In_Subprograms::
+* GOTO_Statements::
+* Implicit_IN_Mode_Parameters::
+* Implicit_SMALL_For_Fixed_Point_Types::
+* Improperly_Located_Instantiations::
+* Improper_Returns::
+* Library_Level_Subprograms::
+* Local_Packages::
+@ignore
+* Improperly_Called_Protected_Entries::
+@end ignore
+* Misnamed_Identifiers::
+* Multiple_Entries_In_Protected_Definitions::
+* Name_Clashes::
+* Non_Qualified_Aggregates::
+* Non_Short_Circuit_Operators::
+* Non_SPARK_Attributes::
+* Non_Tagged_Derived_Types::
+* Non_Visible_Exceptions::
+* Numeric_Literals::
+* OTHERS_In_Aggregates::
+* OTHERS_In_CASE_Statements::
+* OTHERS_In_Exception_Handlers::
+* Outer_Loop_Exits::
+* Overloaded_Operators::
+* Overly_Nested_Control_Structures::
+* Parameters_Out_Of_Order::
+* Positional_Actuals_For_Defaulted_Generic_Parameters::
+* Positional_Actuals_For_Defaulted_Parameters::
+* Positional_Components::
+* Positional_Generic_Parameters::
+* Positional_Parameters::
+* Predefined_Numeric_Types::
+* Raising_External_Exceptions::
+* Raising_Predefined_Exceptions::
+@ignore
+* Recursion::
+* Side_Effect_Functions::
+@end ignore
+* Slices::
+* Unassigned_OUT_Parameters::
+* Uncommented_BEGIN_In_Package_Bodies::
+* Unconstrained_Array_Returns::
+* Universal_Ranges::
+* Unnamed_Blocks_And_Loops::
+@ignore
+* Unused_Subprograms::
+@end ignore
+* USE_PACKAGE_Clauses::
+* Volatile_Objects_Without_Address_Clauses::
+@end menu
 
-begin
-   P2;
-end STB;
-@end smallexample
 
-@ifset vms
-@node Compatibility with DEC Ada
-@chapter Compatibility with DEC Ada
-@cindex Compatibility
+@node Abstract_Type_Declarations
+@subsection @code{Abstract_Type_Declarations}
+@cindex @code{Abstract_Type_Declarations} rule (for @command{gnatcheck})
 
 @noindent
-This section of the manual compares DEC Ada for OpenVMS Alpha and GNAT
-OpenVMS Alpha. GNAT achieves a high level of compatibility
-with DEC Ada, and it should generally be straightforward to port code
-from the DEC Ada environment to GNAT. However, there are a few language
-and implementation differences of which the user must be aware. These
-differences are discussed in this section. In
-addition, the operating environment and command structure for the
-compiler are different, and these differences are also discussed.
+Flag all declarations of abstract types. For an abstract private
+type, both the private and full type declarations are flagged.
 
-Note that this discussion addresses specifically the implementation
-of Ada 83 for DIGITAL OpenVMS Alpha Systems. In cases where the implementation
-of DEC Ada differs between OpenVMS Alpha Systems and OpenVMS VAX Systems,
-GNAT always follows the Alpha implementation.
+This rule has no parameters.
 
-@menu
-* Ada 95 Compatibility::
-* Differences in the Definition of Package System::
-* Language-Related Features::
-* The Package STANDARD::
-* The Package SYSTEM::
-* Tasking and Task-Related Features::
-* Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems::
-* Pragmas and Pragma-Related Features::
-* Library of Predefined Units::
-* Bindings::
-* Main Program Definition::
-* Implementation-Defined Attributes::
-* Compiler and Run-Time Interfacing::
-* Program Compilation and Library Management::
-* Input-Output::
-* Implementation Limits::
-* Tools::
-@end menu
 
-@node Ada 95 Compatibility
-@section Ada 95 Compatibility
+@node Anonymous_Arrays
+@subsection @code{Anonymous_Arrays}
+@cindex @code{Anonymous_Arrays} rule (for @command{gnatcheck})
 
 @noindent
-GNAT is an Ada 95 compiler, and DEC Ada is an Ada 83
-compiler. Ada 95 is almost completely upwards compatible
-with Ada 83, and therefore Ada 83 programs will compile
-and run under GNAT with
-no changes or only minor changes. The Ada 95 Reference
-Manual (ANSI/ISO/IEC-8652:1995) provides details on specific
-incompatibilities.
+Flag all anonymous array type definitions (by Ada semantics these can only
+occur in object declarations).
 
-GNAT provides the switch /83 on the GNAT COMPILE command,
-as well as the pragma ADA_83, to force the compiler to
-operate in Ada 83 mode. This mode does not guarantee complete
-conformance to Ada 83, but in practice is sufficient to
-eliminate most sources of incompatibilities.
-In particular, it eliminates the recognition of the
-additional Ada 95 keywords, so that their use as identifiers
-in Ada83 program is legal, and handles the cases of packages
-with optional bodies, and generics that instantiate unconstrained
-types without the use of @code{(<>)}.
+This rule has no parameters.
 
-@node Differences in the Definition of Package System
-@section Differences in the Definition of Package System
+@node Anonymous_Subtypes
+@subsection @code{Anonymous_Subtypes}
+@cindex @code{Anonymous_Subtypes} rule (for @command{gnatcheck})
 
 @noindent
-Both the Ada 95 and Ada 83 reference manuals permit a compiler to add
-implementation-dependent declarations to package System. In normal mode,
-GNAT does not take advantage of this permission, and the version of System
-provided by GNAT exactly matches that in the Ada 95 Reference Manual.
+Flag all uses of anonymous subtypes. A use of an anonymous subtype is
+any instance of a subtype indication with a constraint, other than one
+that occurs immediately within a subtype declaration. Any use of a range
+other than as a constraint used immediately within a subtype declaration
+is considered as an anonymous subtype.
 
-However, DEC Ada adds an extensive set of declarations to package System,
-as fully documented in the DEC Ada manuals. To minimize changes required
-for programs that make use of these extensions, GNAT provides the pragma
-Extend_System for extending the definition of package System. By using:
+An effect of this rule is that @code{for} loops such as the following are
+flagged (since @code{1..N} is formally a ``range''):
 
 @smallexample @c ada
-@group
-@cartouche
-pragma Extend_System (Aux_DEC);
-@end cartouche
-@end group
+for I in 1 .. N loop
+   @dots{}
+end loop;
 @end smallexample
 
 @noindent
-The set of definitions in System is extended to include those in package
-@code{System.Aux_DEC}.
-These definitions are incorporated directly into package
-System, as though they had been declared there in the first place. For a
-list of the declarations added, see the specification of this package,
-which can be found in the file @code{s-auxdec.ads} in the GNAT library.
-The pragma Extend_System is a configuration pragma, which means that
-it can be placed in the file @file{gnat.adc}, so that it will automatically
-apply to all subsequent compilations. See the section on Configuration
-Pragmas for further details.
-
-An alternative approach that avoids the use of the non-standard
-Extend_System pragma is to add a context clause to the unit that
-references these facilities:
+Declaring an explicit subtype solves the problem:
 
 @smallexample @c ada
-@group
-@cartouche
-with System.Aux_DEC;
-use  System.Aux_DEC;
-@end cartouche
-@end group
+subtype S is Integer range 1..N;
+@dots{}
+for I in S loop
+   @dots{}
+end loop;
 @end smallexample
 
 @noindent
-The effect is not quite semantically identical to incorporating
-the declarations directly into package @code{System},
-but most programs will not notice a difference
-unless they use prefix notation (e.g. @code{System.Integer_8})
-to reference the
-entities directly in package @code{System}.
-For units containing such references,
-the prefixes must either be removed, or the pragma @code{Extend_System}
-must be used.
+This rule has no parameters.
 
-@node Language-Related Features
-@section Language-Related Features
+@node Blocks
+@subsection @code{Blocks}
+@cindex @code{Blocks} rule (for @command{gnatcheck})
 
 @noindent
-The following sections highlight differences in types,
-representations of types, operations, alignment, and
-related topics.
+Flag each block statement.
 
-@menu
-* Integer Types and Representations::
-* Floating-Point Types and Representations::
-* Pragmas Float_Representation and Long_Float::
-* Fixed-Point Types and Representations::
-* Record and Array Component Alignment::
-* Address Clauses::
-* Other Representation Clauses::
-@end menu
+This rule has no parameters.
 
-@node Integer Types and Representations
-@subsection Integer Types and Representations
+@node Boolean_Relational_Operators
+@subsection @code{Boolean_Relational_Operators}
+@cindex @code{Boolean_Relational_Operators} rule (for @command{gnatcheck})
 
 @noindent
-The set of predefined integer types is identical in DEC Ada and GNAT.
-Furthermore the representation of these integer types is also identical,
-including the capability of size clauses forcing biased representation.
+Flag each call to a predefined relational operator (``<'', ``>'', ``<='',
+``>='', ``='' and ``/='') for the predefined Boolean type.
+(This rule is useful in enforcing the SPARK language restrictions.)
 
-In addition,
-DEC Ada for OpenVMS Alpha systems has defined the
-following additional integer types in package System:
+Calls to predefined relational operators of any type derived from
+@code{Standard.Boolean} are not detected.  Calls to user-defined functions
+with these designators, and uses of operators that are renamings
+of the predefined relational operators for @code{Standard.Boolean},
+are likewise not detected.
 
-@itemize @bullet
+This rule has no parameters.
 
-@item
-INTEGER_8
+@ignore
+@node Ceiling_Violations
+@subsection @code{Ceiling_Violations} (under construction, GLOBAL)
+@cindex @code{Ceiling_Violations} rule (for @command{gnatcheck})
 
-@item
-INTEGER_16
+@noindent
+Flag invocations of a protected operation by a task whose priority exceeds
+the protected object's ceiling.
+
+As of @value{NOW}, this rule has the following limitations:
+
+@itemize @bullet
 
 @item
-INTEGER_32
+ We consider only pragmas Priority and Interrupt_Priority as means to define
+  a task/protected operation priority. We do not consider the effect of using
+  Ada.Dynamic_Priorities.Set_Priority procedure;
 
 @item
-INTEGER_64
+ We consider only base task priorities, and no priority inheritance. That is,
+  we do not make a difference between calls issued during task activation and
+  execution of the sequence of statements from task body;
 
 @item
-LARGEST_INTEGER
+ Any situation when the priority of protected operation caller is set by a
+  dynamic expression (that is, the corresponding Priority or
+  Interrupt_Priority pragma has a non-static expression as an argument) we
+  treat as a priority inconsistency (and, therefore, detect this situation).
 @end itemize
 
 @noindent
-When using GNAT, the first four of these types may be obtained from the
-standard Ada 95 package @code{Interfaces}.
-Alternatively, by use of the pragma
-@code{Extend_System}, identical
-declarations can be referenced directly in package @code{System}.
-On both GNAT and DEC Ada, the maximum integer size is 64 bits.
+At the moment the notion of the main subprogram is not implemented in
+gnatcheck, so any pragma Priority in a library level subprogram body (in case
+if this subprogram can be a main subprogram of a partition) changes the
+priority of an environment task. So if we have more then one such pragma in
+the set of processed sources, the pragma that is processed last, defines the
+priority of an environment task.
 
-@node Floating-Point Types and Representations
-@subsection Floating-Point Types and Representations
-@cindex Floating-Point types
+This rule has no parameters.
+@end ignore
+
+@node Controlled_Type_Declarations
+@subsection @code{Controlled_Type_Declarations}
+@cindex @code{Controlled_Type_Declarations} rule (for @command{gnatcheck})
 
 @noindent
-The set of predefined floating-point types is identical in DEC Ada and GNAT.
-Furthermore the representation of these floating-point
-types is also identical. One important difference is that the default
-representation for DEC Ada is VAX_Float, but the default representation
-for GNAT is IEEE.
+Flag all declarations of controlled types. A declaration of a private type
+is flagged if its full declaration declares a controlled type. A declaration
+of a derived type is flagged if its ancestor type is controlled. Subtype
+declarations are not checked. A declaration of a type that itself is not a
+descendant of a type declared in @code{Ada.Finalization} but has a controlled
+component is not checked.
+
+This rule has no parameters.
 
-Specific types may be declared to be VAX_Float or IEEE, using the pragma
-@code{Float_Representation} as described in the DEC Ada documentation.
-For example, the declarations:
 
-@smallexample @c ada
-@group
-@cartouche
-type F_Float is digits 6;
-pragma Float_Representation (VAX_Float, F_Float);
-@end cartouche
-@end group
-@end smallexample
+
+@node Declarations_In_Blocks
+@subsection @code{Declarations_In_Blocks}
+@cindex @code{Declarations_In_Blocks} rule (for @command{gnatcheck})
 
 @noindent
-declare a type F_Float that will be represented in VAX_Float format.
-This set of declarations actually appears in System.Aux_DEC, which provides
-the full set of additional floating-point declarations provided in
-the DEC Ada version of package
-System. This and similar declarations may be accessed in a user program
-by using pragma @code{Extend_System}. The use of this
-pragma, and the related pragma @code{Long_Float} is described in further
-detail in the following section.
+Flag all block statements containing local declarations. A @code{declare}
+block with an empty @i{declarative_part} or with a @i{declarative part}
+containing only pragmas and/or @code{use} clauses is not flagged.
 
-@node Pragmas Float_Representation and Long_Float
-@subsection Pragmas Float_Representation and Long_Float
+This rule has no parameters.
+
+
+@node Default_Parameters
+@subsection @code{Default_Parameters}
+@cindex @code{Default_Parameters} rule (for @command{gnatcheck})
 
 @noindent
-DEC Ada provides the pragma @code{Float_Representation}, which
-acts as a program library switch to allow control over
-the internal representation chosen for the predefined
-floating-point types declared in the package @code{Standard}.
-The format of this pragma is as follows:
+Flag all default expressions for subprogram parameters. Parameter
+declarations of formal and generic subprograms are also checked.
 
-@smallexample
-@group
-@cartouche
-@b{pragma} @code{Float_Representation}(VAX_Float | IEEE_Float);
-@end cartouche
-@end group
-@end smallexample
+This rule has no parameters.
+
+
+@node Discriminated_Records
+@subsection @code{Discriminated_Records}
+@cindex @code{Discriminated_Records} rule (for @command{gnatcheck})
 
 @noindent
-This pragma controls the representation of floating-point
-types as follows:
+Flag all declarations of record types with discriminants. Only the
+declarations of record and record extension types are checked. Incomplete,
+formal, private, derived and private extension type declarations are not
+checked. Task and protected type declarations also are not checked.
 
-@itemize @bullet
-@item
-@code{VAX_Float} specifies that floating-point
-types are represented by default with the VAX hardware types
-F-floating, D-floating, G-floating. Note that the H-floating
-type is available only on DIGITAL Vax systems, and is not available
-in either DEC Ada or GNAT for Alpha systems.
+This rule has no parameters.
 
-@item
-@code{IEEE_Float} specifies that floating-point
-types are represented by default with the IEEE single and
-double floating-point types.
-@end itemize
+
+@node Enumeration_Ranges_In_CASE_Statements
+@subsection @code{Enumeration_Ranges_In_CASE_Statements}
+@cindex @code{Enumeration_Ranges_In_CASE_Statements} (for @command{gnatcheck})
 
 @noindent
-GNAT provides an identical implementation of the pragma
-@code{Float_Representation}, except that it functions as a
-configuration pragma, as defined by Ada 95. Note that the
-notion of configuration pragma corresponds closely to the
-DEC Ada notion of a program library switch.
+Flag each use of a range of enumeration literals as a choice in a
+@code{case} statement.
+All forms for specifying a range (explicit ranges
+such as @code{A .. B}, subtype marks and @code{'Range} attributes) are flagged.
+An enumeration range is
+flagged even if contains exactly one enumeration value or no values at all. A
+type derived from an enumeration type is considered as an enumeration type.
 
-When no pragma is used in GNAT, the default is IEEE_Float, which is different
-from DEC Ada 83, where the default is VAX_Float. In addition, the
-predefined libraries in GNAT are built using IEEE_Float, so it is not
-advisable to change the format of numbers passed to standard library
-routines, and if necessary explicit type conversions may be needed.
+This rule helps prevent maintenance problems arising from adding an
+enumeration value to a type and having it implicitly handled by an existing
+@code{case} statement with an enumeration range that includes the new literal.
 
-The use of IEEE_Float is recommended in GNAT since it is more efficient,
-and (given that it conforms to an international standard) potentially more
-portable. The situation in which VAX_Float may be useful is in interfacing
-to existing code and data that expects the use of VAX_Float. There are
-two possibilities here. If the requirement for the use of VAX_Float is
-localized, then the best approach is to use the predefined VAX_Float
-types in package @code{System}, as extended by
-@code{Extend_System}. For example, use @code{System.F_Float}
-to specify the 32-bit @code{F-Float} format.
+This rule has no parameters.
 
-Alternatively, if an entire program depends heavily on the use of
-the @code{VAX_Float} and in particular assumes that the types in
-package @code{Standard} are in @code{Vax_Float} format, then it
-may be desirable to reconfigure GNAT to assume Vax_Float by default.
-This is done by using the GNAT LIBRARY command to rebuild the library, and
-then using the general form of the @code{Float_Representation}
-pragma to ensure that this default format is used throughout.
-The form of the GNAT LIBRARY command is:
 
-@smallexample
-GNAT LIBRARY /CONFIG=@i{file} /CREATE=@i{directory}
-@end smallexample
+@node Exceptions_As_Control_Flow
+@subsection @code{Exceptions_As_Control_Flow}
+@cindex @code{Exceptions_As_Control_Flow} (for @command{gnatcheck})
 
 @noindent
-where @i{file} contains the new configuration pragmas
-and @i{directory} is the directory to be created to contain
-the new library.
+Flag each place where an exception is explicitly raised and handled in the
+same subprogram body. A @code{raise} statement in an exception handler,
+package body, task body or entry body is not flagged.
+
+The rule has no parameters.
+
+@node EXIT_Statements_With_No_Loop_Name
+@subsection @code{EXIT_Statements_With_No_Loop_Name}
+@cindex @code{EXIT_Statements_With_No_Loop_Name} (for @command{gnatcheck})
 
 @noindent
-On OpenVMS systems, DEC Ada provides the pragma @code{Long_Float}
-to allow control over the internal representation chosen
-for the predefined type @code{Long_Float} and for floating-point
-type declarations with digits specified in the range 7 .. 15.
-The format of this pragma is as follows:
+Flag each @code{exit} statement that does not specify the name of the loop
+being exited.
 
-@smallexample @c ada
-@cartouche
-pragma Long_Float (D_FLOAT | G_FLOAT);
-@end cartouche
-@end smallexample
+The rule has no parameters.
 
-@node Fixed-Point Types and Representations
-@subsection Fixed-Point Types and Representations
+
+@node Expanded_Loop_Exit_Names
+@subsection @code{Expanded_Loop_Exit_Names}
+@cindex @code{Expanded_Loop_Exit_Names} rule (for @command{gnatcheck})
 
 @noindent
-On DEC Ada for OpenVMS Alpha systems, rounding is
-away from zero for both positive and negative numbers.
-Therefore, +0.5 rounds to 1 and -0.5 rounds to -1.
+Flag all expanded loop names in @code{exit} statements.
 
-On GNAT for OpenVMS Alpha, the results of operations
-on fixed-point types are in accordance with the Ada 95
-rules. In particular, results of operations on decimal
-fixed-point types are truncated.
+This rule has no parameters.
 
-@node Record and Array Component Alignment
-@subsection Record and Array Component Alignment
+@node Explicit_Full_Discrete_Ranges
+@subsection @code{Explicit_Full_Discrete_Ranges}
+@cindex @code{Explicit_Full_Discrete_Ranges} rule (for @command{gnatcheck})
 
 @noindent
-On DEC Ada for OpenVMS Alpha, all non composite components
-are aligned on natural boundaries. For example, 1-byte
-components are aligned on byte boundaries, 2-byte
-components on 2-byte boundaries, 4-byte components on 4-byte
-byte boundaries, and so on. The OpenVMS Alpha hardware
-runs more efficiently with naturally aligned data.
+Flag each discrete range that has the form @code{A'First .. A'Last}.
 
-ON GNAT for OpenVMS Alpha, alignment rules are compatible
-with DEC Ada for OpenVMS Alpha.
+This rule has no parameters.
 
-@node Address Clauses
-@subsection Address Clauses
+@node Float_Equality_Checks
+@subsection @code{Float_Equality_Checks}
+@cindex @code{Float_Equality_Checks} rule (for @command{gnatcheck})
 
 @noindent
-In DEC Ada and GNAT, address clauses are supported for
-objects and imported subprograms.
-The predefined type @code{System.Address} is a private type
-in both compilers, with the same representation (it is simply
-a machine pointer). Addition, subtraction, and comparison
-operations are available in the standard Ada 95 package
-@code{System.Storage_Elements}, or in package @code{System}
-if it is extended to include @code{System.Aux_DEC} using a
-pragma @code{Extend_System} as previously described.
+Flag all calls to the predefined equality operations for floating-point types.
+Both ``@code{=}'' and ``@code{/=}'' operations are checked.
+User-defined equality operations are not flagged, nor are ``@code{=}''
+and ``@code{/=}'' operations for fixed-point types.
 
-Note that code that with's both this extended package @code{System}
-and the package @code{System.Storage_Elements} should not @code{use}
-both packages, or ambiguities will result. In general it is better
-not to mix these two sets of facilities. The Ada 95 package was
-designed specifically to provide the kind of features that DEC Ada
-adds directly to package @code{System}.
+This rule has no parameters.
 
-GNAT is compatible with DEC Ada in its handling of address
-clauses, except for some limitations in
-the form of address clauses for composite objects with
-initialization. Such address clauses are easily replaced
-by the use of an explicitly-defined constant as described
-in the Ada 95 Reference Manual (13.1(22)). For example, the sequence
-of declarations:
 
-@smallexample @c ada
-@cartouche
-X, Y : Integer := Init_Func;
-Q : String (X .. Y) := "abc";
-...
-for Q'Address use Compute_Address;
-@end cartouche
-@end smallexample
+@node Forbidden_Pragmas
+@subsection @code{Forbidden_Pragmas}
+@cindex @code{Forbidden_Pragmas} rule (for @command{gnatcheck})
 
 @noindent
-will be rejected by GNAT, since the address cannot be computed at the time
-that Q is declared. To achieve the intended effect, write instead:
+Flag each use of the specified pragmas.  The pragmas to be detected
+are named in the rule's  parameters.
 
-@smallexample @c ada
-@group
-@cartouche
-X, Y : Integer := Init_Func;
-Q_Address : constant Address := Compute_Address;
-Q : String (X .. Y) := "abc";
-...
-for Q'Address use Q_Address;
-@end cartouche
-@end group
-@end smallexample
+This rule has the following parameters:
 
-@noindent
-which will be accepted by GNAT (and other Ada 95 compilers), and is also
-backwards compatible with Ada 83. A fuller description of the restrictions
-on address specifications is found in the GNAT Reference Manual.
+@itemize @bullet
+@item For the @option{+R} option
 
-@node Other Representation Clauses
-@subsection Other Representation Clauses
+@table @asis
+@item @emph{Pragma_Name}
+Adds the specified pragma to the set of pragmas to be
+checked and sets the checks for all the specified pragmas
+ON. @emph{Pragma_Name} is treated as a name of a pragma. If it
+does not correspond to any pragma name defined in the Ada
+standard or to the name of a GNAT-specific pragma defined
+in the GNAT Reference Manual, it is treated as the name of
+unknown pragma.
+
+@item @code{GNAT}
+All the GNAT-specific pragmas are detected; this sets
+the checks for all the specified pragmas ON.
+
+@item @code{ALL}
+All pragmas are detected; this sets the rule ON.
+@end table
+
+@item For the @option{-R} option
+@table @asis
+@item @emph{Pragma_Name}
+Removes the specified pragma from the set of pragmas to be
+checked without affecting checks for
+other pragmas. @emph{Pragma_Name} is treated as a name
+of a pragma. If it does not correspond to any pragma
+defined in the Ada standard or to any name defined in the
+GNAT Reference Manual,
+this option is treated as turning OFF detection of all
+unknown pragmas.
+
+@item GNAT
+Turn OFF detection of all GNAT-specific pragmas
+
+@item ALL
+Clear the list of the pragmas to be detected and
+turn the rule OFF.
+@end table
+@end itemize
 
 @noindent
-GNAT supports in a compatible manner all the representation
-clauses supported by DEC Ada. In addition, it
-supports representation clause forms that are new in Ada 95
-including COMPONENT_SIZE and SIZE clauses for objects.
+Parameters are not case sensitive. If @emph{Pragma_Name} does not have
+the syntax of an Ada identifier and therefore can not be considered
+as a pragma name, a diagnostic message is generated and the corresponding
+parameter is ignored.
+
+When more then one parameter is given in the same rule option, the parameters
+must be separated by a comma.
+
+If more then one option for this rule is specified for the @command{gnatcheck}
+call, a new option overrides the previous one(s).
+
+The @option{+R} option with no parameters turns the rule ON with the set of
+pragmas to be detected defined by the previous rule options.
+(By default this set is empty, so if the only option specified for the rule is
+@option{+RForbidden_Pragmas} (with
+no parameter), then the rule is enabled, but it does not detect anything).
+The @option{-R} option with no parameter turns the rule OFF, but it does not
+affect the set of pragmas to be detected.
+
+
 
-@node The Package STANDARD
-@section The Package STANDARD
+
+@node Function_Style_Procedures
+@subsection @code{Function_Style_Procedures}
+@cindex @code{Function_Style_Procedures} rule (for @command{gnatcheck})
 
 @noindent
-The package STANDARD, as implemented by DEC Ada, is fully
-described in the Reference Manual for the Ada Programming
-Language (ANSI/MIL-STD-1815A-1983) and in the DEC Ada
-Language Reference Manual. As implemented by GNAT, the
-package STANDARD is described in the Ada 95 Reference
-Manual.
+Flag each procedure that can be rewritten as a function. A procedure can be
+converted into a function if it has exactly one parameter of mode @code{out}
+and no parameters of mode @code{in out}. Procedure declarations,
+formal procedure declarations, and generic procedure declarations are always
+checked. Procedure
+bodies and body stubs are flagged only if they do not have corresponding
+separate declarations. Procedure renamings and procedure instantiations are
+not flagged.
 
-In addition, DEC Ada supports the Latin-1 character set in
-the type CHARACTER. GNAT supports the Latin-1 character set
-in the type CHARACTER and also Unicode (ISO 10646 BMP) in
-the type WIDE_CHARACTER.
+If a procedure can be rewritten as a function, but its @code{out} parameter is
+of a limited type, it is not flagged.
 
-The floating-point types supported by GNAT are those
-supported by DEC Ada, but defaults are different, and are controlled by
-pragmas. See @pxref{Floating-Point Types and Representations} for details.
+Protected procedures are not flagged. Null procedures also are not flagged.
+
+This rule has no parameters.
 
-@node The Package SYSTEM
-@section The Package SYSTEM
+
+@node Generics_In_Subprograms
+@subsection @code{Generics_In_Subprograms}
+@cindex @code{Generics_In_Subprograms} rule (for @command{gnatcheck})
 
 @noindent
-DEC Ada provides a system-specific version of the package
-SYSTEM for each platform on which the language ships.
-For the complete specification of the package SYSTEM, see
-Appendix F of the DEC Ada Language Reference Manual.
+Flag each declaration of a generic unit in a subprogram. Generic
+declarations in the bodies of generic subprograms are also flagged.
+A generic unit nested in another generic unit is not flagged.
+If a generic unit is
+declared in a local package that is declared in a subprogram body, the
+generic unit is flagged.
 
-On DEC Ada, the package SYSTEM includes the following conversion functions:
-@itemize @bullet
-@item TO_ADDRESS(INTEGER)
+This rule has no parameters.
 
-@item  TO_ADDRESS(UNSIGNED_LONGWORD)
 
-@item  TO_ADDRESS(universal_integer)
+@node GOTO_Statements
+@subsection @code{GOTO_Statements}
+@cindex @code{GOTO_Statements} rule (for @command{gnatcheck})
 
-@item  TO_INTEGER(ADDRESS)
+@noindent
+Flag each occurrence of a @code{goto} statement.
 
-@item  TO_UNSIGNED_LONGWORD(ADDRESS)
+This rule has no parameters.
 
-@item  Function IMPORT_VALUE return UNSIGNED_LONGWORD and the
-                 functions IMPORT_ADDRESS and IMPORT_LARGEST_VALUE
-@end itemize
+
+@node Implicit_IN_Mode_Parameters
+@subsection @code{Implicit_IN_Mode_Parameters}
+@cindex @code{Implicit_IN_Mode_Parameters} rule (for @command{gnatcheck})
 
 @noindent
-By default, GNAT supplies a version of SYSTEM that matches
-the definition given in the Ada 95 Reference Manual.
-This
-is a subset of the DIGITAL system definitions, which is as
-close as possible to the original definitions. The only difference
-is that the definition of SYSTEM_NAME is different:
+Flag each occurrence of a formal parameter with an implicit @code{in} mode.
+Note that @code{access} parameters, although they technically behave
+like @code{in} parameters, are not flagged.
+
+This rule has no parameters.
 
-@smallexample @c ada
-@group
-@cartouche
-type Name is (SYSTEM_NAME_GNAT);
-System_Name : constant Name := SYSTEM_NAME_GNAT;
-@end cartouche
-@end group
-@end smallexample
+
+@node Implicit_SMALL_For_Fixed_Point_Types
+@subsection @code{Implicit_SMALL_For_Fixed_Point_Types}
+@cindex @code{Implicit_SMALL_For_Fixed_Point_Types} rule (for @command{gnatcheck})
 
 @noindent
-Also, GNAT adds the new Ada 95 declarations for
-BIT_ORDER and DEFAULT_BIT_ORDER.
+Flag each fixed point type declaration that lacks an explicit
+representation  clause to define its @code{'Small} value.
+Since @code{'Small} can be  defined only for ordinary fixed point types,
+decimal fixed point type declarations are not checked.
 
-However, the use of the following pragma causes GNAT
-to extend the definition of package SYSTEM so that it
-encompasses the full set of DIGITAL-specific extensions,
-including the functions listed above:
+This rule has no parameters.
 
-@smallexample @c ada
-@cartouche
-pragma Extend_System (Aux_DEC);
-@end cartouche
-@end smallexample
+
+@node Improperly_Located_Instantiations
+@subsection @code{Improperly_Located_Instantiations}
+@cindex @code{Improperly_Located_Instantiations} rule (for @command{gnatcheck})
 
 @noindent
-The pragma Extend_System is a configuration pragma that
-is most conveniently placed in the @file{gnat.adc} file. See the
-GNAT Reference Manual for further details.
+Flag all generic instantiations in library-level package specifications
+(including library generic packages) and in all subprogram bodies.
 
-DEC Ada does not allow the recompilation of the package
-SYSTEM. Instead DEC Ada provides several pragmas (SYSTEM_
-NAME, STORAGE_UNIT, and MEMORY_SIZE) to modify values in
-the package SYSTEM. On OpenVMS Alpha systems, the pragma
-SYSTEM_NAME takes the enumeration literal OPENVMS_AXP as
-its single argument.
+Instantiations in task and entry bodies are not flagged. Instantiations in the
+bodies of protected subprograms are flagged.
 
-GNAT does permit the recompilation of package SYSTEM using
-a special switch (@option{-gnatg}) and this switch can be used if
-it is necessary to modify the definitions in SYSTEM. GNAT does
-not permit the specification of SYSTEM_NAME, STORAGE_UNIT
-or MEMORY_SIZE by any other means.
+This rule has no parameters.
 
-On GNAT systems, the pragma SYSTEM_NAME takes the
-enumeration literal SYSTEM_NAME_GNAT.
 
-The definitions provided by the use of
 
-@smallexample @c ada
-pragma Extend_System (AUX_Dec);
-@end smallexample
+@node Improper_Returns
+@subsection @code{Improper_Returns}
+@cindex @code{Improper_Returns} rule (for @command{gnatcheck})
 
 @noindent
-are virtually identical to those provided by the DEC Ada 83 package
-System. One important difference is that the name of the TO_ADDRESS
-function for type UNSIGNED_LONGWORD is changed to TO_ADDRESS_LONG.
-See the GNAT Reference manual for a discussion of why this change was
-necessary.
+Flag each explicit @code{return} statement in procedures, and
+multiple @code{return} statements in functions.
+Diagnostic messages are generated for all @code{return} statements
+in a procedure (thus each procedure must be written so that it
+returns implicitly at the end of its statement part),
+and for all @code{return} statements in a function after the first one.
+This rule supports the stylistic convention that each subprogram
+should have no more than one point of normal return.
 
-@noindent
-The version of TO_ADDRESS taking a universal integer argument is in fact
-an extension to Ada 83 not strictly compatible with the reference manual.
-In GNAT, we are constrained to be exactly compatible with the standard,
-and this means we cannot provide this capability. In DEC Ada 83, the
-point of this definition is to deal with a call like:
+This rule has no parameters.
 
-@smallexample @c ada
-TO_ADDRESS (16#12777#);
-@end smallexample
+
+@node Library_Level_Subprograms
+@subsection @code{Library_Level_Subprograms}
+@cindex @code{Library_Level_Subprograms} rule (for @command{gnatcheck})
 
 @noindent
-Normally, according to the Ada 83 standard, one would expect this to be
-ambiguous, since it matches both the INTEGER and UNSIGNED_LONGWORD forms
-of TO_ADDRESS. However, in DEC Ada 83, there is no ambiguity, since the
-definition using universal_integer takes precedence.
+Flag all library-level subprograms (including generic subprogram instantiations).
 
-In GNAT, since the version with universal_integer cannot be supplied, it is
-not possible to be 100% compatible. Since there are many programs using
-numeric constants for the argument to TO_ADDRESS, the decision in GNAT was
-to change the name of the function in the UNSIGNED_LONGWORD case, so the
-declarations provided in the GNAT version of AUX_Dec are:
+This rule has no parameters.
 
-@smallexample @c ada
-function To_Address (X : Integer) return Address;
-pragma Pure_Function (To_Address);
 
-function To_Address_Long (X : Unsigned_Longword) return Address;
-pragma Pure_Function (To_Address_Long);
-@end smallexample
+@node Local_Packages
+@subsection @code{Local_Packages}
+@cindex @code{Local_Packages} rule (for @command{gnatcheck})
 
 @noindent
-This means that programs using TO_ADDRESS for UNSIGNED_LONGWORD must
-change the name to TO_ADDRESS_LONG.
+Flag all local packages declared in package and generic package
+specifications.
+Local packages in bodies are not flagged.
 
-@node Tasking and Task-Related Features
-@section Tasking and Task-Related Features
+This rule has no parameters.
+
+@ignore
+@node Improperly_Called_Protected_Entries
+@subsection @code{Improperly_Called_Protected_Entries} (under construction, GLOBAL)
+@cindex @code{Improperly_Called_Protected_Entries} rule (for @command{gnatcheck})
 
 @noindent
-The concepts relevant to a comparison of tasking on GNAT
-and on DEC Ada for OpenVMS Alpha systems are discussed in
-the following sections.
+Flag each protected entry that can be called from more than one task.
 
-For detailed information on concepts related to tasking in
-DEC Ada, see the DEC Ada Language Reference Manual and the
-relevant run-time reference manual.
+This rule has no parameters.
+@end ignore
 
-@node Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems
-@section Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems
 
-@noindent
-On OpenVMS Alpha systems, each Ada task (except a passive
-task) is implemented as a single stream of execution
-that is created and managed by the kernel. On these
-systems, DEC Ada tasking support is based on DECthreads,
-an implementation of the POSIX standard for threads.
+@node Misnamed_Identifiers
+@subsection @code{Misnamed_Identifiers}
+@cindex @code{Misnamed_Identifiers} rule (for @command{gnatcheck})
 
-Although tasks are implemented as threads, all tasks in
-an Ada program are part of the same process. As a result,
-resources such as open files and virtual memory can be
-shared easily among tasks. Having all tasks in one process
-allows better integration with the programming environment
-(the shell and the debugger, for example).
+@noindent
+Flag the declaration of each identifier that does not have a suffix
+corresponding to the kind of entity being declared.
+The following declarations are checked:
 
-Also, on OpenVMS Alpha systems, DEC Ada tasks and foreign
-code that calls DECthreads routines can be used together.
-The interaction between Ada tasks and DECthreads routines
-can have some benefits. For example when on OpenVMS Alpha,
-DEC Ada can call C code that is already threaded.
-GNAT on OpenVMS Alpha uses the facilities of DECthreads,
-and Ada tasks are mapped to threads.
+@itemize @bullet
+@item
+ type declarations
 
-@menu
-* Assigning Task IDs::
-* Task IDs and Delays::
-* Task-Related Pragmas::
-* Scheduling and Task Priority::
-* The Task Stack::
-* External Interrupts::
-@end menu
+@item
+ constant declarations (but not number declarations)
 
-@node Assigning Task IDs
-@subsection Assigning Task IDs
+@item
+ package renaming declarations (but not generic package renaming
+    declarations)
+@end itemize
 
 @noindent
-The DEC Ada Run-Time Library always assigns %TASK 1 to
-the environment task that executes the main program. On
-OpenVMS Alpha systems, %TASK 0 is often used for tasks
-that have been created but are not yet activated.
-
-On OpenVMS Alpha systems, task IDs are assigned at
-activation. On GNAT systems, task IDs are also assigned at
-task creation but do not have the same form or values as
-task ID values in DEC Ada. There is no null task, and the
-environment task does not have a specific task ID value.
+This rule may have parameters. When used without parameters, the rule enforces
+the following checks:
 
-@node Task IDs and Delays
-@subsection Task IDs and Delays
+@itemize @bullet
+@item
+   type-defining names end with @code{_T}, unless the type is an access type,
+    in which case the suffix must be @code{_A}
+@item
+   constant names end with @code{_C}
+@item
+   names defining package renamings end with @code{_R}
+@end itemize
 
 @noindent
-On OpenVMS Alpha systems, tasking delays are implemented
-using Timer System Services. The Task ID is used for the
-identification of the timer request (the REQIDT parameter).
-If Timers are used in the application take care not to use
-0 for the identification, because cancelling such a timer
-will cancel all timers and may lead to unpredictable results.
+For a private or incomplete type declaration the following checks are
+made for the defining name suffix:
 
-@node Task-Related Pragmas
-@subsection Task-Related Pragmas
+@itemize @bullet
+@item
+ For an incomplete type declaration: if the corresponding full type
+  declaration is available, the defining identifier from the full type
+  declaration is checked, but the defining identifier from the incomplete type
+  declaration is not; otherwise the defining identifier from the incomplete
+  type declaration is checked against the suffix specified for type
+  declarations.
+
+@item
+ For a private type declaration (including private extensions),  the defining
+  identifier from the private type declaration is checked against the type
+  suffix (even if the corresponding full declaration is an access type
+  declaration), and the defining identifier from the corresponding full type
+  declaration is not checked.
+@end itemize
 
 @noindent
-Ada supplies the pragma TASK_STORAGE, which allows
-specification of the size of the guard area for a task
-stack. (The guard area forms an area of memory that has no
-read or write access and thus helps in the detection of
-stack overflow.) On OpenVMS Alpha systems, if the pragma
-TASK_STORAGE specifies a value of zero, a minimal guard
-area is created. In the absence of a pragma TASK_STORAGE, a default guard
-area is created.
+For a deferred constant, the defining name in the corresponding full constant
+declaration is not checked.
 
-GNAT supplies the following task-related pragmas:
+Defining names of formal types are not checked.
+
+The rule may have the following parameters:
 
 @itemize @bullet
-@item  TASK_INFO
+@item
+For the @option{+R} option:
+@table @code
+@item Default
+Sets the default listed above for all the names to be checked.
 
-              This pragma appears within a task definition and
-              applies to the task in which it appears. The argument
-              must be of type SYSTEM.TASK_INFO.TASK_INFO_TYPE.
+@item Type_Suffix=@emph{string}
+Specifies the suffix for a type name.
 
-@item  TASK_STORAGE
+@item Access_Suffix=@emph{string}
+Specifies the suffix for an access type name. If
+this parameter is set, it overrides for access
+types the suffix set by the @code{Type_Suffix} parameter.
 
-              GNAT implements pragma TASK_STORAGE in the same way as
-              DEC Ada.
-              Both DEC Ada and GNAT supply the pragmas PASSIVE,
-              SUPPRESS, and VOLATILE.
+@item Constant_Suffix=@emph{string}
+Specifies the suffix for a constant name.
+
+@item Renaming_Suffix=@emph{string}
+Specifies the suffix for a package renaming name.
+@end table
+
+@item
+For the @option{-R} option:
+@table @code
+@item All_Suffixes
+Remove all the suffixes specified for the
+identifier suffix checks, whether by default or
+as specified by other rule parameters. All the
+checks for this rule are disabled as a result.
+
+@item Type_Suffix
+Removes the suffix specified for types. This
+disables checks for types but does not disable
+any other checks for this rule (including the
+check for access type names if @code{Access_Suffix} is
+set).
+
+@item Access_Suffix
+Removes the suffix specified for access types.
+This disables checks for access type names but
+does not disable any other checks for this rule.
+If @code{Type_Suffix} is set, access type names are
+checked as ordinary type names.
+
+@item Constant_Suffix
+Removes the suffix specified for constants. This
+disables checks for constant names but does not
+disable any other checks for this rule.
+
+@item Renaming_Suffix
+Removes the suffix specified for package
+renamings. This disables checks for package
+renamings but does not disable any other checks
+for this rule.
+@end table
 @end itemize
-@node Scheduling and Task Priority
-@subsection Scheduling and Task Priority
 
 @noindent
-DEC Ada implements the Ada language requirement that
-when two tasks are eligible for execution and they have
-different priorities, the lower priority task does not
-execute while the higher priority task is waiting. The DEC
-Ada Run-Time Library keeps a task running until either the
-task is suspended or a higher priority task becomes ready.
+If more than one parameter is used, parameters must be separated by commas.
 
-On OpenVMS Alpha systems, the default strategy is round-
-robin with preemption. Tasks of equal priority take turns
-at the processor. A task is run for a certain period of
-time and then placed at the rear of the ready queue for
-its priority level.
+If more than one  option is specified for the @command{gnatcheck} invocation,
+a new option overrides the previous one(s).
 
-DEC Ada provides the implementation-defined pragma TIME_SLICE,
-which can be used to enable or disable round-robin
-scheduling of tasks with the same priority.
-See the relevant DEC Ada run-time reference manual for
-information on using the pragmas to control DEC Ada task
-scheduling.
+The @option{+RMisnamed_Identifiers} option (with no parameter) enables
+checks for all the
+name suffixes specified by previous options used for this rule.
 
-GNAT follows the scheduling rules of Annex D (real-time
-Annex) of the Ada 95 Reference Manual. In general, this
-scheduling strategy is fully compatible with DEC Ada
-although it provides some additional constraints (as
-fully documented in Annex D).
-GNAT implements time slicing control in a manner compatible with
-DEC Ada 83, by means of the pragma Time_Slice, whose semantics are identical
-to the DEC Ada 83 pragma of the same name.
-Note that it is not possible to mix GNAT tasking and
-DEC Ada 83 tasking in the same program, since the two run times are
-not compatible.
+The @option{-RMisnamed_Identifiers} option (with no parameter) disables
+all the checks but keeps
+all the suffixes specified by previous options used for this rule.
 
-@node The Task Stack
-@subsection The Task Stack
+The @emph{string} value must be a valid suffix for an Ada identifier (after
+trimming all the leading and trailing space characters, if any).
+Parameters are not case sensitive, except the @emph{string} part.
 
-@noindent
-In DEC Ada, a task stack is allocated each time a
-non passive task is activated. As soon as the task is
-terminated, the storage for the task stack is deallocated.
-If you specify a size of zero (bytes) with T'STORAGE_SIZE,
-a default stack size is used. Also, regardless of the size
-specified, some additional space is allocated for task
-management purposes. On OpenVMS Alpha systems, at least
-one page is allocated.
+If any error is detected in a rule parameter, the parameter is ignored.
+In such a case the options that are set for the rule are not
+specified.
 
-GNAT handles task stacks in a similar manner. According to
-the Ada 95 rules, it provides the pragma STORAGE_SIZE as
-an alternative method for controlling the task stack size.
-The specification of the attribute T'STORAGE_SIZE is also
-supported in a manner compatible with DEC Ada.
 
-@node External Interrupts
-@subsection External Interrupts
+
+@node Multiple_Entries_In_Protected_Definitions
+@subsection @code{Multiple_Entries_In_Protected_Definitions}
+@cindex @code{Multiple_Entries_In_Protected_Definitions} rule (for @command{gnatcheck})
 
 @noindent
-On DEC Ada, external interrupts can be associated with task entries.
-GNAT is compatible with DEC Ada in its handling of external interrupts.
+Flag each protected definition (i.e., each protected object/type declaration)
+that defines more than one entry.
+Diagnostic messages are generated for all the entry declarations
+except the first one. An entry family is counted as one entry. Entries from
+the private part of the protected definition are also checked.
 
-@node Pragmas and Pragma-Related Features
-@section Pragmas and Pragma-Related Features
+This rule has no parameters.
+
+@node Name_Clashes
+@subsection @code{Name_Clashes}
+@cindex @code{Name_Clashes} rule (for @command{gnatcheck})
 
 @noindent
-Both DEC Ada and GNAT supply all language-defined pragmas
-as specified by the Ada 83 standard. GNAT also supplies all
-language-defined pragmas specified in the Ada 95 Reference Manual.
-In addition, GNAT implements the implementation-defined pragmas
-from DEC Ada 83.
+Check that certain names are not used as defining identifiers. To activate
+this rule, you need to supply a reference to the dictionary file(s) as a rule
+parameter(s) (more then one dictionary file can be specified). If no
+dictionary file is set, this rule will not cause anything to be flagged.
+Only defining occurrences, not references, are checked.
+The check is not case-sensitive.
 
-@itemize @bullet
-@item  AST_ENTRY
+This rule is enabled by default, but without setting any corresponding
+dictionary file(s); thus the default effect is to do no checks.
 
-@item  COMMON_OBJECT
+A dictionary file is a plain text file. The maximum line length for this file
+is 1024 characters.  If the line is longer then this limit, extra characters
+are ignored.
 
-@item  COMPONENT_ALIGNMENT
+Each line can be either an empty line, a comment line, or a line containing
+a list of identifiers separated by space or HT characters.
+A comment is an Ada-style comment (from @code{--} to end-of-line).
+Identifiers must follow the Ada syntax for identifiers.
+A line containing one or more identifiers may end with a comment.
 
-@item  EXPORT_EXCEPTION
+@node Non_Qualified_Aggregates
+@subsection @code{Non_Qualified_Aggregates}
+@cindex @code{Non_Qualified_Aggregates} rule (for @command{gnatcheck})
 
-@item  EXPORT_FUNCTION
+@noindent
+Flag each non-qualified aggregate.
+A non-qualified aggregate is an
+aggregate that is not the expression of a qualified expression. A
+string literal is not considered an aggregate, but an array
+aggregate of a string type is considered as a normal aggregate.
+Aggregates of anonymous array types are not flagged.
 
-@item  EXPORT_OBJECT
+This rule has no parameters.
 
-@item  EXPORT_PROCEDURE
 
-@item  EXPORT_VALUED_PROCEDURE
+@node Non_Short_Circuit_Operators
+@subsection @code{Non_Short_Circuit_Operators}
+@cindex @code{Non_Short_Circuit_Operators} rule (for @command{gnatcheck})
 
-@item  FLOAT_REPRESENTATION
+@noindent
+Flag all calls to predefined @code{and} and @code{or} operators for
+any boolean type. Calls to
+user-defined @code{and} and @code{or} and to operators defined by renaming
+declarations are not flagged. Calls to predefined @code{and} and @code{or}
+operators for modular types or boolean array types are not flagged.
 
-@item  IDENT
+This rule has no parameters.
 
-@item  IMPORT_EXCEPTION
 
-@item  IMPORT_FUNCTION
 
-@item  IMPORT_OBJECT
+@node Non_SPARK_Attributes
+@subsection @code{Non_SPARK_Attributes}
+@cindex @code{Non_SPARK_Attributes} rule (for @command{gnatcheck})
 
-@item  IMPORT_PROCEDURE
+@noindent
+The SPARK language defines the following subset of Ada 95 attribute
+designators as those that can be used in SPARK programs. The use of
+any other attribute is flagged.
 
-@item  IMPORT_VALUED_PROCEDURE
+@itemize @bullet
+@item @code{'Adjacent}
+@item @code{'Aft}
+@item @code{'Base}
+@item @code{'Ceiling}
+@item @code{'Component_Size}
+@item @code{'Compose}
+@item @code{'Copy_Sign}
+@item @code{'Delta}
+@item @code{'Denorm}
+@item @code{'Digits}
+@item @code{'Exponent}
+@item @code{'First}
+@item @code{'Floor}
+@item @code{'Fore}
+@item @code{'Fraction}
+@item @code{'Last}
+@item @code{'Leading_Part}
+@item @code{'Length}
+@item @code{'Machine}
+@item @code{'Machine_Emax}
+@item @code{'Machine_Emin}
+@item @code{'Machine_Mantissa}
+@item @code{'Machine_Overflows}
+@item @code{'Machine_Radix}
+@item @code{'Machine_Rounds}
+@item @code{'Max}
+@item @code{'Min}
+@item @code{'Model}
+@item @code{'Model_Emin}
+@item @code{'Model_Epsilon}
+@item @code{'Model_Mantissa}
+@item @code{'Model_Small}
+@item @code{'Modulus}
+@item @code{'Pos}
+@item @code{'Pred}
+@item @code{'Range}
+@item @code{'Remainder}
+@item @code{'Rounding}
+@item @code{'Safe_First}
+@item @code{'Safe_Last}
+@item @code{'Scaling}
+@item @code{'Signed_Zeros}
+@item @code{'Size}
+@item @code{'Small}
+@item @code{'Succ}
+@item @code{'Truncation}
+@item @code{'Unbiased_Rounding}
+@item @code{'Val}
+@item @code{'Valid}
+@end itemize
 
-@item  INLINE_GENERIC
+@noindent
+This rule has no parameters.
 
-@item  INTERFACE_NAME
 
-@item  LONG_FLOAT
+@node Non_Tagged_Derived_Types
+@subsection @code{Non_Tagged_Derived_Types}
+@cindex @code{Non_Tagged_Derived_Types} rule (for @command{gnatcheck})
 
-@item  MAIN_STORAGE
+@noindent
+Flag all derived type declarations that do not have a record extension part.
 
-@item  PASSIVE
+This rule has no parameters.
 
-@item  PSET_OBJECT
 
-@item  SHARE_GENERIC
 
-@item  SUPPRESS_ALL
+@node Non_Visible_Exceptions
+@subsection @code{Non_Visible_Exceptions}
+@cindex @code{Non_Visible_Exceptions} rule (for @command{gnatcheck})
 
-@item  TASK_STORAGE
+@noindent
+Flag constructs leading to the possibility of propagating an exception
+out of the scope in which the exception is declared.
+Two cases are detected:
 
-@item  TIME_SLICE
+@itemize @bullet
+@item
+An exception declaration in a subprogram body, task body or block
+statement is flagged if the body or statement does not contain a handler for
+that exception or a handler with an @code{others} choice.
 
-@item  TITLE
+@item
+A @code{raise} statement in an exception handler of a subprogram body,
+task body or block statement is flagged if it (re)raises a locally
+declared exception.  This may occur under the following circumstances:
+@itemize @minus
+@item
+it explicitly raises a locally declared exception, or
+@item
+it does not specify an exception name (i.e., it is simply @code{raise;})
+and the enclosing handler contains a locally declared exception in its
+exception choices.
+@end itemize
 @end itemize
 
 @noindent
-These pragmas are all fully implemented, with the exception of @code{Title},
-@code{Passive}, and @code{Share_Generic}, which are
-recognized, but which have no
-effect in GNAT. The effect of @code{Passive} may be obtained by the
-use of protected objects in Ada 95. In GNAT, all generics are inlined.
+Renamings of local exceptions are not flagged.
 
-Unlike DEC Ada, the GNAT 'EXPORT_@i{subprogram}' pragmas require
-a separate subprogram specification which must appear before the
-subprogram body.
+This rule has no parameters.
 
-GNAT also supplies a number of implementation-defined pragmas as follows:
-@itemize @bullet
-@item  C_PASS_BY_COPY
 
-@item  EXTEND_SYSTEM
+@node Numeric_Literals
+@subsection @code{Numeric_Literals}
+@cindex @code{Numeric_Literals} rule (for @command{gnatcheck})
+
+@noindent
+Flag each use of a numeric literal in an index expression, and in any
+circumstance except for the following:
 
-@item  SOURCE_FILE_NAME
+@itemize @bullet
+@item
+a literal occurring in the initialization expression for a constant
+declaration or a named number declaration, or
 
-@item  UNSUPPRESS
+@item
+an integer literal that is less than or equal to a value
+specified by the @option{N} rule parameter.
+@end itemize
 
-@item  WARNINGS
+@noindent
+This rule may have the following parameters for the @option{+R} option:
 
-@item  ABORT_DEFER
+@table @asis
+@item @emph{N}
+@emph{N} is an integer literal used as the maximal value that is not flagged
+(i.e., integer literals not exceeding this value are allowed)
 
-@item  ADA_83
+@item @code{ALL}
+All integer literals are flagged
+@end table
 
-@item  ADA_95
+@noindent
+If no parameters are set, the maximum unflagged value is 1.
 
-@item  ANNOTATE
+The last specified check limit (or the fact that there is no limit at
+all) is used when multiple @option{+R} options appear.
 
-@item  ASSERT
+The @option{-R} option for this rule has no parameters.
+It disables the rule but retains the last specified maximum unflagged value.
+If the @option{+R} option subsequently appears, this value is used as the
+threshold for the check.
 
-@item  CPP_CLASS
 
-@item  CPP_CONSTRUCTOR
+@node OTHERS_In_Aggregates
+@subsection @code{OTHERS_In_Aggregates}
+@cindex @code{OTHERS_In_Aggregates} rule (for @command{gnatcheck})
 
-@item  CPP_DESTRUCTOR
+@noindent
+Flag each use of an @code{others} choice in extension aggregates.
+In record and array aggregates, an @code{others} choice is flagged unless
+it is used to refer to all components, or to all but one component.
 
-@item  CPP_VIRTUAL
+If, in case of a named array aggregate, there are two associations, one
+with an @code{others} choice and another with a discrete range, the
+@code{others} choice is flagged even if the discrete range specifies
+exactly one component; for example, @code{(1..1 => 0, others => 1)}.
 
-@item  CP_VTABLE
+This rule has no parameters.
 
-@item  DEBUG
+@node OTHERS_In_CASE_Statements
+@subsection @code{OTHERS_In_CASE_Statements}
+@cindex @code{OTHERS_In_CASE_Statements} rule (for @command{gnatcheck})
 
-@item  LINKER_ALIAS
+@noindent
+Flag any use of an @code{others} choice in a @code{case} statement.
 
-@item  LINKER_SECTION
+This rule has no parameters.
 
-@item  MACHINE_ATTRIBUTE
+@node OTHERS_In_Exception_Handlers
+@subsection @code{OTHERS_In_Exception_Handlers}
+@cindex @code{OTHERS_In_Exception_Handlers} rule (for @command{gnatcheck})
 
-@item  NO_RETURN
+@noindent
+Flag any use of an @code{others} choice in an exception handler.
 
-@item  PURE_FUNCTION
+This rule has no parameters.
 
-@item  SOURCE_REFERENCE
 
-@item  TASK_INFO
+@node Outer_Loop_Exits
+@subsection @code{Outer_Loop_Exits}
+@cindex @code{Outer_Loop_Exits} rule (for @command{gnatcheck})
 
-@item  UNCHECKED_UNION
+@noindent
+Flag each @code{exit} statement containing a loop name that is not the name
+of the immediately enclosing @code{loop} statement.
 
-@item  UNIMPLEMENTED_UNIT
+This rule has no parameters.
 
-@item  UNIVERSAL_DATA
 
-@item  WEAK_EXTERNAL
-@end itemize
+@node Overloaded_Operators
+@subsection @code{Overloaded_Operators}
+@cindex @code{Overloaded_Operators} rule (for @command{gnatcheck})
 
 @noindent
-For full details on these GNAT implementation-defined pragmas, see
-the GNAT Reference Manual.
+Flag each function declaration that overloads an operator symbol.
+A function body is checked only if the body does not have a
+separate spec. Formal functions are also checked. For a
+renaming declaration, only renaming-as-declaration is checked
 
-@menu
-* Restrictions on the Pragma INLINE::
-* Restrictions on the Pragma INTERFACE::
-* Restrictions on the Pragma SYSTEM_NAME::
-@end menu
+This rule has no parameters.
 
-@node Restrictions on the Pragma INLINE
-@subsection Restrictions on the Pragma INLINE
+
+@node Overly_Nested_Control_Structures
+@subsection @code{Overly_Nested_Control_Structures}
+@cindex @code{Overly_Nested_Control_Structures} rule (for @command{gnatcheck})
 
 @noindent
-DEC Ada applies the following restrictions to the pragma INLINE:
-@itemize @bullet
-@item  Parameters cannot be a task type.
+Flag each control structure whose nesting level exceeds the value provided
+in the rule parameter.
 
-@item  Function results cannot be task types, unconstrained
-array types, or unconstrained types with discriminants.
+The control structures checked are the following:
 
-@item  Bodies cannot declare the following:
 @itemize @bullet
-@item  Subprogram body or stub (imported subprogram is allowed)
+@item    @code{if} statement
+@item    @code{case} statement
+@item    @code{loop} statement
+@item    Selective accept statement
+@item    Timed entry call statement
+@item    Conditional entry call
+@item    Asynchronous select statement
+@end itemize
 
-@item  Tasks
+@noindent
+The rule may have the following parameter for the @option{+R} option:
 
-@item  Generic declarations
+@table @emph
+@item N
+Positive integer specifying the maximal control structure nesting
+level that is not flagged
+@end table
 
-@item  Instantiations
+@noindent
+If the parameter for the @option{+R} option is not a positive integer,
+the parameter is ignored and the rule is turned ON with the most recently
+specified maximal non-flagged nesting level.
 
-@item  Exceptions
+If more then one  option is specified for the gnatcheck call, the later option and
+new parameter override the previous one(s).
 
-@item  Access types (types derived from access types allowed)
+A @option{+R} option with no parameter turns the rule ON using the maximal
+non-flagged nesting level specified by the most recent @option{+R} option with
+a parameter, or the value 4 if there is no such previous @option{+R} option.
 
-@item  Array or record types
 
-@item  Dependent tasks
 
-@item  Direct recursive calls of subprogram or containing
-subprogram, directly or via a renaming
+@node Parameters_Out_Of_Order
+@subsection @code{Parameters_Out_Of_Order}
+@cindex @code{Parameters_Out_Of_Order} rule (for @command{gnatcheck})
 
-@end itemize
+@noindent
+Flag each subprogram and entry declaration whose formal parameters are not
+ordered according to the following scheme:
+
+@itemize @bullet
+
+@item @code{in} and @code{access} parameters first,
+then @code{in out} parameters,
+and then @code{out} parameters;
+
+@item for @code{in} mode, parameters with default initialization expressions
+occur last
 @end itemize
 
 @noindent
-In GNAT, the only restriction on pragma INLINE is that the
-body must occur before the call if both are in the same
-unit, and the size must be appropriately small. There are
-no other specific restrictions which cause subprograms to
-be incapable of being inlined.
+Only the first violation of the described order is flagged.
 
-@node  Restrictions on the Pragma INTERFACE
-@subsection  Restrictions on the Pragma INTERFACE
+The following constructs are checked:
 
-@noindent
-The following lists and describes the restrictions on the
-pragma INTERFACE on DEC Ada and GNAT:
 @itemize @bullet
-@item  Languages accepted: Ada, Bliss, C, Fortran, Default.
-Default is the default on OpenVMS Alpha systems.
+@item   subprogram declarations (including null procedures);
+@item   generic subprogram declarations;
+@item   formal subprogram declarations;
+@item   entry declarations;
+@item   subprogram bodies and subprogram body stubs that do not
+have separate specifications
+@end itemize
 
-@item  Parameter passing: Language specifies default
-mechanisms but can be overridden with an EXPORT pragma.
+@noindent
+Subprogram renamings are not checked.
 
-@itemize @bullet
-@item  Ada: Use internal Ada rules.
+This rule has no parameters.
 
-@item  Bliss, C: Parameters must be mode @code{in}; cannot be
-record or task type. Result cannot be a string, an
-array, or a record.
 
-@item  Fortran: Parameters cannot be a task. Result cannot
-be a string, an array, or a record.
-@end itemize
-@end itemize
+@node Positional_Actuals_For_Defaulted_Generic_Parameters
+@subsection @code{Positional_Actuals_For_Defaulted_Generic_Parameters}
+@cindex @code{Positional_Actuals_For_Defaulted_Generic_Parameters} rule (for @command{gnatcheck})
 
 @noindent
-GNAT is entirely upwards compatible with DEC Ada, and in addition allows
-record parameters for all languages.
+Flag each generic actual parameter corresponding to a generic formal
+parameter with a default initialization, if positional notation is used.
 
-@node  Restrictions on the Pragma SYSTEM_NAME
-@subsection  Restrictions on the Pragma SYSTEM_NAME
+This rule has no parameters.
+
+@node Positional_Actuals_For_Defaulted_Parameters
+@subsection @code{Positional_Actuals_For_Defaulted_Parameters}
+@cindex @code{Positional_Actuals_For_Defaulted_Parameters} rule (for @command{gnatcheck})
 
 @noindent
-For DEC Ada for OpenVMS Alpha, the enumeration literal
-for the type NAME is OPENVMS_AXP. In GNAT, the enumeration
-literal for the type NAME is SYSTEM_NAME_GNAT.
+Flag each actual parameter to a subprogram or entry call where the
+corresponding formal parameter has a default expression, if positional
+notation is used.
 
-@node  Library of Predefined Units
-@section  Library of Predefined Units
+This rule has no parameters.
+
+@node Positional_Components
+@subsection @code{Positional_Components}
+@cindex @code{Positional_Components} rule (for @command{gnatcheck})
 
 @noindent
-A library of predefined units is provided as part of the
-DEC Ada and GNAT implementations. DEC Ada does not provide
-the package MACHINE_CODE but instead recommends importing
-assembler code.
+Flag each array, record and extension aggregate that includes positional
+notation.
 
-The GNAT versions of the DEC Ada Run-Time Library (ADA$PREDEFINED:)
-units are taken from the OpenVMS Alpha version, not the OpenVMS VAX
-version. During GNAT installation, the DEC Ada Predefined
-Library units are copied into the GNU:[LIB.OPENVMS7_x.2_8_x.DECLIB]
-(aka DECLIB) directory and patched to remove Ada 95 incompatibilities
-and to make them interoperable with GNAT, @pxref{Changes to DECLIB}
-for details.
+This rule has no parameters.
 
-The GNAT RTL is contained in
-the GNU:[LIB.OPENVMS7_x.2_8_x.ADALIB] (aka ADALIB) directory and
-the default search path is set up to find DECLIB units in preference
-to ADALIB units with the same name (TEXT_IO, SEQUENTIAL_IO, and DIRECT_IO,
-for example).
 
-However, it is possible to change the default so that the
-reverse is true, or even to mix them using child package
-notation. The DEC Ada 83 units are available as DEC.xxx where xxx
-is the package name, and the Ada units are available in the
-standard manner defined for Ada 95, that is to say as Ada.xxx. To
-change the default, set ADA_INCLUDE_PATH and ADA_OBJECTS_PATH
-appropriately. For example, to change the default to use the Ada95
-versions do:
+@node Positional_Generic_Parameters
+@subsection @code{Positional_Generic_Parameters}
+@cindex @code{Positional_Generic_Parameters} rule (for @command{gnatcheck})
 
-@smallexample
-$ DEFINE ADA_INCLUDE_PATH GNU:[LIB.OPENVMS7_1.2_8_1.ADAINCLUDE],-
-                          GNU:[LIB.OPENVMS7_1.2_8_1.DECLIB]
-$ DEFINE ADA_OBJECTS_PATH GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB],-
-                          GNU:[LIB.OPENVMS7_1.2_8_1.DECLIB]
-@end smallexample
+@noindent
+Flag each instantiation using positional parameter notation.
 
-@menu
-* Changes to DECLIB::
-@end menu
+This rule has no parameters.
 
-@node Changes to DECLIB
-@subsection Changes to DECLIB
+
+@node Positional_Parameters
+@subsection @code{Positional_Parameters}
+@cindex @code{Positional_Parameters} rule (for @command{gnatcheck})
 
 @noindent
-The changes made to the DEC Ada predefined library for GNAT and Ada 95
-compatibility are minor and include the following:
+Flag each subprogram or entry call using positional parameter notation,
+except for the following:
 
 @itemize @bullet
-@item  Adjusting the location of pragmas and record representation
-clauses to obey Ada 95 rules
+@item
+Invocations of prefix or infix operators are not flagged
+@item
+If the called subprogram or entry has only one formal parameter,
+the call is not flagged;
+@item
+If a subprogram call uses the @emph{Object.Operation} notation, then
+@itemize @minus
+@item
+the first parameter (that is, @emph{Object}) is not flagged;
+@item
+if the called subprogram has only two parameters, the second parameter
+of the call is not flagged;
+@end itemize
+@end itemize
 
-@item  Adding the proper notation to generic formal parameters
-that take unconstrained types in instantiation
+@noindent
+This rule has no parameters.
 
-@item  Adding pragma ELABORATE_BODY to package specifications
-that have package bodies not otherwise allowed
 
-@item  Occurrences of the identifier @code{"PROTECTED"} are renamed to
-@code{"PROTECTD"}.
-Currently these are found only in the STARLET package spec.
-@end itemize
 
-@noindent
-None of the above changes is visible to users.
 
-@node Bindings
-@section Bindings
+@node Predefined_Numeric_Types
+@subsection @code{Predefined_Numeric_Types}
+@cindex @code{Predefined_Numeric_Types} rule (for @command{gnatcheck})
 
 @noindent
-On OpenVMS Alpha, DEC Ada provides the following strongly-typed bindings:
-@itemize @bullet
+Flag each explicit use of the name of any numeric type or subtype defined
+in package @code{Standard}.
 
-@item  Command Language Interpreter (CLI interface)
+The rationale for this rule is to detect when the
+program may depend on platform-specific characteristics of the implementation
+of the predefined numeric types. Note that this rule is over-pessimistic;
+for example, a program that uses @code{String} indexing
+likely needs a variable of type @code{Integer}.
+Another example is the flagging of predefined numeric types with explicit
+constraints:
 
-@item  DECtalk Run-Time Library (DTK interface)
+@smallexample @c ada
+    subtype My_Integer is Integer range Left .. Right;
+    Vy_Var : My_Integer;
+@end smallexample
 
-@item  Librarian utility routines (LBR interface)
+@noindent
+This rule detects only numeric types and subtypes defined in
+@code{Standard}. The use of numeric types and subtypes defined in other
+predefined packages (such as @code{System.Any_Priority} or
+@code{Ada.Text_IO.Count}) is not flagged
 
-@item  General Purpose Run-Time Library (LIB interface)
+This rule has no parameters.
 
-@item  Math Run-Time Library (MTH interface)
 
-@item  National Character Set Run-Time Library (NCS interface)
 
-@item  Compiled Code Support Run-Time Library (OTS interface)
+@node Raising_External_Exceptions
+@subsection @code{Raising_External_Exceptions}
+@cindex @code{Raising_External_Exceptions} rule (for @command{gnatcheck})
 
-@item  Parallel Processing Run-Time Library (PPL interface)
+@noindent
+Flag any @code{raise} statement, in a program unit declared in a library
+package or in a generic library package, for an exception that is
+neither a predefined exception nor an exception that is also declared (or
+renamed) in the visible part of the package.
 
-@item  Screen Management Run-Time Library (SMG interface)
+This rule has no parameters.
 
-@item  Sort Run-Time Library (SOR interface)
 
-@item  String Run-Time Library (STR interface)
 
-@item STARLET System Library
-@findex Starlet
+@node Raising_Predefined_Exceptions
+@subsection @code{Raising_Predefined_Exceptions}
+@cindex @code{Raising_Predefined_Exceptions} rule (for @command{gnatcheck})
 
-@item  X Window System Version 11R4 and 11R5 (X, XLIB interface)
+@noindent
+Flag each @code{raise} statement that raises a predefined exception
+(i.e., one of the exceptions @code{Constraint_Error}, @code{Numeric_Error},
+@code{Program_Error}, @code{Storage_Error}, or @code{Tasking_Error}).
 
-@item  X Windows Toolkit (XT interface)
+This rule has no parameters.
 
-@item  X/Motif Version 1.1.3 and 1.2 (XM interface)
-@end itemize
+
+@ignore
+@node Recursion
+@subsection @code{Recursion} (under construction, GLOBAL)
+@cindex @code{Recursion} rule (for @command{gnatcheck})
 
 @noindent
-GNAT provides implementations of these DEC bindings in the DECLIB directory.
+Flag recursive subprograms (cycles in the call graph). Declarations, and not
+calls, of recursive subprograms are detected.
 
-The X/Motif bindings used to build DECLIB are whatever versions are in the
-DEC Ada @file{ADA$PREDEFINED} directory with extension @file{.ADC}.
-The build script will
-automatically add a pragma Linker_Options to packages @code{Xm}, @code{Xt},
-and @code{X_Lib}
-causing the default X/Motif sharable image libraries to be linked in. This
-is done via options files named @file{xm.opt}, @file{xt.opt}, and
-@file{x_lib.opt} (also located in the @file{DECLIB} directory).
+This rule has no parameters.
+@end ignore
 
-It may be necessary to edit these options files to update or correct the
-library names if, for example, the newer X/Motif bindings from
-@file{ADA$EXAMPLES}
-had been (previous to installing GNAT) copied and renamed to supersede the
-default @file{ADA$PREDEFINED} versions.
+@ignore
+@node Side_Effect_Functions
+@subsection @code{Side_Effect_Functions} (under construction, GLOBAL)
+@cindex @code{Side_Effect_Functions} rule (for @command{gnatcheck})
 
-@menu
-* Shared Libraries and Options Files::
-* Interfaces to C::
-@end menu
+@noindent
+Flag functions with side effects.
 
-@node Shared Libraries and Options Files
-@subsection Shared Libraries and Options Files
+We define a side effect as changing any data object that is not local for the
+body of this function.
 
-@noindent
-When using the DEC Ada
-predefined X and Motif bindings, the linking with their sharable images is
-done automatically by @command{GNAT LINK}.
-When using other X and Motif bindings, you need
-to add the corresponding sharable images to the command line for
-@code{GNAT LINK}. When linking with shared libraries, or with
-@file{.OPT} files, you must
-also add them to the command line for @command{GNAT LINK}.
+At the moment, we do NOT consider a side effect any input-output operations
+(changing a state or a content of any file).
 
-A shared library to be used with GNAT is built in the same way as other
-libraries under VMS. The VMS Link command can be used in standard fashion.
+We do not consider protected functions for this rule (???)
 
-@node Interfaces to C
-@subsection Interfaces to C
+There are the following sources of side effect:
 
-@noindent
-DEC Ada
-provides the following Ada types and operations:
+@enumerate
+@item Explicit (or direct) side-effect:
 
 @itemize @bullet
-@item C types package (C_TYPES)
+@item
+direct assignment to a non-local variable;
 
-@item C strings (C_TYPES.NULL_TERMINATED)
+@item
+direct call to an entity that is known to change some data object that is
+     not local for the body of this function (Note, that if F1 calls F2 and F2
+     does have a side effect, this does not automatically mean that F1 also
+     have a side effect, because it may be the case that F2 is declared in
+     F1's body and it changes some data object that is global for F2, but
+     local for F1);
+@end itemize
 
-@item Other_types (SHORT_INT)
+@item Indirect side-effect:
+@itemize @bullet
+@item
+Subprogram calls implicitly issued by:
+@itemize @bullet
+@item
+computing initialization expressions from type declarations as a part
+         of object elaboration or allocator evaluation;
+@item
+computing implicit parameters of subprogram or entry calls or generic
+         instantiations;
 @end itemize
 
-@noindent
-Interfacing to C with GNAT, one can use the above approach
-described for DEC Ada or the facilities of Annex B of
-the Ada 95 Reference Manual (packages INTERFACES.C,
-INTERFACES.C.STRINGS and INTERFACES.C.POINTERS). For more
-information, see the section ``Interfacing to C'' in the
-@cite{GNAT Reference Manual}.
+@item
+activation of a task that change some non-local data object (directly or
+     indirectly);
 
-The @option{-gnatF} qualifier forces default and explicit
-@code{External_Name} parameters in pragmas Import and Export
-to be uppercased for compatibility with the default behavior
-of Compaq C. The qualifier has no effect on @code{Link_Name} parameters.
+@item
+elaboration code of a package that is a result of a package instantiation;
 
-@node Main Program Definition
-@section Main Program Definition
+@item
+controlled objects;
+@end itemize
 
-@noindent
-The following section discusses differences in the
-definition of main programs on DEC Ada and GNAT.
-On DEC Ada, main programs are defined to meet the
-following conditions:
+@item Situations when we can suspect a side-effect, but the full static check
+is either impossible or too hard:
 @itemize @bullet
-@item  Procedure with no formal parameters (returns 0 upon
-       normal completion)
+@item
+assignment to access variables or to the objects pointed by access
+     variables;
 
-@item  Procedure with no formal parameters (returns 42 when
-       unhandled exceptions are raised)
+@item
+call to a subprogram pointed by access-to-subprogram value
 
-@item  Function with no formal parameters whose returned value
-       is of a discrete type
+@item
+dispatching calls;
+@end itemize
+@end enumerate
 
-@item  Procedure with one OUT formal of a discrete type for
-       which a specification of pragma EXPORT_VALUED_PROCEDURE is given.
+@noindent
+This rule has no parameters.
+@end ignore
 
-@end itemize
+@node Slices
+@subsection @code{Slices}
+@cindex @code{Slices} rule (for @command{gnatcheck})
 
 @noindent
-When declared with the pragma EXPORT_VALUED_PROCEDURE,
-a main function or main procedure returns a discrete
-value whose size is less than 64 bits (32 on VAX systems),
-the value is zero- or sign-extended as appropriate.
-On GNAT, main programs are defined as follows:
-@itemize @bullet
-@item  Must be a non-generic, parameter-less subprogram that
-is either a procedure or function returning an Ada
-STANDARD.INTEGER (the predefined type)
+Flag all uses of array slicing
 
-@item  Cannot be a generic subprogram or an instantiation of a
-generic subprogram
-@end itemize
+This rule has no parameters.
 
-@node Implementation-Defined Attributes
-@section Implementation-Defined Attributes
+
+@node Unassigned_OUT_Parameters
+@subsection @code{Unassigned_OUT_Parameters}
+@cindex @code{Unassigned_OUT_Parameters} rule (for @command{gnatcheck})
 
 @noindent
-GNAT provides all DEC Ada implementation-defined
-attributes.
+Flags procedures' @code{out} parameters that are not assigned, and
+identifies the contexts in which the assignments are missing.
 
-@node Compiler and Run-Time Interfacing
-@section Compiler and Run-Time Interfacing
+An @code{out} parameter is flagged in the statements in the procedure
+body's handled sequence of statements (before the procedure body's
+@code{exception} part, if any) if this sequence of statements contains
+no assignments to the parameter.
 
-@noindent
-DEC Ada provides the following ways to pass options to the linker
-(ACS LINK):
-@itemize @bullet
-@item  /WAIT and /SUBMIT qualifiers
+An @code{out} parameter is flagged in an exception handler in the exception
+part of the procedure body's handled sequence of statements if the handler
+contains no assignment to the parameter.
 
-@item  /COMMAND qualifier
+Bodies of generic procedures are also considered.
 
-@item  /[NO]MAP qualifier
+The following are treated as assignments to an @code{out} parameter:
 
-@item  /OUTPUT=file-spec
+@itemize @bullet
+@item
+an assignment statement, with the parameter or some component as the target;
 
-@item  /[NO]DEBUG and /[NO]TRACEBACK qualifiers
+@item
+passing the parameter (or one of its components) as an @code{out} or
+@code{in out} parameter.
 @end itemize
 
 @noindent
-To pass options to the linker, GNAT provides the following
-switches:
+This rule does not have any parameters.
 
-@itemize @bullet
-@item   @option{/EXECUTABLE=exec-name}
 
-@item   @option{/VERBOSE qualifier}
 
-@item   @option{/[NO]DEBUG} and @option{/[NO]TRACEBACK} qualifiers
-@end itemize
+@node Uncommented_BEGIN_In_Package_Bodies
+@subsection @code{Uncommented_BEGIN_In_Package_Bodies}
+@cindex @code{Uncommented_BEGIN_In_Package_Bodies} rule (for @command{gnatcheck})
 
 @noindent
-For more information on these switches, see
-@ref{Switches for gnatlink}.
-In DEC Ada, the command-line switch @option{/OPTIMIZE} is available
-to control optimization. DEC Ada also supplies the
-following pragmas:
-@itemize @bullet
-@item  @code{OPTIMIZE}
+Flags each package body with declarations and a statement part that does not
+include a trailing comment on the line containing the @code{begin} keyword;
+this trailing comment needs to specify the package name and nothing else.
+The @code{begin} is not flagged if the package body does not
+contain any declarations.
 
-@item  @code{INLINE}
+If the @code{begin} keyword is placed on the
+same line as the last declaration or the first statement, it is flagged
+independently of whether the line contains a trailing comment. The
+diagnostic message is attached to the line containing the first statement.
 
-@item  @code{INLINE_GENERIC}
+This rule has no parameters.
 
-@item  @code{SUPPRESS_ALL}
 
-@item  @code{PASSIVE}
-@end itemize
+@node Unconstrained_Array_Returns
+@subsection @code{Unconstrained_Array_Returns}
+@cindex @code{Unconstrained_Array_Returns} rule (for @command{gnatcheck})
 
 @noindent
-In GNAT, optimization is controlled strictly by command
-line parameters, as described in the corresponding section of this guide.
-The DIGITAL pragmas for control of optimization are
-recognized but ignored.
+Flag each function returning an unconstrained array. Function declarations,
+function bodies (and body stubs) having no separate specifications,
+and generic function instantiations are checked.
+Generic function declarations, function calls and function renamings are
+not checked.
 
-Note that in GNAT, the default is optimization off, whereas in DEC Ada 83,
-the default is that optimization is turned on.
+This rule has no parameters.
 
-@node Program Compilation and Library Management
-@section Program Compilation and Library Management
+@node Universal_Ranges
+@subsection @code{Universal_Ranges}
+@cindex @code{Universal_Ranges} rule (for @command{gnatcheck})
 
 @noindent
-DEC Ada and GNAT provide a comparable set of commands to
-build programs. DEC Ada also provides a program library,
-which is a concept that does not exist on GNAT. Instead,
-GNAT provides directories of sources that are compiled as
-needed.
+Flag discrete ranges that are a part of an index constraint, constrained
+array definition, or @code{for}-loop parameter specification, and whose bounds
+are both of type @i{universal_integer}. Ranges that have at least one
+bound of a specific type (such as @code{1 .. N}, where @code{N} is a variable
+or an expression of non-universal type) are not flagged.
 
-The following table summarizes
-the DEC Ada commands and provides
-equivalent GNAT commands. In this table, some GNAT
-equivalents reflect the fact that GNAT does not use the
-concept of a program library. Instead, it uses a model
-in which collections of source and object files are used
-in a manner consistent with other languages like C and
-Fortran. Therefore, standard system file commands are used
-to manipulate these elements. Those GNAT commands are marked with
-an asterisk.
-Note that, unlike DEC Ada, none of the GNAT commands accepts wild cards.
+This rule has no parameters.
 
-@need 1500
-@multitable @columnfractions .35 .65
 
-@item @emph{DEC Ada Command}
-@tab @emph{GNAT Equivalent / Description}
+@node Unnamed_Blocks_And_Loops
+@subsection @code{Unnamed_Blocks_And_Loops}
+@cindex @code{Unnamed_Blocks_And_Loops} rule (for @command{gnatcheck})
 
-@item @command{ADA}
-@tab @command{GNAT COMPILE}@*
-Invokes the compiler to compile one or more Ada source files.
+@noindent
+Flag each unnamed block statement and loop statement.
 
-@item @command{ACS ATTACH}@*
-@tab [No equivalent]@*
-Switches control of terminal from current process running the program
-library manager.
+The rule has no parameters.
 
-@item @command{ACS CHECK}
-@tab @command{GNAT MAKE /DEPENDENCY_LIST}@*
-Forms the execution closure of one
-or more compiled units and checks completeness and currency.
 
-@item @command{ACS COMPILE}
-@tab @command{GNAT MAKE /ACTIONS=COMPILE}@*
-Forms the execution closure of one or
-more specified units, checks completeness and currency,
-identifies units that have revised source files, compiles same,
-and recompiles units that are or will become obsolete.
-Also completes incomplete generic instantiations.
 
-@item @command{ACS COPY FOREIGN}
-@tab Copy (*)@*
-Copies a foreign object file into the program library as a
-library unit body.
-
-@item @command{ACS COPY UNIT}
-@tab Copy (*)@*
-Copies a compiled unit from one program library to another.
-
-@item @command{ACS CREATE LIBRARY}
-@tab Create /directory (*)@*
-Creates a program library.
-
-@item @command{ACS CREATE SUBLIBRARY}
-@tab Create /directory (*)@*
-Creates a program sublibrary.
-
-@item @command{ACS DELETE LIBRARY}
-@tab @*
-Deletes a program library and its contents.
+@ignore
+@node Unused_Subprograms
+@subsection @code{Unused_Subprograms} (under construction, GLOBAL)
+@cindex @code{Unused_Subprograms} rule (for @command{gnatcheck})
 
-@item @command{ACS DELETE SUBLIBRARY}
-@tab @*
-Deletes a program sublibrary and its contents.
+@noindent
+Flag all unused subprograms.
 
-@item @command{ACS DELETE UNIT}
-@tab Delete file (*)@*
-On OpenVMS systems, deletes one or more compiled units from
-the current program library.
+This rule has no parameters.
+@end ignore
 
-@item @command{ACS DIRECTORY}
-@tab Directory (*)@*
-On OpenVMS systems, lists units contained in the current
-program library.
 
-@item @command{ACS ENTER FOREIGN}
-@tab Copy (*)@*
-Allows the import of a foreign body as an Ada library
-specification and enters a reference to a pointer.
 
-@item @command{ACS ENTER UNIT}
-@tab Copy (*)@*
-Enters a reference (pointer) from the current program library to
-a unit compiled into another program library.
 
-@item @command{ACS EXIT}
-@tab [No equivalent]@*
-Exits from the program library manager.
+@node USE_PACKAGE_Clauses
+@subsection @code{USE_PACKAGE_Clauses}
+@cindex @code{USE_PACKAGE_Clauses} rule (for @command{gnatcheck})
 
-@item @command{ACS EXPORT}
-@tab Copy (*)@*
-Creates an object file that contains system-specific object code
-for one or more units. With GNAT, object files can simply be copied
-into the desired directory.
+@noindent
+Flag all @code{use} clauses for packages; @code{use type} clauses are
+not flagged.
 
-@item @command{ACS EXTRACT SOURCE}
-@tab Copy (*)@*
-Allows access to the copied source file for each Ada compilation unit
+This rule has no parameters.
 
-@item @command{ACS HELP}
-@tab @command{HELP GNAT}@*
-Provides online help.
 
-@item @command{ACS LINK}
-@tab @command{GNAT LINK}@*
-Links an object file containing Ada units into an executable file.
 
-@item @command{ACS LOAD}
-@tab Copy (*)@*
-Loads (partially compiles) Ada units into the program library.
-Allows loading a program from a collection of files into a library
-without knowing the relationship among units.
+@node Volatile_Objects_Without_Address_Clauses
+@subsection @code{Volatile_Objects_Without_Address_Clauses}
+@cindex @code{Volatile_Objects_Without_Address_Clauses} rule (for @command{gnatcheck})
 
-@item @command{ACS MERGE}
-@tab Copy (*)@*
-Merges into the current program library, one or more units from
-another library where they were modified.
+@noindent
+Flag each volatile object that does not have an address clause.
 
-@item @command{ACS RECOMPILE}
-@tab @command{GNAT MAKE /ACTIONS=COMPILE}@*
-Recompiles from   external or copied source files any obsolete
-unit in the closure. Also, completes any incomplete generic
-instantiations.
+The following check is made: if the pragma @code{Volatile} is applied to a
+data object or to its type, then an address clause must
+be supplied for this object.
 
-@item @command{ACS REENTER}
-@tab @command{GNAT MAKE}@*
-Reenters current references to units compiled after last entered
-with the @command{ACS ENTER UNIT} command.
+This rule does not check the components of data objects,
+array components that are volatile as a result of the pragma
+@code{Volatile_Components}, or objects that are volatile because
+they are atomic as a result of pragmas @code{Atomic} or
+@code{Atomic_Components}.
 
-@item @command{ACS SET LIBRARY}
-@tab Set default (*)@*
-Defines a program library to be the compilation context as well
-as the target library for compiler output and commands in general.
+Only variable declarations, and not constant declarations, are checked.
 
-@item @command{ACS SET PRAGMA}
-@tab Edit @file{gnat.adc} (*)@*
-Redefines specified  values of the library characteristics
-@code{LONG_ FLOAT}, @code{MEMORY_SIZE}, @code{SYSTEM_NAME},
-and @code{Float_Representation}.
+This rule has no parameters.
 
-@item @command{ACS SET SOURCE}
-@tab Define @code{ADA_INCLUDE_PATH} path (*)@*
-Defines the source file search list for the @command{ACS COMPILE} command.
 
-@item @command{ACS SHOW LIBRARY}
-@tab Directory (*)@*
-Lists information about one or more program libraries.
+@c *********************************
+@node Creating Sample Bodies Using gnatstub
+@chapter Creating Sample Bodies Using @command{gnatstub}
+@findex gnatstub
 
-@item @command{ACS SHOW PROGRAM}
-@tab [No equivalent]@*
-Lists information about the execution closure of one or
-more units in the program library.
+@noindent
+@command{gnatstub} creates body stubs, that is, empty but compilable bodies
+for library unit declarations.
 
-@item @command{ACS SHOW SOURCE}
-@tab Show logical @code{ADA_INCLUDE_PATH}@*
-Shows the source file search used when compiling units.
+Note: to invoke @code{gnatstub} with a project file, use the @code{gnat}
+driver (see @ref{The GNAT Driver and Project Files}).
 
-@item @command{ACS SHOW VERSION}
-@tab Compile with @option{VERBOSE} option
-Displays the version number of the compiler and program library
-manager used.
+To create a body stub, @command{gnatstub} has to compile the library
+unit declaration. Therefore, bodies can be created only for legal
+library units. Moreover, if a library unit depends semantically upon
+units located outside the current directory, you have to provide
+the source search path when calling @command{gnatstub}, see the description
+of @command{gnatstub} switches below.
 
-@item @command{ACS SPAWN}
-@tab [No equivalent]@*
-Creates a subprocess of the current process (same as @command{DCL SPAWN}
-command).
+@menu
+* Running gnatstub::
+* Switches for gnatstub::
+@end menu
 
-@item @command{ACS VERIFY}
-@tab [No equivalent]@*
-Performs a series of consistency checks on a program library to
-determine whether the library structure and library files are in
-valid form.
-@end multitable
+@node Running gnatstub
+@section Running @command{gnatstub}
 
 @noindent
+@command{gnatstub} has the command-line interface of the form
 
-@node Input-Output
-@section Input-Output
+@smallexample
+$ gnatstub [switches] filename [directory]
+@end smallexample
 
 @noindent
-On OpenVMS Alpha systems, DEC Ada uses OpenVMS Record
-Management Services (RMS) to perform operations on
-external files.
+where
+@table @emph
+@item filename
+is the name of the source file that contains a library unit declaration
+for which a body must be created. The file name may contain the path
+information.
+The file name does not have to follow the GNAT file name conventions. If the
+name
+does not follow GNAT file naming conventions, the name of the body file must
+be provided
+explicitly as the value of the @option{^-o^/BODY=^@var{body-name}} option.
+If the file name follows the GNAT file naming
+conventions and the name of the body file is not provided,
+@command{gnatstub}
+creates the name
+of the body file from the argument file name by replacing the @file{.ads}
+suffix
+with the @file{.adb} suffix.
 
-@noindent
-DEC Ada and GNAT predefine an identical set of input-
-output packages. To make the use of the
-generic TEXT_IO operations more convenient, DEC Ada
-provides predefined library packages that instantiate the
-integer and floating-point operations for the predefined
-integer and floating-point types as shown in the following table.
+@item directory
+indicates the directory in which the body stub is to be placed (the default
+is the
+current directory)
 
-@multitable @columnfractions .45 .55
-@item @emph{Package Name} @tab Instantiation
+@item switches
+is an optional sequence of switches as described in the next section
+@end table
 
-@item @code{INTEGER_TEXT_IO}
-@tab @code{INTEGER_IO(INTEGER)}
+@node Switches for gnatstub
+@section Switches for @command{gnatstub}
 
-@item @code{SHORT_INTEGER_TEXT_IO}
-@tab @code{INTEGER_IO(SHORT_INTEGER)}
+@table @option
+@c !sort!
 
-@item @code{SHORT_SHORT_INTEGER_TEXT_IO}
-@tab @code{INTEGER_IO(SHORT_SHORT_INTEGER)}
+@item ^-f^/FULL^
+@cindex @option{^-f^/FULL^} (@command{gnatstub})
+If the destination directory already contains a file with the name of the
+body file
+for the argument spec file, replace it with the generated body stub.
 
-@item @code{FLOAT_TEXT_IO}
-@tab @code{FLOAT_IO(FLOAT)}
+@item ^-hs^/HEADER=SPEC^
+@cindex @option{^-hs^/HEADER=SPEC^} (@command{gnatstub})
+Put the comment header (i.e., all the comments preceding the
+compilation unit) from the source of the library unit declaration
+into the body stub.
 
-@item @code{LONG_FLOAT_TEXT_IO}
-@tab @code{FLOAT_IO(LONG_FLOAT)}
-@end multitable
+@item ^-hg^/HEADER=GENERAL^
+@cindex @option{^-hg^/HEADER=GENERAL^} (@command{gnatstub})
+Put a sample comment header into the body stub.
 
-@noindent
-The DEC Ada predefined packages and their operations
-are implemented using OpenVMS Alpha files and input-
-output facilities. DEC Ada supports asynchronous input-
-output on OpenVMS Alpha. Familiarity with the following is
-recommended:
-@itemize @bullet
-@item  RMS file organizations and access methods
+@ifclear vms
+@item -IDIR
+@cindex @option{-IDIR} (@command{gnatstub})
+@itemx -I-
+@cindex @option{-I-} (@command{gnatstub})
+@end ifclear
+@ifset vms
+@item /NOCURRENT_DIRECTORY
+@cindex @option{/NOCURRENT_DIRECTORY} (@command{gnatstub})
+@end ifset
+^These switches have ^This switch has^ the same meaning as in calls to
+@command{gcc}.
+^They define ^It defines ^ the source search path in the call to
+@command{gcc} issued
+by @command{gnatstub} to compile an argument source file.
 
-@item  OpenVMS file specifications and directories
+@item ^-gnatec^/CONFIGURATION_PRAGMAS_FILE=^@var{PATH}
+@cindex @option{^-gnatec^/CONFIGURATION_PRAGMAS_FILE^} (@command{gnatstub})
+This switch has the same meaning as in calls to @command{gcc}.
+It defines the additional configuration file to be passed to the call to
+@command{gcc} issued
+by @command{gnatstub} to compile an argument source file.
 
-@item  OpenVMS File Definition Language (FDL)
-@end itemize
+@item ^-gnatyM^/MAX_LINE_LENGTH=^@var{n}
+@cindex @option{^-gnatyM^/MAX_LINE_LENGTH^} (@command{gnatstub})
+(@var{n} is a non-negative integer). Set the maximum line length in the
+body stub to @var{n}; the default is 79. The maximum value that can be
+specified is 32767. Note that in the special case of configuration
+pragma files, the maximum is always 32767 regardless of whether or
+not this switch appears.
 
-@noindent
-GNAT provides I/O facilities that are completely
-compatible with DEC Ada. The distribution includes the
-standard DEC Ada versions of all I/O packages, operating
-in a manner compatible with DEC Ada. In particular, the
-following packages are by default the DEC Ada (Ada 83)
-versions of these packages rather than the renamings
-suggested in annex J of the Ada 95 Reference Manual:
-@itemize @bullet
-@item  @code{TEXT_IO}
+@item ^-gnaty^/STYLE_CHECKS=^@var{n}
+@cindex @option{^-gnaty^/STYLE_CHECKS=^} (@command{gnatstub})
+(@var{n} is a non-negative integer from 1 to 9). Set the indentation level in
+the generated body sample to @var{n}.
+The default indentation is 3.
 
-@item  @code{SEQUENTIAL_IO}
+@item ^-gnatyo^/ORDERED_SUBPROGRAMS^
+@cindex @option{^-gnato^/ORDERED_SUBPROGRAMS^} (@command{gnatstub})
+Order local bodies alphabetically. (By default local bodies are ordered
+in the same way as the corresponding local specs in the argument spec file.)
 
-@item  @code{DIRECT_IO}
-@end itemize
+@item ^-i^/INDENTATION=^@var{n}
+@cindex @option{^-i^/INDENTATION^} (@command{gnatstub})
+Same as @option{^-gnaty^/STYLE_CHECKS=^@var{n}}
 
-@noindent
-The use of the standard Ada 95 syntax for child packages (for
-example, @code{ADA.TEXT_IO}) retrieves the Ada 95 versions of these
-packages, as defined in the Ada 95 Reference Manual.
-GNAT provides DIGITAL-compatible predefined instantiations
-of the @code{TEXT_IO} packages, and also
-provides the standard predefined instantiations required
-by the Ada 95 Reference Manual.
-
-For further information on how GNAT interfaces to the file
-system or how I/O is implemented in programs written in
-mixed languages, see the chapter ``Implementation of the
-Standard I/O'' in the @cite{GNAT Reference Manual}.
-This chapter covers the following:
-@itemize @bullet
-@item  Standard I/O packages
+@item ^-k^/TREE_FILE=SAVE^
+@cindex @option{^-k^/TREE_FILE=SAVE^} (@command{gnatstub})
+Do not remove the tree file (i.e., the snapshot of the compiler internal
+structures used by @command{gnatstub}) after creating the body stub.
 
-@item  @code{FORM} strings
+@item ^-l^/LINE_LENGTH=^@var{n}
+@cindex @option{^-l^/LINE_LENGTH^} (@command{gnatstub})
+Same as @option{^-gnatyM^/MAX_LINE_LENGTH=^@var{n}}
 
-@item  @code{ADA.DIRECT_IO}
+@item ^-o^/BODY=^@var{body-name}
+@cindex @option{^-o^/BODY^} (@command{gnatstub})
+Body file name.  This should be set if the argument file name does not
+follow
+the GNAT file naming
+conventions. If this switch is omitted the default name for the body will be
+obtained
+from the argument file name according to the GNAT file naming conventions.
 
-@item  @code{ADA.SEQUENTIAL_IO}
+@item ^-q^/QUIET^
+@cindex @option{^-q^/QUIET^} (@command{gnatstub})
+Quiet mode: do not generate a confirmation when a body is
+successfully created, and do not generate a message when a body is not
+required for an
+argument unit.
 
-@item  @code{ADA.TEXT_IO}
+@item ^-r^/TREE_FILE=REUSE^
+@cindex @option{^-r^/TREE_FILE=REUSE^} (@command{gnatstub})
+Reuse the tree file (if it exists) instead of creating it.  Instead of
+creating the tree file for the library unit declaration, @command{gnatstub}
+tries to find it in the current directory and use it for creating
+a body. If the tree file is not found, no body is created. This option
+also implies @option{^-k^/SAVE^}, whether or not
+the latter is set explicitly.
 
-@item  Stream pointer positioning
+@item ^-t^/TREE_FILE=OVERWRITE^
+@cindex @option{^-t^/TREE_FILE=OVERWRITE^} (@command{gnatstub})
+Overwrite the existing tree file.  If the current directory already
+contains the file which, according to the GNAT file naming rules should
+be considered as a tree file for the argument source file,
+@command{gnatstub}
+will refuse to create the tree file needed to create a sample body
+unless this option is set.
 
-@item  Reading and writing non-regular files
+@item ^-v^/VERBOSE^
+@cindex @option{^-v^/VERBOSE^} (@command{gnatstub})
+Verbose mode: generate version information.
 
-@item  @code{GET_IMMEDIATE}
+@end table
 
-@item  Treating @code{TEXT_IO} files as streams
+@node Other Utility Programs
+@chapter Other Utility Programs
 
-@item  Shared files
+@noindent
+This chapter discusses some other utility programs available in the Ada
+environment.
 
-@item  Open modes
-@end itemize
+@menu
+* Using Other Utility Programs with GNAT::
+* The External Symbol Naming Scheme of GNAT::
+* Converting Ada Files to html with gnathtml::
+* Installing gnathtml::
+@ifset vms
+* LSE::
+* Profiling::
+@end ifset
+@end menu
 
-@node Implementation Limits
-@section Implementation Limits
+@node Using Other Utility Programs with GNAT
+@section Using Other Utility Programs with GNAT
 
 @noindent
-The following table lists implementation limits for DEC Ada
-and GNAT systems.
-@multitable @columnfractions .60 .20 .20
-@sp 1
-@item  @emph{Compilation Parameter}
-@tab   @emph{DEC Ada}
-@tab   @emph{GNAT}
-@sp 1
-
-@item  In a subprogram or entry  declaration, maximum number of
-       formal parameters that are of an unconstrained record type
-@tab   32
-@tab   No set limit
-@sp 1
+The object files generated by GNAT are in standard system format and in
+particular the debugging information uses this format. This means
+programs generated by GNAT can be used with existing utilities that
+depend on these formats.
 
-@item  Maximum identifier length (number of characters)
-@tab   255
-@tab   255
-@sp 1
+@ifclear vms
+In general, any utility program that works with C will also often work with
+Ada programs generated by GNAT. This includes software utilities such as
+gprof (a profiling program), @code{gdb} (the FSF debugger), and utilities such
+as Purify.
+@end ifclear
 
-@item  Maximum number of characters in a source line
-@tab   255
-@tab   255
-@sp 1
+@node The External Symbol Naming Scheme of GNAT
+@section The External Symbol Naming Scheme of GNAT
 
-@item  Maximum collection size   (number of bytes)
-@tab   2**31-1
-@tab   2**31-1
-@sp 1
+@noindent
+In order to interpret the output from GNAT, when using tools that are
+originally intended for use with other languages, it is useful to
+understand the conventions used to generate link names from the Ada
+entity names.
 
-@item  Maximum number of discriminants for a record type
-@tab   245
-@tab   No set limit
-@sp 1
+All link names are in all lowercase letters. With the exception of library
+procedure names, the mechanism used is simply to use the full expanded
+Ada name with dots replaced by double underscores. For example, suppose
+we have the following package spec:
 
-@item  Maximum number of formal parameters in an entry or
-       subprogram declaration
-@tab   246
-@tab    No set limit
-@sp 1
+@smallexample @c ada
+@group
+@cartouche
+package QRS is
+   MN : Integer;
+end QRS;
+@end cartouche
+@end group
+@end smallexample
 
-@item  Maximum number of dimensions in an array type
-@tab   255
-@tab   No set limit
-@sp 1
+@noindent
+The variable @code{MN} has a full expanded Ada name of @code{QRS.MN}, so
+the corresponding link name is @code{qrs__mn}.
+@findex Export
+Of course if a @code{pragma Export} is used this may be overridden:
 
-@item  Maximum number of library  units and subunits in a compilation.
-@tab   4095
-@tab   No set limit
-@sp 1
+@smallexample @c ada
+@group
+@cartouche
+package Exports is
+   Var1 : Integer;
+   pragma Export (Var1, C, External_Name => "var1_name");
+   Var2 : Integer;
+   pragma Export (Var2, C, Link_Name => "var2_link_name");
+end Exports;
+@end cartouche
+@end group
+@end smallexample
 
-@item  Maximum number of library units and subunits in an execution.
-@tab   16383
-@tab   No set limit
-@sp 1
+@noindent
+In this case, the link name for @var{Var1} is whatever link name the
+C compiler would assign for the C function @var{var1_name}. This typically
+would be either @var{var1_name} or @var{_var1_name}, depending on operating
+system conventions, but other possibilities exist. The link name for
+@var{Var2} is @var{var2_link_name}, and this is not operating system
+dependent.
 
-@item  Maximum number of objects declared with the pragma @code{COMMON_OBJECT}
-       or @code{PSECT_OBJECT}
-@tab   32757
-@tab   No set limit
-@sp 1
+@findex _main
+One exception occurs for library level procedures. A potential ambiguity
+arises between the required name @code{_main} for the C main program,
+and the name we would otherwise assign to an Ada library level procedure
+called @code{Main} (which might well not be the main program).
 
-@item  Maximum number of enumeration literals in an enumeration type
-       definition
-@tab   65535
-@tab   No set limit
-@sp 1
+To avoid this ambiguity, we attach the prefix @code{_ada_} to such
+names. So if we have a library level procedure such as
 
-@item  Maximum number of lines in a source file
-@tab   65534
-@tab   No set limit
-@sp 1
+@smallexample @c ada
+@group
+@cartouche
+procedure Hello (S : String);
+@end cartouche
+@end group
+@end smallexample
 
-@item  Maximum number of bits in any object
-@tab   2**31-1
-@tab   2**31-1
-@sp 1
+@noindent
+the external name of this procedure will be @var{_ada_hello}.
 
-@item  Maximum size of the static portion of a stack frame (approximate)
-@tab   2**31-1
-@tab   2**31-1
-@end multitable
 
-@node  Tools
-@section Tools
+@node Converting Ada Files to html with gnathtml
+@section Converting Ada Files to HTML with @code{gnathtml}
 
-@end ifset
+@noindent
+This @code{Perl} script allows Ada source files to be browsed using
+standard Web browsers. For installation procedure, see the section
+@xref{Installing gnathtml}.
 
+Ada reserved keywords are highlighted in a bold font and Ada comments in
+a blue font. Unless your program was compiled with the gcc @option{-gnatx}
+switch to suppress the generation of cross-referencing information, user
+defined variables and types will appear in a different color; you will
+be able to click on any identifier and go to its declaration.
 
-@c **************************************
-@node Platform-Specific Information for the Run-Time Libraries
-@appendix Platform-Specific Information for the Run-Time Libraries
-@cindex Tasking and threads libraries
-@cindex Threads libraries and tasking
-@cindex Run-time libraries (platform-specific information)
+The command line is as follow:
+@smallexample
+$ perl gnathtml.pl [^switches^options^] ada-files
+@end smallexample
 
 @noindent
-The GNAT run-time implementation
-may vary with respect to both the underlying threads library and
-the exception handling scheme.
-For threads support, one or more of the following are supplied:
-@itemize @bullet
-@item @b{native threads library}, a binding to the thread package from
-the underlying operating system
+You can pass it as many Ada files as you want. @code{gnathtml} will generate
+an html file for every ada file, and a global file called @file{index.htm}.
+This file is an index of every identifier defined in the files.
 
-@item @b{FSU threads library}, a binding to the Florida State University
-threads implementation, which complies fully with the requirements of Annex D
+The available ^switches^options^ are the following ones:
 
-@item @b{pthreads library} (Sparc Solaris only), a binding to the Solaris
-POSIX thread package
-@end itemize
+@table @option
+@item -83
+@cindex @option{-83} (@code{gnathtml})
+Only the Ada 83 subset of keywords will be highlighted.
 
-@noindent
-For exception handling, either or both of two models are supplied:
-@itemize @bullet
-@item @b{Zero-Cost Exceptions} (``ZCX''),@footnote{
-Most programs should experience a substantial speed improvement by
-being compiled with a ZCX run-time.
-This is especially true for
-tasking applications or applications with many exception handlers.}
-@cindex Zero-Cost Exceptions
-@cindex ZCX (Zero-Cost Exceptions)
-which uses binder-generated tables that
-are interrogated at run time to locate a handler
+@item -cc @var{color}
+@cindex @option{-cc} (@code{gnathtml})
+This option allows you to change the color used for comments. The default
+value is green. The color argument can be any name accepted by html.
 
-@item @b{setjmp / longjmp} (``SJLJ''),
-@cindex setjmp/longjmp Exception Model
-@cindex SJLJ (setjmp/longjmp Exception Model)
-which uses dynamically-set data to establish
-the set of handlers
-@end itemize
+@item -d
+@cindex @option{-d} (@code{gnathtml})
+If the Ada files depend on some other files (for instance through
+@code{with} clauses, the latter files will also be converted to html.
+Only the files in the user project will be converted to html, not the files
+in the run-time library itself.
 
-@noindent
-This appendix summarizes which combinations of threads and exception support
-are supplied on various GNAT platforms.
-It then shows how to select a particular library either
-permanently or temporarily,
-explains the properties of (and tradeoffs among) the various threads
-libraries, and provides some additional
-information about several specific platforms.
+@item -D
+@cindex @option{-D} (@code{gnathtml})
+This command is the same as @option{-d} above, but @command{gnathtml} will
+also look for files in the run-time library, and generate html files for them.
 
-@menu
-* Summary of Run-Time Configurations::
-* Specifying a Run-Time Library::
-* Choosing between Native and FSU Threads Libraries::
-* Choosing the Scheduling Policy::
-* Solaris-Specific Considerations::
-* IRIX-Specific Considerations::
-* Linux-Specific Considerations::
-* AIX-Specific Considerations::
-@end menu
+@item -ext @var{extension}
+@cindex @option{-ext} (@code{gnathtml})
+This option allows you to change the extension of the generated HTML files.
+If you do not specify an extension, it will default to @file{htm}.
 
+@item -f
+@cindex @option{-f} (@code{gnathtml})
+By default, gnathtml will generate html links only for global entities
+('with'ed units, global variables and types,@dots{}).  If you specify
+@option{-f} on the command line, then links will be generated for local
+entities too.
 
-@node Summary of Run-Time Configurations
-@section Summary of Run-Time Configurations
+@item -l @var{number}
+@cindex @option{-l} (@code{gnathtml})
+If this ^switch^option^ is provided and @var{number} is not 0, then
+@code{gnathtml} will number the html files every @var{number} line.
 
+@item -I @var{dir}
+@cindex @option{-I} (@code{gnathtml})
+Specify a directory to search for library files (@file{.ALI} files) and
+source files. You can provide several -I switches on the command line,
+and the directories will be parsed in the order of the command line.
 
-@multitable @columnfractions .30 .70
-@item @b{alpha-openvms}
-@item @code{@ @ }@i{rts-native (default)}
-@item @code{@ @ @ @ }Tasking    @tab native VMS threads
-@item @code{@ @ @ @ }Exceptions @tab ZCX
-@*
-@item @b{pa-hpux}
-@item @code{@ @ }@i{rts-native (default)}
-@item @code{@ @ @ @ }Tasking    @tab native HP threads library
-@item @code{@ @ @ @ }Exceptions @tab ZCX
-@*
-@item @code{@ @ }@i{rts-sjlj}
-@item @code{@ @ @ @ }Tasking    @tab native HP threads library
-@item @code{@ @ @ @ }Exceptions @tab SJLJ
-@*
-@item @b{sparc-solaris}  @tab
-@item @code{@ @ }@i{rts-native (default)}
-@item @code{@ @ @ @ }Tasking    @tab native Solaris threads library
-@item @code{@ @ @ @ }Exceptions @tab ZCX
-@*
-@item @code{@ @ }@i{rts-fsu}    @tab
-@item @code{@ @ @ @ }Tasking    @tab FSU threads library
-@item @code{@ @ @ @ }Exceptions @tab SJLJ
-@*
-@item @code{@ @ }@i{rts-m64}
-@item @code{@ @ @ @ }Tasking     @tab native Solaris threads library
-@item @code{@ @ @ @ }Exceptions  @tab ZCX
-@item @code{@ @ @ @ }Constraints @tab Use only when compiling in 64-bit mode;
-@item    @tab Use only on Solaris 8 or later.
-@item    @tab @xref{Building and Debugging 64-bit Applications}, for details.
-@*
-@item @code{@ @ }@i{rts-pthread}
-@item @code{@ @ @ @ }Tasking    @tab pthreads library
-@item @code{@ @ @ @ }Exceptions @tab ZCX
-@*
-@item @code{@ @ }@i{rts-sjlj}
-@item @code{@ @ @ @ }Tasking    @tab native Solaris threads library
-@item @code{@ @ @ @ }Exceptions @tab SJLJ
-@*
-@item @b{x86-linux}
-@item @code{@ @ }@i{rts-native (default)}
-@item @code{@ @ @ @ }Tasking    @tab LinuxThread library
-@item @code{@ @ @ @ }Exceptions @tab ZCX
-@*
-@item @code{@ @ }@i{rts-fsu}
-@item @code{@ @ @ @ }Tasking    @tab FSU threads library
-@item @code{@ @ @ @ }Exceptions @tab SJLJ
-@*
-@item @code{@ @ }@i{rts-sjlj}
-@item @code{@ @ @ @ }Tasking    @tab LinuxThread library
-@item @code{@ @ @ @ }Exceptions @tab SJLJ
-@*
-@item @b{x86-windows}
-@item @code{@ @ }@i{rts-native (default)}
-@item @code{@ @ @ @ }Tasking    @tab native Win32 threads
-@item @code{@ @ @ @ }Exceptions @tab SJLJ
-@*
-@end multitable
+@item -o @var{dir}
+@cindex @option{-o} (@code{gnathtml})
+Specify the output directory for html files. By default, gnathtml will
+saved the generated html files in a subdirectory named @file{html/}.
 
+@item -p @var{file}
+@cindex @option{-p} (@code{gnathtml})
+If you are using Emacs and the most recent Emacs Ada mode, which provides
+a full Integrated Development Environment for compiling, checking,
+running and debugging applications, you may use @file{.gpr} files
+to give the directories where Emacs can find sources and object files.
 
+Using this ^switch^option^, you can tell gnathtml to use these files.
+This allows you to get an html version of your application, even if it
+is spread over multiple directories.
 
-@node Specifying a Run-Time Library
-@section Specifying a Run-Time Library
+@item -sc @var{color}
+@cindex @option{-sc} (@code{gnathtml})
+This ^switch^option^ allows you to change the color used for symbol
+definitions.
+The default value is red. The color argument can be any name accepted by html.
 
-@noindent
-The @file{adainclude} subdirectory containing the sources of the GNAT
-run-time library, and the @file{adalib} subdirectory containing the
-@file{ALI} files and the static and/or shared GNAT library, are located
-in the gcc target-dependent area:
+@item -t @var{file}
+@cindex @option{-t} (@code{gnathtml})
+This ^switch^option^ provides the name of a file. This file contains a list of
+file names to be converted, and the effect is exactly as though they had
+appeared explicitly on the command line. This
+is the recommended way to work around the command line length limit on some
+systems.
 
-@smallexample
-target=$prefix/lib/gcc-lib/gcc-@i{dumpmachine}/gcc-@i{dumpversion}/
-@end smallexample
+@end table
 
-@noindent
-As indicated above, on some platforms several run-time libraries are supplied.
-These libraries are installed in the target dependent area and
-contain a complete source and binary subdirectory. The detailed description
-below explains the differences between the different libraries in terms of
-their thread support.
+@node Installing gnathtml
+@section Installing @code{gnathtml}
 
-The default run-time library (when GNAT is installed) is @emph{rts-native}.
-This default run time is selected by the means of soft links.
-For example on x86-linux:
+@noindent
+@code{Perl} needs to be installed on your machine to run this script.
+@code{Perl} is freely available for almost every architecture and
+Operating System via the Internet.
 
+On Unix systems, you  may want to modify  the  first line of  the script
+@code{gnathtml},  to explicitly  tell  the Operating  system  where Perl
+is. The syntax of this line is:
 @smallexample
-@group
- $(target-dir)
-     |
-     +--- adainclude----------+
-     |                        |
-     +--- adalib-----------+  |
-     |                     |  |
-     +--- rts-native       |  |
-     |    |                |  |
-     |    +--- adainclude <---+
-     |    |                |
-     |    +--- adalib <----+
-     |
-     +--- rts-fsu
-     |    |
-     |    +--- adainclude
-     |    |
-     |    +--- adalib
-     |
-     +--- rts-sjlj
-          |
-          +--- adainclude
-          |
-          +--- adalib
-@end group
+#!full_path_name_to_perl
 @end smallexample
 
 @noindent
-If the @i{rts-fsu} library is to be selected on a permanent basis,
-these soft links can be modified with the following commands:
+Alternatively, you may run the script using the following command line:
 
 @smallexample
-$ cd $target
-$ rm -f adainclude adalib
-$ ln -s rts-fsu/adainclude adainclude
-$ ln -s rts-fsu/adalib adalib
+$ perl gnathtml.pl [switches] files
 @end smallexample
 
+@ifset vms
+@node LSE
+@section LSE
+@findex LSE
+
 @noindent
-Alternatively, you can specify @file{rts-fsu/adainclude} in the file
-@file{$target/ada_source_path} and @file{rts-fsu/adalib} in
-@file{$target/ada_object_path}.
+The GNAT distribution provides an Ada 95 template for the HP Language
+Sensitive Editor (LSE), a component of DECset. In order to
+access it, invoke LSE with the qualifier /ENVIRONMENT=GNU:[LIB]ADA95.ENV.
 
-Selecting another run-time library temporarily can be
-achieved by the regular mechanism for GNAT object or source path selection:
+@node Profiling
+@section Profiling
+@findex PCA
 
-@itemize @bullet
-@item
-Set the environment variables:
+@noindent
+GNAT supports The HP Performance Coverage Analyzer (PCA), a component
+of DECset. To use it proceed as outlined under ``HELP PCA'', except for running
+the collection phase with the /DEBUG qualifier.
 
 @smallexample
-$ ADA_INCLUDE_PATH=$target/rts-fsu/adainclude:$ADA_INCLUDE_PATH
-$ ADA_OBJECTS_PATH=$target/rts-fsu/adalib:$ADA_OBJECTS_PATH
-$ export ADA_INCLUDE_PATH ADA_OBJECTS_PATH
+$ GNAT MAKE /DEBUG <PROGRAM_NAME>
+$ DEFINE LIB$DEBUG PCA$COLLECTOR
+$ RUN/DEBUG <PROGRAM_NAME>
 @end smallexample
-
-@item
-Use @option{-aI$target/rts-fsu/adainclude}
-and @option{-aO$target/rts-fsu/adalib}
-on the @command{gnatmake} command line
-
-@item
-Use the switch @option{--RTS}; e.g., @option{--RTS=fsu}
-@cindex @option{--RTS} option
-@end itemize
-
 @noindent
-You can similarly switch to @emph{rts-sjlj}.
+@end ifset
 
-@node Choosing between Native and FSU Threads Libraries
-@section Choosing between Native and FSU Threads Libraries
-@cindex Native threads library
-@cindex FSU threads library
+@node Running and Debugging Ada Programs
+@chapter Running and Debugging Ada Programs
+@cindex Debugging
 
 @noindent
-Some GNAT implementations offer a choice between
-native threads and FSU threads.
+This chapter discusses how to debug Ada programs.
+@ifset vms
+It applies to GNAT on the Alpha OpenVMS platform;
+for I64 OpenVMS please refer to the @cite{OpenVMS Debugger Manual},
+since HP has implemented Ada support in the OpenVMS debugger on I64.
+@end ifset
 
-@itemize @bullet
+An incorrect Ada program may be handled in three ways by the GNAT compiler:
+
+@enumerate
 @item
-The @emph{native threads} library correspond to the standard system threads
-implementation (e.g. LinuxThreads on GNU/Linux,
-@cindex LinuxThreads library
-POSIX threads on AIX, or
-Solaris threads on Solaris). When this option is chosen, GNAT provides
-a full and accurate implementation of the core language tasking model
-as described in Chapter 9 of the Ada Reference Manual,
-but might not (and probably does not) implement
-the exact semantics as specified in @w{Annex D} (the Real-Time Systems Annex).
-@cindex Annex D (Real-Time Systems Annex) compliance
-@cindex Real-Time Systems Annex compliance
-Indeed, the reason that a choice of libraries is offered
-on a given target is because some of the
-ACATS tests for @w{Annex D} fail using the native threads library.
-As far as possible, this library is implemented
-in accordance with Ada semantics (e.g., modifying priorities as required
-to simulate ceiling locking),
-but there are often slight inaccuracies, most often in the area of
-absolutely respecting the priority rules on a single
-processor.
-Moreover, it is not possible in general to define the exact behavior,
-because the native threads implementations
-are not well enough documented.
-
-On systems where the @code{SCHED_FIFO} POSIX scheduling policy is supported,
-@cindex POSIX scheduling policies
-@cindex @code{SCHED_FIFO} scheduling policy
-native threads will provide a behavior very close to the @w{Annex D}
-requirements (i.e., a run-till-blocked scheduler with fixed priorities), but
-on some systems (in particular GNU/Linux and Solaris), you need to have root
-privileges to use the @code{SCHED_FIFO} policy.
-
-@item
-The @emph{FSU threads} library provides a completely accurate implementation
-of @w{Annex D}.
-Thus, operating with this library, GNAT is 100% compliant with both the core
-and all @w{Annex D}
-requirements.
-The formal validations for implementations offering
-a choice of threads packages are always carried out using the FSU
-threads option.
-@end itemize
+The illegality may be a violation of the static semantics of Ada. In
+that case GNAT diagnoses the constructs in the program that are illegal.
+It is then a straightforward matter for the user to modify those parts of
+the program.
 
-@noindent
-From these considerations, it might seem that FSU threads are the
-better choice,
-but that is by no means always the case. The FSU threads package
-operates with all Ada tasks appearing to the system to be a single
-thread. This is often considerably more efficient than operating
-with separate threads, since for example, switching between tasks
-can be accomplished without the (in some cases considerable)
-overhead of a context switch between two system threads. However,
-it means that you may well lose concurrency at the system
-level. Notably, some system operations (such as I/O) may block all
-tasks in a program and not just the calling task. More
-significantly, the FSU threads approach likely means you cannot
-take advantage of multiple processors, since for this you need
-separate threads (or even separate processes) to operate on
-different processors.
+@item
+The illegality may be a violation of the dynamic semantics of Ada. In
+that case the program compiles and executes, but may generate incorrect
+results, or may terminate abnormally with some exception.
 
-For most programs, the native threads library is
-usually the better choice. Use the FSU threads if absolute
-conformance to @w{Annex D} is important for your application, or if
-you find that the improved efficiency of FSU threads is significant to you.
+@item
+When presented with a program that contains convoluted errors, GNAT
+itself may terminate abnormally without providing full diagnostics on
+the incorrect user program.
+@end enumerate
 
-Note also that to take full advantage of Florist and Glade, it is highly
-recommended that you use native threads.
+@menu
+* The GNAT Debugger GDB::
+* Running GDB::
+* Introduction to GDB Commands::
+* Using Ada Expressions::
+* Calling User-Defined Subprograms::
+* Using the Next Command in a Function::
+* Ada Exceptions::
+* Ada Tasks::
+* Debugging Generic Units::
+* GNAT Abnormal Termination or Failure to Terminate::
+* Naming Conventions for GNAT Source Files::
+* Getting Internal Debugging Information::
+* Stack Traceback::
+@end menu
 
+@cindex Debugger
+@findex gdb
 
-@node Choosing the Scheduling Policy
-@section Choosing the Scheduling Policy
+@node The GNAT Debugger GDB
+@section The GNAT Debugger GDB
 
 @noindent
-When using a POSIX threads implementation, you have a choice of several
-scheduling policies: @code{SCHED_FIFO},
-@cindex @code{SCHED_FIFO} scheduling policy
-@code{SCHED_RR}
-@cindex @code{SCHED_RR} scheduling policy
-and @code{SCHED_OTHER}.
-@cindex @code{SCHED_OTHER} scheduling policy
-Typically, the default is @code{SCHED_OTHER}, while using @code{SCHED_FIFO}
-or @code{SCHED_RR} requires special (e.g., root) privileges.
+@code{GDB} is a general purpose, platform-independent debugger that
+can be used to debug mixed-language programs compiled with @command{gcc},
+and in particular is capable of debugging Ada programs compiled with
+GNAT. The latest versions of @code{GDB} are Ada-aware and can handle
+complex Ada data structures.
 
-By default, GNAT uses the @code{SCHED_OTHER} policy. To specify
-@code{SCHED_FIFO},
-@cindex @code{SCHED_FIFO} scheduling policy
-you can use one of the following:
+The manual @cite{Debugging with GDB}
+@ifset vms
+, located in the GNU:[DOCS] directory,
+@end ifset
+contains full details on the usage of @code{GDB}, including a section on
+its usage on programs. This manual should be consulted for full
+details. The section that follows is a brief introduction to the
+philosophy and use of @code{GDB}.
 
-@itemize @bullet
-@item
-@code{pragma Time_Slice (0.0)}
-@cindex pragma Time_Slice
-@item
-the corresponding binder option @option{-T0}
-@cindex @option{-T0} option
-@item
-@code{pragma Task_Dispatching_Policy (FIFO_Within_Priorities)}
-@cindex pragma Task_Dispatching_Policy
-@end itemize
+When GNAT programs are compiled, the compiler optionally writes debugging
+information into the generated object file, including information on
+line numbers, and on declared types and variables. This information is
+separate from the generated code. It makes the object files considerably
+larger, but it does not add to the size of the actual executable that
+will be loaded into memory, and has no impact on run-time performance. The
+generation of debug information is triggered by the use of the
+^-g^/DEBUG^ switch in the @command{gcc} or @command{gnatmake} command
+used to carry out the compilations. It is important to emphasize that
+the use of these options does not change the generated code.
 
-@noindent
-To specify @code{SCHED_RR},
-@cindex @code{SCHED_RR} scheduling policy
-you should use @code{pragma Time_Slice} with a
-value greater than @code{0.0}, or else use the corresponding @option{-T}
-binder option.
+The debugging information is written in standard system formats that
+are used by many tools, including debuggers and profilers. The format
+of the information is typically designed to describe C types and
+semantics, but GNAT implements a translation scheme which allows full
+details about Ada types and variables to be encoded into these
+standard C formats. Details of this encoding scheme may be found in
+the file exp_dbug.ads in the GNAT source distribution. However, the
+details of this encoding are, in general, of no interest to a user,
+since @code{GDB} automatically performs the necessary decoding.
 
+When a program is bound and linked, the debugging information is
+collected from the object files, and stored in the executable image of
+the program. Again, this process significantly increases the size of
+the generated executable file, but it does not increase the size of
+the executable program itself. Furthermore, if this program is run in
+the normal manner, it runs exactly as if the debug information were
+not present, and takes no more actual memory.
 
+However, if the program is run under control of @code{GDB}, the
+debugger is activated.  The image of the program is loaded, at which
+point it is ready to run.  If a run command is given, then the program
+will run exactly as it would have if @code{GDB} were not present. This
+is a crucial part of the @code{GDB} design philosophy.  @code{GDB} is
+entirely non-intrusive until a breakpoint is encountered.  If no
+breakpoint is ever hit, the program will run exactly as it would if no
+debugger were present. When a breakpoint is hit, @code{GDB} accesses
+the debugging information and can respond to user commands to inspect
+variables, and more generally to report on the state of execution.
 
-@node Solaris-Specific Considerations
-@section Solaris-Specific Considerations
-@cindex Solaris Sparc threads libraries
+@c **************
+@node Running GDB
+@section Running GDB
 
 @noindent
-This section addresses some topics related to the various threads libraries
-on Sparc Solaris and then provides some information on building and
-debugging 64-bit applications.
+This section describes how to initiate the debugger.
+@c The above sentence is really just filler, but it was otherwise
+@c clumsy to get the first paragraph nonindented given the conditional
+@c nature of the description
 
-@menu
-* Solaris Threads Issues::
-* Building and Debugging 64-bit Applications::
-@end menu
+@ifclear vms
+The debugger can be launched from a @code{GPS} menu or
+directly from the command line. The description below covers the latter use.
+All the commands shown can be used in the @code{GPS} debug console window,
+but there are usually more GUI-based ways to achieve the same effect.
+@end ifclear
 
+The command to run @code{GDB} is
 
-@node Solaris Threads Issues
-@subsection Solaris Threads Issues
+@smallexample
+$ ^gdb program^GDB PROGRAM^
+@end smallexample
 
 @noindent
-Starting with version 3.14, GNAT under Solaris comes with a new tasking
-run-time library based on POSIX threads --- @emph{rts-pthread}.
-@cindex rts-pthread threads library
-This run-time library has the advantage of being mostly shared across all
-POSIX-compliant thread implementations, and it also provides under
-@w{Solaris 8} the @code{PTHREAD_PRIO_INHERIT}
-@cindex @code{PTHREAD_PRIO_INHERIT} policy (under rts-pthread)
-and @code{PTHREAD_PRIO_PROTECT}
-@cindex @code{PTHREAD_PRIO_PROTECT} policy (under rts-pthread)
-semantics that can be selected using the predefined pragma
-@code{Locking_Policy}
-@cindex pragma Locking_Policy (under rts-pthread)
-with respectively
-@code{Inheritance_Locking} and @code{Ceiling_Locking} as the policy.
-@cindex @code{Inheritance_Locking} (under rts-pthread)
-@cindex @code{Ceiling_Locking} (under rts-pthread)
+where @code{^program^PROGRAM^} is the name of the executable file. This
+activates the debugger and results in a prompt for debugger commands.
+The simplest command is simply @code{run}, which causes the program to run
+exactly as if the debugger were not present. The following section
+describes some of the additional commands that can be given to @code{GDB}.
 
-As explained above, the native run-time library is based on the Solaris thread
-library (@code{libthread}) and is the default library.
-The FSU run-time library is based on the FSU threads.
-@cindex FSU threads library
+@c *******************************
+@node Introduction to GDB Commands
+@section Introduction to GDB Commands
 
-Starting with Solaris 2.5.1, when the Solaris threads library is used
-(this is the default), programs
-compiled with GNAT can automatically take advantage of
-and can thus execute on multiple processors.
-The user can alternatively specify a processor on which the program should run
-to emulate a single-processor system. The multiprocessor / uniprocessor choice
-is made by
-setting the environment variable @code{GNAT_PROCESSOR}
-@cindex @code{GNAT_PROCESSOR} environment variable (on Sparc Solaris)
-to one of the following:
+@noindent
+@code{GDB} contains a large repertoire of commands. The manual
+@cite{Debugging with GDB}
+@ifset vms
+(located in the GNU:[DOCS] directory)
+@end ifset
+includes extensive documentation on the use
+of these commands, together with examples of their use. Furthermore,
+the command @command{help} invoked from within GDB activates a simple help
+facility which summarizes the available commands and their options.
+In this section we summarize a few of the most commonly
+used commands to give an idea of what @code{GDB} is about. You should create
+a simple program with debugging information and experiment with the use of
+these @code{GDB} commands on the program as you read through the
+following section.
 
 @table @code
-@item -2
-Use the default configuration (run the program on all
-         available processors) - this is the same as having
-         @code{GNAT_PROCESSOR} unset
+@item set args @var{arguments}
+The @var{arguments} list above is a list of arguments to be passed to
+the program on a subsequent run command, just as though the arguments
+had been entered on a normal invocation of the program. The @code{set args}
+command is not needed if the program does not require arguments.
 
-@item -1
-Let the run-time implementation choose one processor and run the program on
-         that processor
+@item run
+The @code{run} command causes execution of the program to start from
+the beginning. If the program is already running, that is to say if
+you are currently positioned at a breakpoint, then a prompt will ask
+for confirmation that you want to abandon the current execution and
+restart.
 
-@item 0 .. Last_Proc
-Run the program on the specified processor.
-  @code{Last_Proc} is equal to @code{_SC_NPROCESSORS_CONF - 1}
-(where @code{_SC_NPROCESSORS_CONF} is a system variable).
-@end table
+@item breakpoint @var{location}
+The breakpoint command sets a breakpoint, that is to say a point at which
+execution will halt and @code{GDB} will await further
+commands. @var{location} is
+either a line number within a file, given in the format @code{file:linenumber},
+or it is the name of a subprogram. If you request that a breakpoint be set on
+a subprogram that is overloaded, a prompt will ask you to specify on which of
+those subprograms you want to breakpoint. You can also
+specify that all of them should be breakpointed. If the program is run
+and execution encounters the breakpoint, then the program
+stops and @code{GDB} signals that the breakpoint was encountered by
+printing the line of code before which the program is halted.
 
+@item breakpoint exception @var{name}
+A special form of the breakpoint command which breakpoints whenever
+exception @var{name} is raised.
+If @var{name} is omitted,
+then a breakpoint will occur when any exception is raised.
 
-@node Building and Debugging 64-bit Applications
-@subsection Building and Debugging 64-bit Applications
+@item print @var{expression}
+This will print the value of the given expression. Most simple
+Ada expression formats are properly handled by @code{GDB}, so the expression
+can contain function calls, variables, operators, and attribute references.
 
-@noindent
-In a 64-bit application, all the sources involved must be compiled with the
-@option{-m64} command-line option, and a specific GNAT library (compiled with
-this option) is required.
-The easiest way to build a 64bit application is to add
-@option{-m64 --RTS=m64} to the @command{gnatmake} flags.
+@item continue
+Continues execution following a breakpoint, until the next breakpoint or the
+termination of the program.
 
-To debug these applications, dwarf-2 debug information is required, so you
-have to add @option{-gdwarf-2} to your gnatmake arguments.
-In addition, a special
-version of gdb, called @command{gdb64}, needs to be used.
+@item step
+Executes a single line after a breakpoint. If the next statement
+is a subprogram call, execution continues into (the first statement of)
+the called subprogram.
 
-To summarize, building and debugging a ``Hello World'' program in 64-bit mode
-amounts to:
+@item next
+Executes a single line. If this line is a subprogram call, executes and
+returns from the call.
 
-@smallexample
-     $ gnatmake -m64 -gdwarf-2 --RTS=m64 hello.adb
-     $ gdb64 hello
-@end smallexample
+@item list
+Lists a few lines around the current source location. In practice, it
+is usually more convenient to have a separate edit window open with the
+relevant source file displayed. Successive applications of this command
+print subsequent lines. The command can be given an argument which is a
+line number, in which case it displays a few lines around the specified one.
 
+@item backtrace
+Displays a backtrace of the call chain. This command is typically
+used after a breakpoint has occurred, to examine the sequence of calls that
+leads to the current breakpoint. The display includes one line for each
+activation record (frame) corresponding to an active subprogram.
 
+@item up
+At a breakpoint, @code{GDB} can display the values of variables local
+to the current frame. The command @code{up} can be used to
+examine the contents of other active frames, by moving the focus up
+the stack, that is to say from callee to caller, one frame at a time.
 
-@node IRIX-Specific Considerations
-@section IRIX-Specific Considerations
-@cindex IRIX thread library
+@item down
+Moves the focus of @code{GDB} down from the frame currently being
+examined to the frame of its callee (the reverse of the previous command),
 
-@noindent
-On SGI IRIX, the thread library depends on which compiler is used.
-The @emph{o32 ABI} compiler comes with a run-time library based on the
-user-level @code{athread}
-library. Thus kernel-level capabilities such as nonblocking system
-calls or time slicing can only be achieved reliably by specifying different
-@code{sprocs} via the pragma @code{Task_Info}
-@cindex pragma Task_Info (and IRIX threads)
-and the
-@code{System.Task_Info} package.
-@cindex @code{System.Task_Info} package (and IRIX threads)
-See the @cite{GNAT Reference Manual} for further information.
+@item frame @var{n}
+Inspect the frame with the given number. The value 0 denotes the frame
+of the current breakpoint, that is to say the top of the call stack.
 
-The @emph{n32 ABI} compiler comes with a run-time library based on the
-kernel POSIX threads and thus does not have the limitations mentioned above.
+@end table
 
+@noindent
+The above list is a very short introduction to the commands that
+@code{GDB} provides. Important additional capabilities, including conditional
+breakpoints, the ability to execute command sequences on a breakpoint,
+the ability to debug at the machine instruction level and many other
+features are described in detail in @cite{Debugging with GDB}.
+Note that most commands can be abbreviated
+(for example, c for continue, bt for backtrace).
 
-@node Linux-Specific Considerations
-@section Linux-Specific Considerations
-@cindex Linux threads libraries
+@node Using Ada Expressions
+@section Using Ada Expressions
+@cindex Ada expressions
 
 @noindent
-The default thread library under GNU/Linux has the following disadvantages
-compared to other native thread libraries:
+@code{GDB} supports a fairly large subset of Ada expression syntax, with some
+extensions. The philosophy behind the design of this subset is
 
 @itemize @bullet
-@item The size of the task's stack is limited to 2 megabytes.
-@item  The signal model is not POSIX compliant, which means that to send a
-  signal to the process, you need to send the signal to all threads,
-  e.g. by using @code{killpg()}.
-@end itemize
+@item
+That @code{GDB} should provide basic literals and access to operations for
+arithmetic, dereferencing, field selection, indexing, and subprogram calls,
+leaving more sophisticated computations to subprograms written into the
+program (which therefore may be called from @code{GDB}).
 
-@node AIX-Specific Considerations
-@section AIX-Specific Considerations
-@cindex AIX resolver library
+@item
+That type safety and strict adherence to Ada language restrictions
+are not particularly important to the @code{GDB} user.
 
-@noindent
-On AIX, the resolver library initializes some internal structure on
-the first call to @code{get*by*} functions, which are used to implement
-@code{GNAT.Sockets.Get_Host_By_Name} and @code{GNAT.Sockets.Get_Host_By_Addrss}.
-If such initialization occurs within an Ada task, and the stack size for
-the task is the default size, a stack overflow may occur.
+@item
+That brevity is important to the @code{GDB} user.
+@end itemize
 
-To avoid this overflow, the user should either ensure that the first call
-to @code{GNAT.Sockets.Get_Host_By_Name} or @code{GNAT.Sockets.Get_Host_By_Addrss}
-occurs in the environment task, or use @code{pragma Storage_Size} to
-specify a sufficiently large size for the stack of the task that contains
-this call.
+@noindent
+Thus, for brevity, the debugger acts as if there were
+implicit @code{with} and @code{use} clauses in effect for all user-written
+packages, thus making it unnecessary to fully qualify most names with
+their packages, regardless of context. Where this causes ambiguity,
+@code{GDB} asks the user's intent.
 
-@c *******************************
-@node Example of Binder Output File
-@appendix Example of Binder Output File
+For details on the supported Ada syntax, see @cite{Debugging with GDB}.
+
+@node Calling User-Defined Subprograms
+@section Calling User-Defined Subprograms
 
 @noindent
-This Appendix displays the source code for @command{gnatbind}'s output
-file generated for a simple ``Hello World'' program.
-Comments have been added for clarification purposes.
+An important capability of @code{GDB} is the ability to call user-defined
+subprograms while debugging. This is achieved simply by entering
+a subprogram call statement in the form:
 
+@smallexample
+call subprogram-name (parameters)
+@end smallexample
 
-@smallexample @c adanocomment
+@noindent
+The keyword @code{call} can be omitted in the normal case where the
+@code{subprogram-name} does not coincide with any of the predefined
+@code{GDB} commands.
+
+The effect is to invoke the given subprogram, passing it the
+list of parameters that is supplied. The parameters can be expressions and
+can include variables from the program being debugged. The
+subprogram must be defined
+at the library level within your program, and @code{GDB} will call the
+subprogram within the environment of your program execution (which
+means that the subprogram is free to access or even modify variables
+within your program).
+
+The most important use of this facility is in allowing the inclusion of
+debugging routines that are tailored to particular data structures
+in your program. Such debugging routines can be written to provide a suitably
+high-level description of an abstract type, rather than a low-level dump
+of its physical layout. After all, the standard
+@code{GDB print} command only knows the physical layout of your
+types, not their abstract meaning. Debugging routines can provide information
+at the desired semantic level and are thus enormously useful.
+
+For example, when debugging GNAT itself, it is crucial to have access to
+the contents of the tree nodes used to represent the program internally.
+But tree nodes are represented simply by an integer value (which in turn
+is an index into a table of nodes).
+Using the @code{print} command on a tree node would simply print this integer
+value, which is not very useful. But the PN routine (defined in file
+treepr.adb in the GNAT sources) takes a tree node as input, and displays
+a useful high level representation of the tree node, which includes the
+syntactic category of the node, its position in the source, the integers
+that denote descendant nodes and parent node, as well as varied
+semantic information. To study this example in more detail, you might want to
+look at the body of the PN procedure in the stated file.
+
+@node Using the Next Command in a Function
+@section Using the Next Command in a Function
+
+@noindent
+When you use the @code{next} command in a function, the current source
+location will advance to the next statement as usual. A special case
+arises in the case of a @code{return} statement.
+
+Part of the code for a return statement is the ``epilog'' of the function.
+This is the code that returns to the caller. There is only one copy of
+this epilog code, and it is typically associated with the last return
+statement in the function if there is more than one return. In some
+implementations, this epilog is associated with the first statement
+of the function.
+
+The result is that if you use the @code{next} command from a return
+statement that is not the last return statement of the function you
+may see a strange apparent jump to the last return statement or to
+the start of the function. You should simply ignore this odd jump.
+The value returned is always that from the first return statement
+that was stepped through.
+
+@node Ada Exceptions
+@section Breaking on Ada Exceptions
+@cindex Exceptions
+
+@noindent
+You can set breakpoints that trip when your program raises
+selected exceptions.
+
+@table @code
+@item break exception
+Set a breakpoint that trips whenever (any task in the) program raises
+any exception.
+
+@item break exception @var{name}
+Set a breakpoint that trips whenever (any task in the) program raises
+the exception @var{name}.
+
+@item break exception unhandled
+Set a breakpoint that trips whenever (any task in the) program raises an
+exception for which there is no handler.
+
+@item info exceptions
+@itemx info exceptions @var{regexp}
+The @code{info exceptions} command permits the user to examine all defined
+exceptions within Ada programs. With a regular expression, @var{regexp}, as
+argument, prints out only those exceptions whose name matches @var{regexp}.
+@end table
+
+@node Ada Tasks
+@section Ada Tasks
+@cindex Tasks
+
+@noindent
+@code{GDB} allows the following task-related commands:
+
+@table @code
+@item info tasks
+This command shows a list of current Ada tasks, as in the following example:
+
+@smallexample
 @iftex
 @leftskip=0cm
 @end iftex
---  The package is called Ada_Main unless this name is actually used
---  as a unit name in the partition, in which case some other unique
---  name is used.
+(gdb) info tasks
+  ID       TID P-ID   Thread Pri State                 Name
+   1   8088000   0   807e000  15 Child Activation Wait main_task
+   2   80a4000   1   80ae000  15 Accept/Select Wait    b
+   3   809a800   1   80a4800  15 Child Activation Wait a
+*  4   80ae800   3   80b8000  15 Running               c
+@end smallexample
 
-with System;
-package ada_main is
+@noindent
+In this listing, the asterisk before the first task indicates it to be the
+currently running task. The first column lists the task ID that is used
+to refer to tasks in the following commands.
 
-   Elab_Final_Code : Integer;
-   pragma Import (C, Elab_Final_Code, "__gnat_inside_elab_final_code");
+@item break @var{linespec} task @var{taskid}
+@itemx break @var{linespec} task @var{taskid} if @dots{}
+@cindex Breakpoints and tasks
+These commands are like the @code{break @dots{} thread @dots{}}.
+@var{linespec} specifies source lines.
 
-   --  The main program saves the parameters (argument count,
-   --  argument values, environment pointer) in global variables
-   --  for later access by other units including
-   --  Ada.Command_Line.
+Use the qualifier @samp{task @var{taskid}} with a breakpoint command
+to specify that you only want @code{GDB} to stop the program when a
+particular Ada task reaches this breakpoint. @var{taskid} is one of the
+numeric task identifiers assigned by @code{GDB}, shown in the first
+column of the @samp{info tasks} display.
 
-   gnat_argc : Integer;
-   gnat_argv : System.Address;
-   gnat_envp : System.Address;
+If you do not specify @samp{task @var{taskid}} when you set a
+breakpoint, the breakpoint applies to @emph{all} tasks of your
+program.
 
-   --  The actual variables are stored in a library routine. This
-   --  is useful for some shared library situations, where there
-   --  are problems if variables are not in the library.
+You can use the @code{task} qualifier on conditional breakpoints as
+well; in this case, place @samp{task @var{taskid}} before the
+breakpoint condition (before the @code{if}).
 
-   pragma Import (C, gnat_argc);
-   pragma Import (C, gnat_argv);
-   pragma Import (C, gnat_envp);
+@item task @var{taskno}
+@cindex Task switching
 
-   --  The exit status is similarly an external location
+This command allows to switch to the task referred by @var{taskno}. In
+particular, This allows to browse the backtrace of the specified
+task. It is advised to switch back to the original task before
+continuing execution otherwise the scheduling of the program may be
+perturbed.
+@end table
 
-   gnat_exit_status : Integer;
-   pragma Import (C, gnat_exit_status);
+@noindent
+For more detailed information on the tasking support,
+see @cite{Debugging with GDB}.
 
-   GNAT_Version : constant String :=
-                    "GNAT Version: 3.15w (20010315)";
-   pragma Export (C, GNAT_Version, "__gnat_version");
+@node Debugging Generic Units
+@section Debugging Generic Units
+@cindex Debugging Generic Units
+@cindex Generics
 
-   --  This is the generated adafinal routine that performs
-   --  finalization at the end of execution. In the case where
-   --  Ada is the main program, this main program makes a call
-   --  to adafinal at program termination.
+@noindent
+GNAT always uses code expansion for generic instantiation. This means that
+each time an instantiation occurs, a complete copy of the original code is
+made, with appropriate substitutions of formals by actuals.
 
-   procedure adafinal;
-   pragma Export (C, adafinal, "adafinal");
+It is not possible to refer to the original generic entities in
+@code{GDB}, but it is always possible to debug a particular instance of
+a generic, by using the appropriate expanded names. For example, if we have
 
-   --  This is the generated adainit routine that performs
-   --  initialization at the start of execution. In the case
-   --  where Ada is the main program, this main program makes
-   --  a call to adainit at program startup.
+@smallexample @c ada
+@group
+@cartouche
+procedure g is
 
-   procedure adainit;
-   pragma Export (C, adainit, "adainit");
+   generic package k is
+      procedure kp (v1 : in out integer);
+   end k;
 
-   --  This routine is called at the start of execution. It is
-   --  a dummy routine that is used by the debugger to breakpoint
-   --  at the start of execution.
+   package body k is
+      procedure kp (v1 : in out integer) is
+      begin
+         v1 := v1 + 1;
+      end kp;
+   end k;
 
-   procedure Break_Start;
-   pragma Import (C, Break_Start, "__gnat_break_start");
+   package k1 is new k;
+   package k2 is new k;
 
-   --  This is the actual generated main program (it would be
-   --  suppressed if the no main program switch were used). As
-   --  required by standard system conventions, this program has
-   --  the external name main.
+   var : integer := 1;
 
-   function main
-     (argc : Integer;
-      argv : System.Address;
-      envp : System.Address)
-      return Integer;
-   pragma Export (C, main, "main");
+begin
+   k1.kp (var);
+   k2.kp (var);
+   k1.kp (var);
+   k2.kp (var);
+end;
+@end cartouche
+@end group
+@end smallexample
 
-   --  The following set of constants give the version
-   --  identification values for every unit in the bound
-   --  partition. This identification is computed from all
-   --  dependent semantic units, and corresponds to the
-   --  string that would be returned by use of the
-   --  Body_Version or Version attributes.
+@noindent
+Then to break on a call to procedure kp in the k2 instance, simply
+use the command:
 
-   type Version_32 is mod 2 ** 32;
-   u00001 : constant Version_32 := 16#7880BEB3#;
-   u00002 : constant Version_32 := 16#0D24CBD0#;
-   u00003 : constant Version_32 := 16#3283DBEB#;
-   u00004 : constant Version_32 := 16#2359F9ED#;
-   u00005 : constant Version_32 := 16#664FB847#;
-   u00006 : constant Version_32 := 16#68E803DF#;
-   u00007 : constant Version_32 := 16#5572E604#;
-   u00008 : constant Version_32 := 16#46B173D8#;
-   u00009 : constant Version_32 := 16#156A40CF#;
-   u00010 : constant Version_32 := 16#033DABE0#;
-   u00011 : constant Version_32 := 16#6AB38FEA#;
-   u00012 : constant Version_32 := 16#22B6217D#;
-   u00013 : constant Version_32 := 16#68A22947#;
-   u00014 : constant Version_32 := 16#18CC4A56#;
-   u00015 : constant Version_32 := 16#08258E1B#;
-   u00016 : constant Version_32 := 16#367D5222#;
-   u00017 : constant Version_32 := 16#20C9ECA4#;
-   u00018 : constant Version_32 := 16#50D32CB6#;
-   u00019 : constant Version_32 := 16#39A8BB77#;
-   u00020 : constant Version_32 := 16#5CF8FA2B#;
-   u00021 : constant Version_32 := 16#2F1EB794#;
-   u00022 : constant Version_32 := 16#31AB6444#;
-   u00023 : constant Version_32 := 16#1574B6E9#;
-   u00024 : constant Version_32 := 16#5109C189#;
-   u00025 : constant Version_32 := 16#56D770CD#;
-   u00026 : constant Version_32 := 16#02F9DE3D#;
-   u00027 : constant Version_32 := 16#08AB6B2C#;
-   u00028 : constant Version_32 := 16#3FA37670#;
-   u00029 : constant Version_32 := 16#476457A0#;
-   u00030 : constant Version_32 := 16#731E1B6E#;
-   u00031 : constant Version_32 := 16#23C2E789#;
-   u00032 : constant Version_32 := 16#0F1BD6A1#;
-   u00033 : constant Version_32 := 16#7C25DE96#;
-   u00034 : constant Version_32 := 16#39ADFFA2#;
-   u00035 : constant Version_32 := 16#571DE3E7#;
-   u00036 : constant Version_32 := 16#5EB646AB#;
-   u00037 : constant Version_32 := 16#4249379B#;
-   u00038 : constant Version_32 := 16#0357E00A#;
-   u00039 : constant Version_32 := 16#3784FB72#;
-   u00040 : constant Version_32 := 16#2E723019#;
-   u00041 : constant Version_32 := 16#623358EA#;
-   u00042 : constant Version_32 := 16#107F9465#;
-   u00043 : constant Version_32 := 16#6843F68A#;
-   u00044 : constant Version_32 := 16#63305874#;
-   u00045 : constant Version_32 := 16#31E56CE1#;
-   u00046 : constant Version_32 := 16#02917970#;
-   u00047 : constant Version_32 := 16#6CCBA70E#;
-   u00048 : constant Version_32 := 16#41CD4204#;
-   u00049 : constant Version_32 := 16#572E3F58#;
-   u00050 : constant Version_32 := 16#20729FF5#;
-   u00051 : constant Version_32 := 16#1D4F93E8#;
-   u00052 : constant Version_32 := 16#30B2EC3D#;
-   u00053 : constant Version_32 := 16#34054F96#;
-   u00054 : constant Version_32 := 16#5A199860#;
-   u00055 : constant Version_32 := 16#0E7F912B#;
-   u00056 : constant Version_32 := 16#5760634A#;
-   u00057 : constant Version_32 := 16#5D851835#;
+@smallexample
+(gdb) break g.k2.kp
+@end smallexample
+
+@noindent
+When the breakpoint occurs, you can step through the code of the
+instance in the normal manner and examine the values of local variables, as for
+other units.
+
+@node GNAT Abnormal Termination or Failure to Terminate
+@section GNAT Abnormal Termination or Failure to Terminate
+@cindex GNAT Abnormal Termination or Failure to Terminate
+
+@noindent
+When presented with programs that contain serious errors in syntax
+or semantics,
+GNAT may on rare occasions  experience problems in operation, such
+as aborting with a
+segmentation fault or illegal memory access, raising an internal
+exception, terminating abnormally, or failing to terminate at all.
+In such cases, you can activate
+various features of GNAT that can help you pinpoint the construct in your
+program that is the likely source of the problem.
+
+The following strategies are presented in increasing order of
+difficulty, corresponding to your experience in using GNAT and your
+familiarity with compiler internals.
+
+@enumerate
+@item
+Run @command{gcc} with the @option{-gnatf}. This first
+switch causes all errors on a given line to be reported. In its absence,
+only the first error on a line is displayed.
+
+The @option{-gnatdO} switch causes errors to be displayed as soon as they
+are encountered, rather than after compilation is terminated. If GNAT
+terminates prematurely or goes into an infinite loop, the last error
+message displayed may help to pinpoint the culprit.
+
+@item
+Run @command{gcc} with the @option{^-v (verbose)^/VERBOSE^} switch. In this
+mode, @command{gcc} produces ongoing information about the progress of the
+compilation and provides the name of each procedure as code is
+generated. This switch allows you to find which Ada procedure was being
+compiled when it encountered a code generation problem.
+
+@item
+@cindex @option{-gnatdc} switch
+Run @command{gcc} with the @option{-gnatdc} switch. This is a GNAT specific
+switch that does for the front-end what @option{^-v^VERBOSE^} does
+for the back end. The system prints the name of each unit,
+either a compilation unit or nested unit, as it is being analyzed.
+@item
+Finally, you can start
+@code{gdb} directly on the @code{gnat1} executable. @code{gnat1} is the
+front-end of GNAT, and can be run independently (normally it is just
+called from @command{gcc}). You can use @code{gdb} on @code{gnat1} as you
+would on a C program (but @pxref{The GNAT Debugger GDB} for caveats). The
+@code{where} command is the first line of attack; the variable
+@code{lineno} (seen by @code{print lineno}), used by the second phase of
+@code{gnat1} and by the @command{gcc} backend, indicates the source line at
+which the execution stopped, and @code{input_file name} indicates the name of
+the source file.
+@end enumerate
+
+@node Naming Conventions for GNAT Source Files
+@section Naming Conventions for GNAT Source Files
+
+@noindent
+In order to examine the workings of the GNAT system, the following
+brief description of its organization may be helpful:
+
+@itemize @bullet
+@item
+Files with prefix @file{^sc^SC^} contain the lexical scanner.
+
+@item
+All files prefixed with @file{^par^PAR^} are components of the parser. The
+numbers correspond to chapters of the Ada Reference Manual. For example,
+parsing of select statements can be found in @file{par-ch9.adb}.
+
+@item
+All files prefixed with @file{^sem^SEM^} perform semantic analysis. The
+numbers correspond to chapters of the Ada standard. For example, all
+issues involving context clauses can be found in @file{sem_ch10.adb}. In
+addition, some features of the language require sufficient special processing
+to justify their own semantic files: sem_aggr for aggregates, sem_disp for
+dynamic dispatching, etc.
+
+@item
+All files prefixed with @file{^exp^EXP^} perform normalization and
+expansion of the intermediate representation (abstract syntax tree, or AST).
+these files use the same numbering scheme as the parser and semantics files.
+For example, the construction of record initialization procedures is done in
+@file{exp_ch3.adb}.
+
+@item
+The files prefixed with @file{^bind^BIND^} implement the binder, which
+verifies the consistency of the compilation, determines an order of
+elaboration, and generates the bind file.
+
+@item
+The files @file{atree.ads} and @file{atree.adb} detail the low-level
+data structures used by the front-end.
+
+@item
+The files @file{sinfo.ads} and @file{sinfo.adb} detail the structure of
+the abstract syntax tree as produced by the parser.
+
+@item
+The files @file{einfo.ads} and @file{einfo.adb} detail the attributes of
+all entities, computed during semantic analysis.
+
+@item
+Library management issues are dealt with in files with prefix
+@file{^lib^LIB^}.
+
+@item
+@findex Ada
+@cindex Annex A
+Ada files with the prefix @file{^a-^A-^} are children of @code{Ada}, as
+defined in Annex A.
+
+@item
+@findex Interfaces
+@cindex Annex B
+Files with prefix @file{^i-^I-^} are children of @code{Interfaces}, as
+defined in Annex B.
+
+@item
+@findex System
+Files with prefix @file{^s-^S-^} are children of @code{System}. This includes
+both language-defined children and GNAT run-time routines.
+
+@item
+@findex GNAT
+Files with prefix @file{^g-^G-^} are children of @code{GNAT}. These are useful
+general-purpose packages, fully documented in their specifications. All
+the other @file{.c} files are modifications of common @command{gcc} files.
+@end itemize
+
+@node Getting Internal Debugging Information
+@section Getting Internal Debugging Information
+
+@noindent
+Most compilers have internal debugging switches and modes. GNAT
+does also, except GNAT internal debugging switches and modes are not
+secret. A summary and full description of all the compiler and binder
+debug flags are in the file @file{debug.adb}. You must obtain the
+sources of the compiler to see the full detailed effects of these flags.
+
+The switches that print the source of the program (reconstructed from
+the internal tree) are of general interest for user programs, as are the
+options to print
+the full internal tree, and the entity table (the symbol table
+information). The reconstructed source provides a readable version of the
+program after the front-end has completed analysis and  expansion,
+and is useful when studying the performance of specific constructs.
+For example, constraint checks are indicated, complex aggregates
+are replaced with loops and assignments, and tasking primitives
+are replaced with run-time calls.
+
+@node Stack Traceback
+@section Stack Traceback
+@cindex traceback
+@cindex stack traceback
+@cindex stack unwinding
+
+@noindent
+Traceback is a mechanism to display the sequence of subprogram calls that
+leads to a specified execution point in a program. Often (but not always)
+the execution point is an instruction at which an exception has been raised.
+This mechanism is also known as @i{stack unwinding} because it obtains
+its information by scanning the run-time stack and recovering the activation
+records of all active subprograms. Stack unwinding is one of the most
+important tools for program debugging.
+
+The first entry stored in traceback corresponds to the deepest calling level,
+that is to say the subprogram currently executing the instruction
+from which we want to obtain the traceback.
+
+Note that there is no runtime performance penalty when stack traceback
+is enabled, and no exception is raised during program execution.
+
+@menu
+* Non-Symbolic Traceback::
+* Symbolic Traceback::
+@end menu
+
+@node Non-Symbolic Traceback
+@subsection Non-Symbolic Traceback
+@cindex traceback, non-symbolic
+
+@noindent
+Note: this feature is not supported on all platforms. See
+@file{GNAT.Traceback spec in g-traceb.ads} for a complete list of supported
+platforms.
+
+@menu
+* Tracebacks From an Unhandled Exception::
+* Tracebacks From Exception Occurrences (non-symbolic)::
+* Tracebacks From Anywhere in a Program (non-symbolic)::
+@end menu
+
+@node Tracebacks From an Unhandled Exception
+@subsubsection Tracebacks From an Unhandled Exception
+
+@noindent
+A runtime non-symbolic traceback is a list of addresses of call instructions.
+To enable this feature you must use the @option{-E}
+@code{gnatbind}'s option. With this option a stack traceback is stored as part
+of exception information. You can retrieve this information using the
+@code{addr2line} tool.
+
+Here is a simple example:
+
+@smallexample @c ada
+@cartouche
+procedure STB is
+
+   procedure P1 is
+   begin
+      raise Constraint_Error;
+   end P1;
+
+   procedure P2 is
+   begin
+      P1;
+   end P2;
+
+begin
+   P2;
+end STB;
+@end cartouche
+@end smallexample
+
+@smallexample
+$ gnatmake stb -bargs -E
+$ stb
+
+Execution terminated by unhandled exception
+Exception name: CONSTRAINT_ERROR
+Message: stb.adb:5
+Call stack traceback locations:
+0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4
+@end smallexample
+
+@noindent
+As we see the traceback lists a sequence of addresses for the unhandled
+exception @code{CONSTRAINT_ERROR} raised in procedure P1. It is easy to
+guess that this exception come from procedure P1. To translate these
+addresses into the source lines where the calls appear, the
+@code{addr2line} tool, described below, is invaluable. The use of this tool
+requires the program to be compiled with debug information.
+
+@smallexample
+$ gnatmake -g stb -bargs -E
+$ stb
+
+Execution terminated by unhandled exception
+Exception name: CONSTRAINT_ERROR
+Message: stb.adb:5
+Call stack traceback locations:
+0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4
+
+$ addr2line --exe=stb 0x401373 0x40138b 0x40139c 0x401335 0x4011c4
+   0x4011f1 0x77e892a4
+
+00401373 at d:/stb/stb.adb:5
+0040138B at d:/stb/stb.adb:10
+0040139C at d:/stb/stb.adb:14
+00401335 at d:/stb/b~stb.adb:104
+004011C4 at /build/@dots{}/crt1.c:200
+004011F1 at /build/@dots{}/crt1.c:222
+77E892A4 in ?? at ??:0
+@end smallexample
+
+@noindent
+The @code{addr2line} tool has several other useful options:
+
+@table @code
+@item --functions
+to get the function name corresponding to any location
+
+@item --demangle=gnat
+to use the gnat decoding mode for the function names. Note that
+for binutils version 2.9.x the option is simply @option{--demangle}.
+@end table
+
+@smallexample
+$ addr2line --exe=stb --functions --demangle=gnat 0x401373 0x40138b
+   0x40139c 0x401335 0x4011c4 0x4011f1
+
+00401373 in stb.p1 at d:/stb/stb.adb:5
+0040138B in stb.p2 at d:/stb/stb.adb:10
+0040139C in stb at d:/stb/stb.adb:14
+00401335 in main at d:/stb/b~stb.adb:104
+004011C4 in <__mingw_CRTStartup> at /build/@dots{}/crt1.c:200
+004011F1 in <mainCRTStartup> at /build/@dots{}/crt1.c:222
+@end smallexample
+
+@noindent
+From this traceback we can see that the exception was raised in
+@file{stb.adb} at line 5, which was reached from a procedure call in
+@file{stb.adb} at line 10, and so on. The @file{b~std.adb} is the binder file,
+which contains the call to the main program.
+@xref{Running gnatbind}. The remaining entries are assorted runtime routines,
+and the output will vary from platform to platform.
+
+It is also possible to use @code{GDB} with these traceback addresses to debug
+the program. For example, we can break at a given code location, as reported
+in the stack traceback:
+
+@smallexample
+$ gdb -nw stb
+@ifclear vms
+@noindent
+Furthermore, this feature is not implemented inside Windows DLL. Only
+the non-symbolic traceback is reported in this case.
+@end ifclear
+
+(gdb) break *0x401373
+Breakpoint 1 at 0x401373: file stb.adb, line 5.
+@end smallexample
+
+@noindent
+It is important to note that the stack traceback addresses
+do not change when debug information is included. This is particularly useful
+because it makes it possible to release software without debug information (to
+minimize object size), get a field report that includes a stack traceback
+whenever an internal bug occurs, and then be able to retrieve the sequence
+of calls with the same program compiled with debug information.
+
+@node Tracebacks From Exception Occurrences (non-symbolic)
+@subsubsection Tracebacks From Exception Occurrences
+
+@noindent
+Non-symbolic tracebacks are obtained by using the @option{-E} binder argument.
+The stack traceback is attached to the exception information string, and can
+be retrieved in an exception handler within the Ada program, by means of the
+Ada facilities defined in @code{Ada.Exceptions}. Here is a simple example:
+
+@smallexample @c ada
+with Ada.Text_IO;
+with Ada.Exceptions;
+
+procedure STB is
+
+   use Ada;
+   use Ada.Exceptions;
+
+   procedure P1 is
+      K : Positive := 1;
+   begin
+      K := K - 1;
+   exception
+      when E : others =>
+         Text_IO.Put_Line (Exception_Information (E));
+   end P1;
+
+   procedure P2 is
+   begin
+      P1;
+   end P2;
+
+begin
+   P2;
+end STB;
+@end smallexample
+
+@noindent
+This program will output:
+
+@smallexample
+$ stb
+
+Exception name: CONSTRAINT_ERROR
+Message: stb.adb:12
+Call stack traceback locations:
+0x4015e4 0x401633 0x401644 0x401461 0x4011c4 0x4011f1 0x77e892a4
+@end smallexample
+
+@node Tracebacks From Anywhere in a Program (non-symbolic)
+@subsubsection Tracebacks From Anywhere in a Program
+
+@noindent
+It is also possible to retrieve a stack traceback from anywhere in a
+program. For this you need to
+use the @code{GNAT.Traceback} API. This package includes a procedure called
+@code{Call_Chain} that computes a complete stack traceback, as well as useful
+display procedures described below. It is not necessary to use the
+@option{-E gnatbind} option in this case, because the stack traceback mechanism
+is invoked explicitly.
+
+@noindent
+In the following example we compute a traceback at a specific location in
+the program, and we display it using @code{GNAT.Debug_Utilities.Image} to
+convert addresses to strings:
+
+@smallexample @c ada
+with Ada.Text_IO;
+with GNAT.Traceback;
+with GNAT.Debug_Utilities;
+
+procedure STB is
+
+   use Ada;
+   use GNAT;
+   use GNAT.Traceback;
+
+   procedure P1 is
+      TB  : Tracebacks_Array (1 .. 10);
+      --  We are asking for a maximum of 10 stack frames.
+      Len : Natural;
+      --  Len will receive the actual number of stack frames returned.
+   begin
+      Call_Chain (TB, Len);
+
+      Text_IO.Put ("In STB.P1 : ");
+
+      for K in 1 .. Len loop
+         Text_IO.Put (Debug_Utilities.Image (TB (K)));
+         Text_IO.Put (' ');
+      end loop;
+
+      Text_IO.New_Line;
+   end P1;
+
+   procedure P2 is
+   begin
+      P1;
+   end P2;
+
+begin
+   P2;
+end STB;
+@end smallexample
+
+@smallexample
+$ gnatmake -g stb
+$ stb
+
+In STB.P1 : 16#0040_F1E4# 16#0040_14F2# 16#0040_170B# 16#0040_171C#
+16#0040_1461# 16#0040_11C4# 16#0040_11F1# 16#77E8_92A4#
+@end smallexample
+
+@noindent
+You can then get further information by invoking the @code{addr2line}
+tool as described earlier (note that the hexadecimal addresses
+need to be specified in C format, with a leading ``0x'').
+
+@node Symbolic Traceback
+@subsection Symbolic Traceback
+@cindex traceback, symbolic
+
+@noindent
+A symbolic traceback is a stack traceback in which procedure names are
+associated with each code location.
+
+@noindent
+Note that this feature is not supported on all platforms. See
+@file{GNAT.Traceback.Symbolic spec in g-trasym.ads} for a complete
+list of currently supported platforms.
+
+@noindent
+Note that the symbolic traceback requires that the program be compiled
+with debug information. If it is not compiled with debug information
+only the non-symbolic information will be valid.
+
+@menu
+* Tracebacks From Exception Occurrences (symbolic)::
+* Tracebacks From Anywhere in a Program (symbolic)::
+@end menu
+
+@node Tracebacks From Exception Occurrences (symbolic)
+@subsubsection Tracebacks From Exception Occurrences
+
+@smallexample @c ada
+with Ada.Text_IO;
+with GNAT.Traceback.Symbolic;
+
+procedure STB is
+
+   procedure P1 is
+   begin
+      raise Constraint_Error;
+   end P1;
+
+   procedure P2 is
+   begin
+      P1;
+   end P2;
+
+   procedure P3 is
+   begin
+      P2;
+   end P3;
+
+begin
+   P3;
+exception
+   when E : others =>
+      Ada.Text_IO.Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E));
+end STB;
+@end smallexample
+
+@smallexample
+$ gnatmake -g .\stb -bargs -E -largs -lgnat -laddr2line -lintl
+$ stb
+
+0040149F in stb.p1 at stb.adb:8
+004014B7 in stb.p2 at stb.adb:13
+004014CF in stb.p3 at stb.adb:18
+004015DD in ada.stb at stb.adb:22
+00401461 in main at b~stb.adb:168
+004011C4 in __mingw_CRTStartup at crt1.c:200
+004011F1 in mainCRTStartup at crt1.c:222
+77E892A4 in ?? at ??:0
+@end smallexample
+
+@noindent
+In the above example the ``.\'' syntax in the @command{gnatmake} command
+is currently required by @command{addr2line} for files that are in
+the current working directory.
+Moreover, the exact sequence of linker options may vary from platform
+to platform.
+The above @option{-largs} section is for Windows platforms. By contrast,
+under Unix there is no need for the @option{-largs} section.
+Differences across platforms are due to details of linker implementation.
+
+@node Tracebacks From Anywhere in a Program (symbolic)
+@subsubsection Tracebacks From Anywhere in a Program
+
+@noindent
+It is possible to get a symbolic stack traceback
+from anywhere in a program, just as for non-symbolic tracebacks.
+The first step is to obtain a non-symbolic
+traceback, and then call @code{Symbolic_Traceback} to compute the symbolic
+information. Here is an example:
+
+@smallexample @c ada
+with Ada.Text_IO;
+with GNAT.Traceback;
+with GNAT.Traceback.Symbolic;
+
+procedure STB is
+
+   use Ada;
+   use GNAT.Traceback;
+   use GNAT.Traceback.Symbolic;
+
+   procedure P1 is
+      TB  : Tracebacks_Array (1 .. 10);
+      --  We are asking for a maximum of 10 stack frames.
+      Len : Natural;
+      --  Len will receive the actual number of stack frames returned.
+   begin
+      Call_Chain (TB, Len);
+      Text_IO.Put_Line (Symbolic_Traceback (TB (1 .. Len)));
+   end P1;
+
+   procedure P2 is
+   begin
+      P1;
+   end P2;
+
+begin
+   P2;
+end STB;
+@end smallexample
+
+@c ******************************
+@ifset vms
+@node Compatibility with HP Ada
+@chapter Compatibility with HP Ada
+@cindex Compatibility
+
+@noindent
+@cindex DEC Ada
+@cindex HP Ada
+@cindex Compatibility between GNAT and HP Ada
+This chapter compares HP Ada (formerly known as ``DEC Ada'')
+for OpenVMS Alpha and GNAT for OpenVMS for Alpha and for I64.
+GNAT is highly compatible
+with HP Ada, and it should generally be straightforward to port code
+from the HP Ada environment to GNAT. However, there are a few language
+and implementation differences of which the user must be aware. These
+differences are discussed in this chapter. In
+addition, the operating environment and command structure for the
+compiler are different, and these differences are also discussed.
+
+For further details on these and other compatibility issues,
+see Appendix E of the HP publication
+@cite{HP Ada, Technical Overview and Comparison on HP Platforms}.
+
+Except where otherwise indicated, the description of GNAT for OpenVMS
+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 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
+of HP Ada differs between OpenVMS Alpha Systems and OpenVMS VAX Systems,
+GNAT always follows the Alpha implementation.
+
+For GNAT running on other than VMS systems, all the HP Ada 83 pragmas and
+attributes are recognized, although only a subset of them can sensibly
+be implemented.  The description of pragmas in the
+@cite{GNAT Reference Manual} indicates whether or not they are applicable
+to non-VMS systems.
+
+@menu
+* Ada Language Compatibility::
+* Differences in the Definition of Package System::
+* Language-Related Features::
+* The Package STANDARD::
+* The Package SYSTEM::
+* Tasking and Task-Related Features::
+* Pragmas and Pragma-Related Features::
+* Library of Predefined Units::
+* Bindings::
+* Main Program Definition::
+* Implementation-Defined Attributes::
+* Compiler and Run-Time Interfacing::
+* Program Compilation and Library Management::
+* Input-Output::
+* Implementation Limits::
+* Tools and Utilities::
+@end menu
+
+@node Ada Language Compatibility
+@section Ada Language Compatibility
+
+@noindent
+GNAT handles Ada 95 and Ada 2005 as well as Ada 83, whereas HP Ada is only
+for Ada 83. Ada 95 and Ada 2005 are almost completely upwards compatible
+with Ada 83, and therefore Ada 83 programs will compile
+and run under GNAT with
+no changes or only minor changes. The @cite{Annotated Ada Reference Manual}
+provides details on specific incompatibilities.
+
+GNAT provides the switch @option{/83} on the @command{GNAT COMPILE} command,
+as well as the pragma @code{ADA_83}, to force the compiler to
+operate in Ada 83 mode. This mode does not guarantee complete
+conformance to Ada 83, but in practice is sufficient to
+eliminate most sources of incompatibilities.
+In particular, it eliminates the recognition of the
+additional Ada 95 and Ada 2005 keywords, so that their use as identifiers
+in Ada 83 programs is legal, and handles the cases of packages
+with optional bodies, and generics that instantiate unconstrained
+types without the use of @code{(<>)}.
+
+@node Differences in the Definition of Package System
+@section Differences in the Definition of Package @code{System}
+
+@noindent
+An Ada compiler is allowed to add
+implementation-dependent declarations to package @code{System}.
+In normal mode,
+GNAT does not take advantage of this permission, and the version of
+@code{System} provided by GNAT exactly matches that defined in the Ada
+Reference Manual.
+
+However, HP Ada adds an extensive set of declarations to package
+@code{System},
+as fully documented in the HP Ada manuals. To minimize changes required
+for programs that make use of these extensions, GNAT provides the pragma
+@code{Extend_System} for extending the definition of package System. By using:
+@cindex pragma @code{Extend_System}
+@cindex @code{Extend_System} pragma
+
+@smallexample @c ada
+@group
+@cartouche
+pragma Extend_System (Aux_DEC);
+@end cartouche
+@end group
+@end smallexample
+
+@noindent
+the set of definitions in @code{System} is extended to include those in
+package @code{System.Aux_DEC}.
+@cindex @code{System.Aux_DEC} package
+@cindex @code{Aux_DEC} package (child of @code{System})
+These definitions are incorporated directly into package @code{System},
+as though they had been declared there. For a
+list of the declarations added, see the specification of this package,
+which can be found in the file @file{s-auxdec.ads} in the GNAT library.
+@cindex @file{s-auxdec.ads} file
+The pragma @code{Extend_System} is a configuration pragma, which means that
+it can be placed in the file @file{gnat.adc}, so that it will automatically
+apply to all subsequent compilations. See @ref{Configuration Pragmas},
+for further details.
+
+An alternative approach that avoids the use of the non-standard
+@code{Extend_System} pragma is to add a context clause to the unit that
+references these facilities:
+
+@smallexample @c ada
+@cartouche
+with System.Aux_DEC;
+use  System.Aux_DEC;
+@end cartouche
+@end smallexample
+
+@noindent
+The effect is not quite semantically identical to incorporating
+the declarations directly into package @code{System},
+but most programs will not notice a difference
+unless they use prefix notation (e.g. @code{System.Integer_8})
+to reference the entities directly in package @code{System}.
+For units containing such references,
+the prefixes must either be removed, or the pragma @code{Extend_System}
+must be used.
+
+@node Language-Related Features
+@section Language-Related Features
+
+@noindent
+The following sections highlight differences in types,
+representations of types, operations, alignment, and
+related topics.
+
+@menu
+* Integer Types and Representations::
+* Floating-Point Types and Representations::
+* Pragmas Float_Representation and Long_Float::
+* Fixed-Point Types and Representations::
+* Record and Array Component Alignment::
+* Address Clauses::
+* Other Representation Clauses::
+@end menu
+
+@node Integer Types and Representations
+@subsection Integer Types and Representations
+
+@noindent
+The set of predefined integer types is identical in HP Ada and GNAT.
+Furthermore the representation of these integer types is also identical,
+including the capability of size clauses forcing biased representation.
+
+In addition,
+HP Ada for OpenVMS Alpha systems has defined the
+following additional integer types in package @code{System}:
+
+@itemize @bullet
+
+@item
+@code{INTEGER_8}
+
+@item
+@code{INTEGER_16}
+
+@item
+@code{INTEGER_32}
+
+@item
+@code{INTEGER_64}
+
+@item
+@code{LARGEST_INTEGER}
+@end itemize
+
+@noindent
+In GNAT, the first four of these types may be obtained from the
+standard Ada package @code{Interfaces}.
+Alternatively, by use of the pragma @code{Extend_System}, identical
+declarations can be referenced directly in package @code{System}.
+On both GNAT and HP Ada, the maximum integer size is 64 bits.
+
+@node Floating-Point Types and Representations
+@subsection Floating-Point Types and Representations
+@cindex Floating-Point types
+
+@noindent
+The set of predefined floating-point types is identical in HP Ada and GNAT.
+Furthermore the representation of these floating-point
+types is also identical. One important difference is that the default
+representation for HP Ada is @code{VAX_Float}, but the default representation
+for GNAT is IEEE.
+
+Specific types may be declared to be @code{VAX_Float} or IEEE, using the
+pragma @code{Float_Representation} as described in the HP Ada
+documentation.
+For example, the declarations:
+
+@smallexample @c ada
+@cartouche
+type F_Float is digits 6;
+pragma Float_Representation (VAX_Float, F_Float);
+@end cartouche
+@end smallexample
+
+@noindent
+declares a type @code{F_Float} that will be represented in @code{VAX_Float}
+format.
+This set of declarations actually appears in @code{System.Aux_DEC},
+which contains
+the full set of additional floating-point declarations provided in
+the HP Ada version of package @code{System}.
+This and similar declarations may be accessed in a user program
+by using pragma @code{Extend_System}. The use of this
+pragma, and the related pragma @code{Long_Float} is described in further
+detail in the following section.
+
+@node Pragmas Float_Representation and Long_Float
+@subsection Pragmas @code{Float_Representation} and @code{Long_Float}
+
+@noindent
+HP Ada provides the pragma @code{Float_Representation}, which
+acts as a program library switch to allow control over
+the internal representation chosen for the predefined
+floating-point types declared in the package @code{Standard}.
+The format of this pragma is as follows:
+
+@smallexample @c ada
+@cartouche
+pragma Float_Representation(VAX_Float | IEEE_Float);
+@end cartouche
+@end smallexample
+
+@noindent
+This pragma controls the representation of floating-point
+types as follows:
+
+@itemize @bullet
+@item
+@code{VAX_Float} specifies that floating-point
+types are represented by default with the VAX system hardware types
+@code{F-floating}, @code{D-floating}, @code{G-floating}.
+Note that the @code{H-floating}
+type was available only on VAX systems, and is not available
+in either HP Ada or GNAT.
+
+@item
+@code{IEEE_Float} specifies that floating-point
+types are represented by default with the IEEE single and
+double floating-point types.
+@end itemize
+
+@noindent
+GNAT provides an identical implementation of the pragma
+@code{Float_Representation}, except that it functions as a
+configuration pragma. Note that the
+notion of configuration pragma corresponds closely to the
+HP Ada notion of a program library switch.
+
+When no pragma is used in GNAT, the default is @code{IEEE_Float},
+which is different
+from HP Ada 83, where the default is @code{VAX_Float}. In addition, the
+predefined libraries in GNAT are built using @code{IEEE_Float}, so it is not
+advisable to change the format of numbers passed to standard library
+routines, and if necessary explicit type conversions may be needed.
+
+The use of @code{IEEE_Float} is recommended in GNAT since it is more
+efficient, and (given that it conforms to an international standard)
+potentially more portable.
+The situation in which @code{VAX_Float} may be useful is in interfacing
+to existing code and data that expect the use of @code{VAX_Float}.
+In such a situation use the predefined @code{VAX_Float}
+types in package @code{System}, as extended by
+@code{Extend_System}. For example, use @code{System.F_Float}
+to specify the 32-bit @code{F-Float} format.
+
+@noindent
+On OpenVMS systems, HP Ada provides the pragma @code{Long_Float}
+to allow control over the internal representation chosen
+for the predefined type @code{Long_Float} and for floating-point
+type declarations with digits specified in the range 7 .. 15.
+The format of this pragma is as follows:
+
+@smallexample @c ada
+@cartouche
+pragma Long_Float (D_FLOAT | G_FLOAT);
+@end cartouche
+@end smallexample
+
+@node Fixed-Point Types and Representations
+@subsection Fixed-Point Types and Representations
+
+@noindent
+On HP Ada for OpenVMS Alpha systems, rounding is
+away from zero for both positive and negative numbers.
+Therefore, @code{+0.5} rounds to @code{1},
+and @code{-0.5} rounds to @code{-1}.
+
+On GNAT the results of operations
+on fixed-point types are in accordance with the Ada
+rules. In particular, results of operations on decimal
+fixed-point types are truncated.
+
+@node Record and Array Component Alignment
+@subsection Record and Array Component Alignment
+
+@noindent
+On HP Ada for OpenVMS Alpha, all non composite components
+are aligned on natural boundaries. For example, 1-byte
+components are aligned on byte boundaries, 2-byte
+components on 2-byte boundaries, 4-byte components on 4-byte
+byte boundaries, and so on. The OpenVMS Alpha hardware
+runs more efficiently with naturally aligned data.
+
+On GNAT, alignment rules are compatible
+with HP Ada for OpenVMS Alpha.
+
+@node Address Clauses
+@subsection Address Clauses
+
+@noindent
+In HP Ada and GNAT, address clauses are supported for
+objects and imported subprograms.
+The predefined type @code{System.Address} is a private type
+in both compilers on Alpha OpenVMS, with the same representation
+(it is simply a machine pointer). Addition, subtraction, and comparison
+operations are available in the standard Ada package
+@code{System.Storage_Elements}, or in package @code{System}
+if it is extended to include @code{System.Aux_DEC} using a
+pragma @code{Extend_System} as previously described.
+
+Note that code that @code{with}'s both this extended package @code{System}
+and the package @code{System.Storage_Elements} should not @code{use}
+both packages, or ambiguities will result. In general it is better
+not to mix these two sets of facilities. The Ada package was
+designed specifically to provide the kind of features that HP Ada
+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 to 64-Bit GNAT for OpenVMS}.
+
+GNAT is compatible with HP Ada in its handling of address
+clauses, except for some limitations in
+the form of address clauses for composite objects with
+initialization. Such address clauses are easily replaced
+by the use of an explicitly-defined constant as described
+in the Ada Reference Manual (13.1(22)). For example, the sequence
+of declarations:
+
+@smallexample @c ada
+@cartouche
+X, Y : Integer := Init_Func;
+Q : String (X .. Y) := "abc";
+@dots{}
+for Q'Address use Compute_Address;
+@end cartouche
+@end smallexample
+
+@noindent
+will be rejected by GNAT, since the address cannot be computed at the time
+that @code{Q} is declared. To achieve the intended effect, write instead:
+
+@smallexample @c ada
+@group
+@cartouche
+X, Y : Integer := Init_Func;
+Q_Address : constant Address := Compute_Address;
+Q : String (X .. Y) := "abc";
+@dots{}
+for Q'Address use Q_Address;
+@end cartouche
+@end group
+@end smallexample
+
+@noindent
+which will be accepted by GNAT (and other Ada compilers), and is also
+compatible with Ada 83. A fuller description of the restrictions
+on address specifications is found in the @cite{GNAT Reference Manual}.
+
+@node Other Representation Clauses
+@subsection Other Representation Clauses
+
+@noindent
+GNAT implements in a compatible manner all the representation
+clauses supported by HP Ada. In addition, GNAT
+implements the representation clause forms that were introduced in Ada 95,
+including @code{COMPONENT_SIZE} and @code{SIZE} clauses for objects.
+
+@node The Package STANDARD
+@section The Package @code{STANDARD}
+
+@noindent
+The package @code{STANDARD}, as implemented by HP Ada, is fully
+described in the @cite{Ada Reference Manual} and in the
+@cite{HP Ada Language Reference Manual}. As implemented by GNAT, the
+package @code{STANDARD} is described in the @cite{Ada Reference Manual}.
+
+In addition, HP Ada supports the Latin-1 character set in
+the type @code{CHARACTER}. GNAT supports the Latin-1 character set
+in the type @code{CHARACTER} and also Unicode (ISO 10646 BMP) in
+the type @code{WIDE_CHARACTER}.
+
+The floating-point types supported by GNAT are those
+supported by HP Ada, but the defaults are different, and are controlled by
+pragmas. See @ref{Floating-Point Types and Representations}, for details.
+
+@node The Package SYSTEM
+@section The Package @code{SYSTEM}
+
+@noindent
+HP Ada provides a specific version of the package
+@code{SYSTEM} for each platform on which the language is implemented.
+For the complete specification of the package @code{SYSTEM}, see
+Appendix F of the @cite{HP Ada Language Reference Manual}.
+
+On HP Ada, the package @code{SYSTEM} includes the following conversion
+functions:
+@itemize @bullet
+@item @code{TO_ADDRESS(INTEGER)}
+
+@item @code{TO_ADDRESS(UNSIGNED_LONGWORD)}
+
+@item @code{TO_ADDRESS(}@i{universal_integer}@code{)}
+
+@item @code{TO_INTEGER(ADDRESS)}
+
+@item @code{TO_UNSIGNED_LONGWORD(ADDRESS)}
+
+@item Function @code{IMPORT_VALUE return UNSIGNED_LONGWORD} and the
+              functions @code{IMPORT_ADDRESS} and @code{IMPORT_LARGEST_VALUE}
+@end itemize
+
+@noindent
+By default, GNAT supplies a version of @code{SYSTEM} that matches
+the definition given in the @cite{Ada Reference Manual}.
+This
+is a subset of the HP system definitions, which is as
+close as possible to the original definitions. The only difference
+is that the definition of @code{SYSTEM_NAME} is different:
+
+@smallexample @c ada
+@cartouche
+type Name is (SYSTEM_NAME_GNAT);
+System_Name : constant Name := SYSTEM_NAME_GNAT;
+@end cartouche
+@end smallexample
+
+@noindent
+Also, GNAT adds the Ada declarations for
+@code{BIT_ORDER} and @code{DEFAULT_BIT_ORDER}.
+
+However, the use of the following pragma causes GNAT
+to extend the definition of package @code{SYSTEM} so that it
+encompasses the full set of HP-specific extensions,
+including the functions listed above:
+
+@smallexample @c ada
+@cartouche
+pragma Extend_System (Aux_DEC);
+@end cartouche
+@end smallexample
+
+@noindent
+The pragma @code{Extend_System} is a configuration pragma that
+is most conveniently placed in the @file{gnat.adc} file. See the
+@cite{GNAT Reference Manual} for further details.
+
+HP Ada does not allow the recompilation of the package
+@code{SYSTEM}. Instead HP Ada provides several pragmas
+(@code{SYSTEM_NAME}, @code{STORAGE_UNIT}, and @code{MEMORY_SIZE})
+to modify values in the package @code{SYSTEM}.
+On OpenVMS Alpha systems, the pragma
+@code{SYSTEM_NAME} takes the enumeration literal @code{OPENVMS_AXP} as
+its single argument.
+
+GNAT does permit the recompilation of package @code{SYSTEM} using
+the special switch @option{-gnatg}, and this switch can be used if
+it is necessary to modify the definitions in @code{SYSTEM}. GNAT does
+not permit the specification of @code{SYSTEM_NAME}, @code{STORAGE_UNIT}
+or @code{MEMORY_SIZE} by any other means.
+
+On GNAT systems, the pragma @code{SYSTEM_NAME} takes the
+enumeration literal @code{SYSTEM_NAME_GNAT}.
+
+The definitions provided by the use of
+
+@smallexample @c ada
+pragma Extend_System (AUX_Dec);
+@end smallexample
+
+@noindent
+are virtually identical to those provided by the HP Ada 83 package
+@code{SYSTEM}. One important difference is that the name of the
+@code{TO_ADDRESS}
+function for type @code{UNSIGNED_LONGWORD} is changed to
+@code{TO_ADDRESS_LONG}.
+See the @cite{GNAT Reference Manual} for a discussion of why this change was
+necessary.
+
+@noindent
+The version of @code{TO_ADDRESS} taking a @i{universal_integer} argument
+is in fact
+an extension to Ada 83 not strictly compatible with the reference manual.
+GNAT, in order to be exactly compatible with the standard,
+does not provide this capability. In HP Ada 83, the
+point of this definition is to deal with a call like:
+
+@smallexample @c ada
+TO_ADDRESS (16#12777#);
+@end smallexample
+
+@noindent
+Normally, according to Ada 83 semantics, one would expect this to be
+ambiguous, since it matches both the @code{INTEGER} and
+@code{UNSIGNED_LONGWORD} forms of @code{TO_ADDRESS}.
+However, in HP Ada 83, there is no ambiguity, since the
+definition using @i{universal_integer} takes precedence.
+
+In GNAT, since the version with @i{universal_integer} cannot be supplied,
+it is
+not possible to be 100% compatible. Since there are many programs using
+numeric constants for the argument to @code{TO_ADDRESS}, the decision in
+GNAT was
+to change the name of the function in the @code{UNSIGNED_LONGWORD} case,
+so the declarations provided in the GNAT version of @code{AUX_Dec} are:
+
+@smallexample @c ada
+function To_Address (X : Integer) return Address;
+pragma Pure_Function (To_Address);
+
+function To_Address_Long (X : Unsigned_Longword) return Address;
+pragma Pure_Function (To_Address_Long);
+@end smallexample
+
+@noindent
+This means that programs using @code{TO_ADDRESS} for
+@code{UNSIGNED_LONGWORD} must change the name to @code{TO_ADDRESS_LONG}.
+
+@node Tasking and Task-Related Features
+@section Tasking and Task-Related Features
+
+@noindent
+This section compares the treatment of tasking in GNAT
+and in HP Ada for OpenVMS Alpha.
+The GNAT description applies to both Alpha and I64 OpenVMS.
+For detailed information on tasking in
+HP Ada, see the @cite{HP Ada Language Reference Manual} and the
+relevant run-time reference manual.
+
+@menu
+* Implementation of Tasks in HP Ada for OpenVMS Alpha Systems::
+* Assigning Task IDs::
+* Task IDs and Delays::
+* Task-Related Pragmas::
+* Scheduling and Task Priority::
+* The Task Stack::
+* External Interrupts::
+@end menu
+
+@node Implementation of Tasks in HP Ada for OpenVMS Alpha Systems
+@subsection Implementation of Tasks in HP Ada for OpenVMS Alpha Systems
+
+@noindent
+On OpenVMS Alpha systems, each Ada task (except a passive
+task) is implemented as a single stream of execution
+that is created and managed by the kernel. On these
+systems, HP Ada tasking support is based on DECthreads,
+an implementation of the POSIX standard for threads.
+
+Also, on OpenVMS Alpha systems, HP Ada tasks and foreign
+code that calls DECthreads routines can be used together.
+The interaction between Ada tasks and DECthreads routines
+can have some benefits. For example when on OpenVMS Alpha,
+HP Ada can call C code that is already threaded.
+
+GNAT uses the facilities of DECthreads,
+and Ada tasks are mapped to threads.
+
+@node Assigning Task IDs
+@subsection Assigning Task IDs
+
+@noindent
+The HP Ada Run-Time Library always assigns @code{%TASK 1} to
+the environment task that executes the main program. On
+OpenVMS Alpha systems, @code{%TASK 0} is often used for tasks
+that have been created but are not yet activated.
+
+On OpenVMS Alpha systems, task IDs are assigned at
+activation. On GNAT systems, task IDs are also assigned at
+task creation but do not have the same form or values as
+task ID values in HP Ada. There is no null task, and the
+environment task does not have a specific task ID value.
+
+@node Task IDs and Delays
+@subsection Task IDs and Delays
+
+@noindent
+On OpenVMS Alpha systems, tasking delays are implemented
+using Timer System Services. The Task ID is used for the
+identification of the timer request (the @code{REQIDT} parameter).
+If Timers are used in the application take care not to use
+@code{0} for the identification, because cancelling such a timer
+will cancel all timers and may lead to unpredictable results.
+
+@node Task-Related Pragmas
+@subsection Task-Related Pragmas
+
+@noindent
+Ada supplies the pragma @code{TASK_STORAGE}, which allows
+specification of the size of the guard area for a task
+stack. (The guard area forms an area of memory that has no
+read or write access and thus helps in the detection of
+stack overflow.) On OpenVMS Alpha systems, if the pragma
+@code{TASK_STORAGE} specifies a value of zero, a minimal guard
+area is created. In the absence of a pragma @code{TASK_STORAGE},
+a default guard area is created.
+
+GNAT supplies the following task-related pragmas:
+
+@itemize @bullet
+@item  @code{TASK_INFO}
+
+              This pragma appears within a task definition and
+              applies to the task in which it appears. The argument
+              must be of type @code{SYSTEM.TASK_INFO.TASK_INFO_TYPE}.
+
+@item  @code{TASK_STORAGE}
+
+              GNAT implements pragma @code{TASK_STORAGE} in the same way as
+              HP Ada.
+              Both HP Ada and GNAT supply the pragmas @code{PASSIVE},
+              @code{SUPPRESS}, and @code{VOLATILE}.
+@end itemize
+@node Scheduling and Task Priority
+@subsection Scheduling and Task Priority
+
+@noindent
+HP Ada implements the Ada language requirement that
+when two tasks are eligible for execution and they have
+different priorities, the lower priority task does not
+execute while the higher priority task is waiting. The HP
+Ada Run-Time Library keeps a task running until either the
+task is suspended or a higher priority task becomes ready.
+
+On OpenVMS Alpha systems, the default strategy is round-
+robin with preemption. Tasks of equal priority take turns
+at the processor. A task is run for a certain period of
+time and then placed at the tail of the ready queue for
+its priority level.
+
+HP Ada provides the implementation-defined pragma @code{TIME_SLICE},
+which can be used to enable or disable round-robin
+scheduling of tasks with the same priority.
+See the relevant HP Ada run-time reference manual for
+information on using the pragmas to control HP Ada task
+scheduling.
+
+GNAT follows the scheduling rules of Annex D (Real-Time
+Annex) of the @cite{Ada Reference Manual}. In general, this
+scheduling strategy is fully compatible with HP Ada
+although it provides some additional constraints (as
+fully documented in Annex D).
+GNAT implements time slicing control in a manner compatible with
+HP Ada 83, by means of the pragma @code{Time_Slice}, whose semantics
+are identical to the HP Ada 83 pragma of the same name.
+Note that it is not possible to mix GNAT tasking and
+HP Ada 83 tasking in the same program, since the two run-time
+libraries are not compatible.
+
+@node The Task Stack
+@subsection The Task Stack
+
+@noindent
+In HP Ada, a task stack is allocated each time a
+non-passive task is activated. As soon as the task is
+terminated, the storage for the task stack is deallocated.
+If you specify a size of zero (bytes) with @code{T'STORAGE_SIZE},
+a default stack size is used. Also, regardless of the size
+specified, some additional space is allocated for task
+management purposes. On OpenVMS Alpha systems, at least
+one page is allocated.
+
+GNAT handles task stacks in a similar manner. In accordance with
+the Ada rules, it provides the pragma @code{STORAGE_SIZE} as
+an alternative method for controlling the task stack size.
+The specification of the attribute @code{T'STORAGE_SIZE} is also
+supported in a manner compatible with HP Ada.
+
+@node External Interrupts
+@subsection External Interrupts
+
+@noindent
+On HP Ada, external interrupts can be associated with task entries.
+GNAT is compatible with HP Ada in its handling of external interrupts.
+
+@node Pragmas and Pragma-Related Features
+@section Pragmas and Pragma-Related Features
+
+@noindent
+Both HP Ada and GNAT supply all language-defined pragmas
+as specified by the Ada 83 standard. GNAT also supplies all
+language-defined pragmas introduced by Ada 95 and Ada 2005.
+In addition, GNAT implements the implementation-defined pragmas
+from HP Ada 83.
+
+@itemize @bullet
+@item  @code{AST_ENTRY}
+
+@item  @code{COMMON_OBJECT}
+
+@item  @code{COMPONENT_ALIGNMENT}
+
+@item  @code{EXPORT_EXCEPTION}
+
+@item  @code{EXPORT_FUNCTION}
+
+@item  @code{EXPORT_OBJECT}
+
+@item  @code{EXPORT_PROCEDURE}
+
+@item  @code{EXPORT_VALUED_PROCEDURE}
+
+@item  @code{FLOAT_REPRESENTATION}
+
+@item  @code{IDENT}
+
+@item  @code{IMPORT_EXCEPTION}
+
+@item  @code{IMPORT_FUNCTION}
+
+@item  @code{IMPORT_OBJECT}
+
+@item  @code{IMPORT_PROCEDURE}
+
+@item  @code{IMPORT_VALUED_PROCEDURE}
+
+@item  @code{INLINE_GENERIC}
+
+@item  @code{INTERFACE_NAME}
+
+@item  @code{LONG_FLOAT}
+
+@item  @code{MAIN_STORAGE}
+
+@item  @code{PASSIVE}
+
+@item  @code{PSECT_OBJECT}
+
+@item  @code{SHARE_GENERIC}
+
+@item  @code{SUPPRESS_ALL}
+
+@item  @code{TASK_STORAGE}
+
+@item  @code{TIME_SLICE}
+
+@item  @code{TITLE}
+@end itemize
+
+@noindent
+These pragmas are all fully implemented, with the exception of @code{TITLE},
+@code{PASSIVE}, and @code{SHARE_GENERIC}, which are
+recognized, but which have no
+effect in GNAT. The effect of @code{PASSIVE} may be obtained by the
+use of Ada protected objects. In GNAT, all generics are inlined.
+
+Unlike HP Ada, the GNAT ``@code{EXPORT_}@i{subprogram}'' pragmas require
+a separate subprogram specification which must appear before the
+subprogram body.
+
+GNAT also supplies a number of implementation-defined pragmas as follows:
+@itemize @bullet
+@item  @code{ABORT_DEFER}
+
+@item  @code{ADA_83}
+
+@item  @code{ADA_95}
+
+@item  @code{ADA_05}
+
+@item  @code{ANNOTATE}
+
+@item  @code{ASSERT}
+
+@item  @code{C_PASS_BY_COPY}
+
+@item  @code{CPP_CLASS}
+
+@item  @code{CPP_CONSTRUCTOR}
+
+@item  @code{CPP_DESTRUCTOR}
+
+@item  @code{DEBUG}
+
+@item  @code{EXTEND_SYSTEM}
+
+@item  @code{LINKER_ALIAS}
+
+@item  @code{LINKER_SECTION}
+
+@item  @code{MACHINE_ATTRIBUTE}
+
+@item  @code{NO_RETURN}
+
+@item  @code{PURE_FUNCTION}
+
+@item  @code{SOURCE_FILE_NAME}
+
+@item  @code{SOURCE_REFERENCE}
+
+@item  @code{TASK_INFO}
+
+@item  @code{UNCHECKED_UNION}
+
+@item  @code{UNIMPLEMENTED_UNIT}
+
+@item  @code{UNIVERSAL_DATA}
+
+@item  @code{UNSUPPRESS}
+
+@item  @code{WARNINGS}
+
+@item  @code{WEAK_EXTERNAL}
+@end itemize
+
+@noindent
+For full details on these GNAT implementation-defined pragmas, see
+the GNAT Reference Manual.
+
+@menu
+* Restrictions on the Pragma INLINE::
+* Restrictions on the Pragma INTERFACE::
+* Restrictions on the Pragma SYSTEM_NAME::
+@end menu
+
+@node Restrictions on the Pragma INLINE
+@subsection Restrictions on Pragma @code{INLINE}
+
+@noindent
+HP Ada enforces the following restrictions on the pragma @code{INLINE}:
+@itemize @bullet
+@item  Parameters cannot have a task type.
+
+@item  Function results cannot be task types, unconstrained
+array types, or unconstrained types with discriminants.
+
+@item  Bodies cannot declare the following:
+@itemize @bullet
+@item  Subprogram body or stub (imported subprogram is allowed)
+
+@item  Tasks
+
+@item  Generic declarations
+
+@item  Instantiations
+
+@item  Exceptions
+
+@item  Access types (types derived from access types allowed)
+
+@item  Array or record types
+
+@item  Dependent tasks
+
+@item  Direct recursive calls of subprogram or containing
+subprogram, directly or via a renaming
+
+@end itemize
+@end itemize
+
+@noindent
+In GNAT, the only restriction on pragma @code{INLINE} is that the
+body must occur before the call if both are in the same
+unit, and the size must be appropriately small. There are
+no other specific restrictions which cause subprograms to
+be incapable of being inlined.
+
+@node  Restrictions on the Pragma INTERFACE
+@subsection  Restrictions on Pragma @code{INTERFACE}
+
+@noindent
+The following restrictions on pragma @code{INTERFACE}
+are enforced by both HP Ada and GNAT:
+@itemize @bullet
+@item  Languages accepted: Ada, Bliss, C, Fortran, Default.
+Default is the default on OpenVMS Alpha systems.
+
+@item  Parameter passing: Language specifies default
+mechanisms but can be overridden with an @code{EXPORT} pragma.
+
+@itemize @bullet
+@item  Ada: Use internal Ada rules.
+
+@item  Bliss, C: Parameters must be mode @code{in}; cannot be
+record or task type. Result cannot be a string, an
+array, or a record.
+
+@item  Fortran: Parameters cannot have a task type. Result cannot
+be a string, an array, or a record.
+@end itemize
+@end itemize
+
+@noindent
+GNAT is entirely upwards compatible with HP Ada, and in addition allows
+record parameters for all languages.
+
+@node  Restrictions on the Pragma SYSTEM_NAME
+@subsection  Restrictions on Pragma @code{SYSTEM_NAME}
+
+@noindent
+For HP Ada for OpenVMS Alpha, the enumeration literal
+for the type @code{NAME} is @code{OPENVMS_AXP}.
+In GNAT, the enumeration
+literal for the type @code{NAME} is @code{SYSTEM_NAME_GNAT}.
+
+@node  Library of Predefined Units
+@section  Library of Predefined Units
+
+@noindent
+A library of predefined units is provided as part of the
+HP Ada and GNAT implementations. HP Ada does not provide
+the package @code{MACHINE_CODE} but instead recommends importing
+assembler code.
+
+The GNAT versions of the HP Ada Run-Time Library (@code{ADA$PREDEFINED:})
+units are taken from the OpenVMS Alpha version, not the OpenVMS VAX
+version.
+The HP Ada Predefined Library units are modified to remove post-Ada 83
+incompatibilities and to make them interoperable with GNAT
+(@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
+
+@node Changes to DECLIB
+@subsection Changes to @code{DECLIB}
+
+@noindent
+The changes made to the HP Ada predefined library for GNAT and post-Ada 83
+compatibility are minor and include the following:
+
+@itemize @bullet
+@item  Adjusting the location of pragmas and record representation
+clauses to obey Ada 95 (and thus Ada 2005) rules
+
+@item  Adding the proper notation to generic formal parameters
+that take unconstrained types in instantiation
+
+@item  Adding pragma @code{ELABORATE_BODY} to package specifications
+that have package bodies not otherwise allowed
+
+@item  Replacing occurrences of the identifier ``@code{PROTECTED}'' by
+``@code{PROTECTD}''.
+Currently these are found only in the @code{STARLET} package spec.
+
+@item Changing @code{SYSTEM.ADDRESS} to @code{SYSTEM.SHORT_ADDRESS}
+where the address size is constrained to 32 bits.
+@end itemize
+
+@noindent
+None of the above changes is visible to users.
+
+@node Bindings
+@section Bindings
+
+@noindent
+On OpenVMS Alpha, HP Ada provides the following strongly-typed bindings:
+@itemize @bullet
+
+@item  Command Language Interpreter (CLI interface)
+
+@item  DECtalk Run-Time Library (DTK interface)
+
+@item  Librarian utility routines (LBR interface)
+
+@item  General Purpose Run-Time Library (LIB interface)
+
+@item  Math Run-Time Library (MTH interface)
+
+@item  National Character Set Run-Time Library (NCS interface)
+
+@item  Compiled Code Support Run-Time Library (OTS interface)
+
+@item  Parallel Processing Run-Time Library (PPL interface)
+
+@item  Screen Management Run-Time Library (SMG interface)
+
+@item  Sort Run-Time Library (SOR interface)
+
+@item  String Run-Time Library (STR interface)
+
+@item STARLET System Library
+@findex Starlet
+
+@item  X Window System Version 11R4 and 11R5 (X, XLIB interface)
+
+@item  X Windows Toolkit (XT interface)
+
+@item  X/Motif Version 1.1.3 and 1.2 (XM interface)
+@end itemize
+
+@noindent
+GNAT provides implementations of these HP bindings in the @code{DECLIB}
+directory, on both the Alpha and I64 OpenVMS platforms.
+
+The X/Motif bindings used to build @code{DECLIB} are whatever versions are
+in the
+HP Ada @file{ADA$PREDEFINED} directory with extension @file{.ADC}.
+A pragma @code{Linker_Options} has been added to packages @code{Xm},
+@code{Xt}, and @code{X_Lib}
+causing the default X/Motif sharable image libraries to be linked in. This
+is done via options files named @file{xm.opt}, @file{xt.opt}, and
+@file{x_lib.opt} (also located in the @file{DECLIB} directory).
+
+It may be necessary to edit these options files to update or correct the
+library names if, for example, the newer X/Motif bindings from
+@file{ADA$EXAMPLES}
+had been (previous to installing GNAT) copied and renamed to supersede the
+default @file{ADA$PREDEFINED} versions.
+
+@menu
+* Shared Libraries and Options Files::
+* Interfaces to C::
+@end menu
+
+@node Shared Libraries and Options Files
+@subsection Shared Libraries and Options Files
+
+@noindent
+When using the HP Ada
+predefined X and Motif bindings, the linking with their sharable images is
+done automatically by @command{GNAT LINK}.
+When using other X and Motif bindings, you need
+to add the corresponding sharable images to the command line for
+@code{GNAT LINK}. When linking with shared libraries, or with
+@file{.OPT} files, you must
+also add them to the command line for @command{GNAT LINK}.
+
+A shared library to be used with GNAT is built in the same way as other
+libraries under VMS. The VMS Link command can be used in standard fashion.
+
+@node Interfaces to C
+@subsection Interfaces to C
+
+@noindent
+HP Ada
+provides the following Ada types and operations:
+
+@itemize @bullet
+@item C types package (@code{C_TYPES})
+
+@item C strings (@code{C_TYPES.NULL_TERMINATED})
+
+@item Other_types (@code{SHORT_INT})
+@end itemize
+
+@noindent
+Interfacing to C with GNAT, you can use the above approach
+described for HP Ada or the facilities of Annex B of
+the @cite{Ada Reference Manual} (packages @code{INTERFACES.C},
+@code{INTERFACES.C.STRINGS} and @code{INTERFACES.C.POINTERS}). For more
+information, see the section ``Interfacing to C'' in the
+@cite{GNAT Reference Manual}.
+
+The @option{-gnatF} qualifier forces default and explicit
+@code{External_Name} parameters in pragmas @code{Import} and @code{Export}
+to be uppercased for compatibility with the default behavior
+of HP C. The qualifier has no effect on @code{Link_Name} parameters.
+
+@node Main Program Definition
+@section Main Program Definition
+
+@noindent
+The following section discusses differences in the
+definition of main programs on HP Ada and GNAT.
+On HP Ada, main programs are defined to meet the
+following conditions:
+@itemize @bullet
+@item  Procedure with no formal parameters (returns @code{0} upon
+       normal completion)
+
+@item  Procedure with no formal parameters (returns @code{42} when
+       an unhandled exception is raised)
+
+@item  Function with no formal parameters whose returned value
+       is of a discrete type
+
+@item  Procedure with one @code{out} formal of a discrete type for
+       which a specification of pragma @code{EXPORT_VALUED_PROCEDURE}
+       is given.
+
+@end itemize
+
+@noindent
+When declared with the pragma @code{EXPORT_VALUED_PROCEDURE},
+a main function or main procedure returns a discrete
+value whose size is less than 64 bits (32 on VAX systems),
+the value is zero- or sign-extended as appropriate.
+On GNAT, main programs are defined as follows:
+@itemize @bullet
+@item  Must be a non-generic, parameterless subprogram that
+is either a procedure or function returning an Ada
+@code{STANDARD.INTEGER} (the predefined type)
+
+@item  Cannot be a generic subprogram or an instantiation of a
+generic subprogram
+@end itemize
+
+@node Implementation-Defined Attributes
+@section Implementation-Defined Attributes
+
+@noindent
+GNAT provides all HP Ada implementation-defined
+attributes.
+
+@node Compiler and Run-Time Interfacing
+@section Compiler and Run-Time Interfacing
+
+@noindent
+HP Ada provides the following qualifiers to pass options to the linker
+(ACS LINK):
+@itemize @bullet
+@item  @option{/WAIT} and @option{/SUBMIT}
+
+@item  @option{/COMMAND}
+
+@item  @option{/[NO]MAP}
+
+@item  @option{/OUTPUT=@i{file-spec}}
+
+@item  @option{/[NO]DEBUG} and @option{/[NO]TRACEBACK}
+@end itemize
+
+@noindent
+To pass options to the linker, GNAT provides the following
+switches:
+
+@itemize @bullet
+@item   @option{/EXECUTABLE=@i{exec-name}}
+
+@item   @option{/VERBOSE}
+
+@item   @option{/[NO]DEBUG} and @option{/[NO]TRACEBACK}
+@end itemize
+
+@noindent
+For more information on these switches, see
+@ref{Switches for gnatlink}.
+In HP Ada, the command-line switch @option{/OPTIMIZE} is available
+to control optimization. HP Ada also supplies the
+following pragmas:
+@itemize @bullet
+@item  @code{OPTIMIZE}
+
+@item  @code{INLINE}
+
+@item  @code{INLINE_GENERIC}
+
+@item  @code{SUPPRESS_ALL}
+
+@item  @code{PASSIVE}
+@end itemize
+
+@noindent
+In GNAT, optimization is controlled strictly by command
+line parameters, as described in the corresponding section of this guide.
+The HP pragmas for control of optimization are
+recognized but ignored.
+
+Note that in GNAT, the default is optimization off, whereas in HP Ada
+the default is that optimization is turned on.
+
+@node Program Compilation and Library Management
+@section Program Compilation and Library Management
+
+@noindent
+HP Ada and GNAT provide a comparable set of commands to
+build programs. HP Ada also provides a program library,
+which is a concept that does not exist on GNAT. Instead,
+GNAT provides directories of sources that are compiled as
+needed.
+
+The following table summarizes
+the HP Ada commands and provides
+equivalent GNAT commands. In this table, some GNAT
+equivalents reflect the fact that GNAT does not use the
+concept of a program library. Instead, it uses a model
+in which collections of source and object files are used
+in a manner consistent with other languages like C and
+Fortran. Therefore, standard system file commands are used
+to manipulate these elements. Those GNAT commands are marked with
+an asterisk.
+Note that, unlike HP Ada, none of the GNAT commands accepts wild cards.
+
+@need 1500
+@multitable @columnfractions .35 .65
+
+@item @emph{HP Ada Command}
+@tab @emph{GNAT Equivalent / Description}
+
+@item @command{ADA}
+@tab @command{GNAT COMPILE}@*
+Invokes the compiler to compile one or more Ada source files.
+
+@item @command{ACS ATTACH}@*
+@tab [No equivalent]@*
+Switches control of terminal from current process running the program
+library manager.
+
+@item @command{ACS CHECK}
+@tab @command{GNAT MAKE /DEPENDENCY_LIST}@*
+Forms the execution closure of one
+or more compiled units and checks completeness and currency.
+
+@item @command{ACS COMPILE}
+@tab @command{GNAT MAKE /ACTIONS=COMPILE}@*
+Forms the execution closure of one or
+more specified units, checks completeness and currency,
+identifies units that have revised source files, compiles same,
+and recompiles units that are or will become obsolete.
+Also completes incomplete generic instantiations.
+
+@item @command{ACS COPY FOREIGN}
+@tab Copy (*)@*
+Copies a foreign object file into the program library as a
+library unit body.
+
+@item @command{ACS COPY UNIT}
+@tab Copy (*)@*
+Copies a compiled unit from one program library to another.
+
+@item @command{ACS CREATE LIBRARY}
+@tab Create /directory (*)@*
+Creates a program library.
+
+@item @command{ACS CREATE SUBLIBRARY}
+@tab Create /directory (*)@*
+Creates a program sublibrary.
+
+@item @command{ACS DELETE LIBRARY}
+@tab @*
+Deletes a program library and its contents.
+
+@item @command{ACS DELETE SUBLIBRARY}
+@tab @*
+Deletes a program sublibrary and its contents.
+
+@item @command{ACS DELETE UNIT}
+@tab Delete file (*)@*
+On OpenVMS systems, deletes one or more compiled units from
+the current program library.
+
+@item @command{ACS DIRECTORY}
+@tab Directory (*)@*
+On OpenVMS systems, lists units contained in the current
+program library.
+
+@item @command{ACS ENTER FOREIGN}
+@tab Copy (*)@*
+Allows the import of a foreign body as an Ada library
+specification and enters a reference to a pointer.
+
+@item @command{ACS ENTER UNIT}
+@tab Copy (*)@*
+Enters a reference (pointer) from the current program library to
+a unit compiled into another program library.
+
+@item @command{ACS EXIT}
+@tab [No equivalent]@*
+Exits from the program library manager.
+
+@item @command{ACS EXPORT}
+@tab Copy (*)@*
+Creates an object file that contains system-specific object code
+for one or more units. With GNAT, object files can simply be copied
+into the desired directory.
+
+@item @command{ACS EXTRACT SOURCE}
+@tab Copy (*)@*
+Allows access to the copied source file for each Ada compilation unit
+
+@item @command{ACS HELP}
+@tab @command{HELP GNAT}@*
+Provides online help.
+
+@item @command{ACS LINK}
+@tab @command{GNAT LINK}@*
+Links an object file containing Ada units into an executable file.
+
+@item @command{ACS LOAD}
+@tab Copy (*)@*
+Loads (partially compiles) Ada units into the program library.
+Allows loading a program from a collection of files into a library
+without knowing the relationship among units.
+
+@item @command{ACS MERGE}
+@tab Copy (*)@*
+Merges into the current program library, one or more units from
+another library where they were modified.
+
+@item @command{ACS RECOMPILE}
+@tab @command{GNAT MAKE /ACTIONS=COMPILE}@*
+Recompiles from   external or copied source files any obsolete
+unit in the closure. Also, completes any incomplete generic
+instantiations.
+
+@item @command{ACS REENTER}
+@tab @command{GNAT MAKE}@*
+Reenters current references to units compiled after last entered
+with the @command{ACS ENTER UNIT} command.
+
+@item @command{ACS SET LIBRARY}
+@tab Set default (*)@*
+Defines a program library to be the compilation context as well
+as the target library for compiler output and commands in general.
 
-   --  The following Export pragmas export the version numbers
-   --  with symbolic names ending in B (for body) or S
-   --  (for spec) so that they can be located in a link. The
-   --  information provided here is sufficient to track down
-   --  the exact versions of units used in a given build.
+@item @command{ACS SET PRAGMA}
+@tab Edit @file{gnat.adc} (*)@*
+Redefines specified  values of the library characteristics
+@code{LONG_ FLOAT}, @code{MEMORY_SIZE}, @code{SYSTEM_NAME},
+and @code{Float_Representation}.
 
-   pragma Export (C, u00001, "helloB");
-   pragma Export (C, u00002, "system__standard_libraryB");
-   pragma Export (C, u00003, "system__standard_libraryS");
-   pragma Export (C, u00004, "adaS");
-   pragma Export (C, u00005, "ada__text_ioB");
-   pragma Export (C, u00006, "ada__text_ioS");
-   pragma Export (C, u00007, "ada__exceptionsB");
-   pragma Export (C, u00008, "ada__exceptionsS");
-   pragma Export (C, u00009, "gnatS");
-   pragma Export (C, u00010, "gnat__heap_sort_aB");
-   pragma Export (C, u00011, "gnat__heap_sort_aS");
-   pragma Export (C, u00012, "systemS");
-   pragma Export (C, u00013, "system__exception_tableB");
-   pragma Export (C, u00014, "system__exception_tableS");
-   pragma Export (C, u00015, "gnat__htableB");
-   pragma Export (C, u00016, "gnat__htableS");
-   pragma Export (C, u00017, "system__exceptionsS");
-   pragma Export (C, u00018, "system__machine_state_operationsB");
-   pragma Export (C, u00019, "system__machine_state_operationsS");
-   pragma Export (C, u00020, "system__machine_codeS");
-   pragma Export (C, u00021, "system__storage_elementsB");
-   pragma Export (C, u00022, "system__storage_elementsS");
-   pragma Export (C, u00023, "system__secondary_stackB");
-   pragma Export (C, u00024, "system__secondary_stackS");
-   pragma Export (C, u00025, "system__parametersB");
-   pragma Export (C, u00026, "system__parametersS");
-   pragma Export (C, u00027, "system__soft_linksB");
-   pragma Export (C, u00028, "system__soft_linksS");
-   pragma Export (C, u00029, "system__stack_checkingB");
-   pragma Export (C, u00030, "system__stack_checkingS");
-   pragma Export (C, u00031, "system__tracebackB");
-   pragma Export (C, u00032, "system__tracebackS");
-   pragma Export (C, u00033, "ada__streamsS");
-   pragma Export (C, u00034, "ada__tagsB");
-   pragma Export (C, u00035, "ada__tagsS");
-   pragma Export (C, u00036, "system__string_opsB");
-   pragma Export (C, u00037, "system__string_opsS");
-   pragma Export (C, u00038, "interfacesS");
-   pragma Export (C, u00039, "interfaces__c_streamsB");
-   pragma Export (C, u00040, "interfaces__c_streamsS");
-   pragma Export (C, u00041, "system__file_ioB");
-   pragma Export (C, u00042, "system__file_ioS");
-   pragma Export (C, u00043, "ada__finalizationB");
-   pragma Export (C, u00044, "ada__finalizationS");
-   pragma Export (C, u00045, "system__finalization_rootB");
-   pragma Export (C, u00046, "system__finalization_rootS");
-   pragma Export (C, u00047, "system__finalization_implementationB");
-   pragma Export (C, u00048, "system__finalization_implementationS");
-   pragma Export (C, u00049, "system__string_ops_concat_3B");
-   pragma Export (C, u00050, "system__string_ops_concat_3S");
-   pragma Export (C, u00051, "system__stream_attributesB");
-   pragma Export (C, u00052, "system__stream_attributesS");
-   pragma Export (C, u00053, "ada__io_exceptionsS");
-   pragma Export (C, u00054, "system__unsigned_typesS");
-   pragma Export (C, u00055, "system__file_control_blockS");
-   pragma Export (C, u00056, "ada__finalization__list_controllerB");
-   pragma Export (C, u00057, "ada__finalization__list_controllerS");
+@item @command{ACS SET SOURCE}
+@tab Define @code{ADA_INCLUDE_PATH} path (*)@*
+Defines the source file search list for the @command{ACS COMPILE} command.
 
-   -- BEGIN ELABORATION ORDER
-   -- ada (spec)
-   -- gnat (spec)
-   -- gnat.heap_sort_a (spec)
-   -- gnat.heap_sort_a (body)
-   -- gnat.htable (spec)
-   -- gnat.htable (body)
-   -- interfaces (spec)
-   -- system (spec)
-   -- system.machine_code (spec)
-   -- system.parameters (spec)
-   -- system.parameters (body)
-   -- interfaces.c_streams (spec)
-   -- interfaces.c_streams (body)
-   -- system.standard_library (spec)
-   -- ada.exceptions (spec)
-   -- system.exception_table (spec)
-   -- system.exception_table (body)
-   -- ada.io_exceptions (spec)
-   -- system.exceptions (spec)
-   -- system.storage_elements (spec)
-   -- system.storage_elements (body)
-   -- system.machine_state_operations (spec)
-   -- system.machine_state_operations (body)
-   -- system.secondary_stack (spec)
-   -- system.stack_checking (spec)
-   -- system.soft_links (spec)
-   -- system.soft_links (body)
-   -- system.stack_checking (body)
-   -- system.secondary_stack (body)
-   -- system.standard_library (body)
-   -- system.string_ops (spec)
-   -- system.string_ops (body)
-   -- ada.tags (spec)
-   -- ada.tags (body)
-   -- ada.streams (spec)
-   -- system.finalization_root (spec)
-   -- system.finalization_root (body)
-   -- system.string_ops_concat_3 (spec)
-   -- system.string_ops_concat_3 (body)
-   -- system.traceback (spec)
-   -- system.traceback (body)
-   -- ada.exceptions (body)
-   -- system.unsigned_types (spec)
-   -- system.stream_attributes (spec)
-   -- system.stream_attributes (body)
-   -- system.finalization_implementation (spec)
-   -- system.finalization_implementation (body)
-   -- ada.finalization (spec)
-   -- ada.finalization (body)
-   -- ada.finalization.list_controller (spec)
-   -- ada.finalization.list_controller (body)
-   -- system.file_control_block (spec)
-   -- system.file_io (spec)
-   -- system.file_io (body)
-   -- ada.text_io (spec)
-   -- ada.text_io (body)
-   -- hello (body)
-   -- END ELABORATION ORDER
+@item @command{ACS SHOW LIBRARY}
+@tab Directory (*)@*
+Lists information about one or more program libraries.
+
+@item @command{ACS SHOW PROGRAM}
+@tab [No equivalent]@*
+Lists information about the execution closure of one or
+more units in the program library.
+
+@item @command{ACS SHOW SOURCE}
+@tab Show logical @code{ADA_INCLUDE_PATH}@*
+Shows the source file search used when compiling units.
+
+@item @command{ACS SHOW VERSION}
+@tab Compile with @option{VERBOSE} option
+Displays the version number of the compiler and program library
+manager used.
+
+@item @command{ACS SPAWN}
+@tab [No equivalent]@*
+Creates a subprocess of the current process (same as @command{DCL SPAWN}
+command).
+
+@item @command{ACS VERIFY}
+@tab [No equivalent]@*
+Performs a series of consistency checks on a program library to
+determine whether the library structure and library files are in
+valid form.
+@end multitable
+
+@noindent
+
+@node Input-Output
+@section Input-Output
+
+@noindent
+On OpenVMS Alpha systems, HP Ada uses OpenVMS Record
+Management Services (RMS) to perform operations on
+external files.
+
+@noindent
+HP Ada and GNAT predefine an identical set of input-
+output packages. To make the use of the
+generic @code{TEXT_IO} operations more convenient, HP Ada
+provides predefined library packages that instantiate the
+integer and floating-point operations for the predefined
+integer and floating-point types as shown in the following table.
+
+@multitable @columnfractions .45 .55
+@item @emph{Package Name} @tab Instantiation
+
+@item @code{INTEGER_TEXT_IO}
+@tab @code{INTEGER_IO(INTEGER)}
+
+@item @code{SHORT_INTEGER_TEXT_IO}
+@tab @code{INTEGER_IO(SHORT_INTEGER)}
+
+@item @code{SHORT_SHORT_INTEGER_TEXT_IO}
+@tab @code{INTEGER_IO(SHORT_SHORT_INTEGER)}
+
+@item @code{FLOAT_TEXT_IO}
+@tab @code{FLOAT_IO(FLOAT)}
+
+@item @code{LONG_FLOAT_TEXT_IO}
+@tab @code{FLOAT_IO(LONG_FLOAT)}
+@end multitable
+
+@noindent
+The HP Ada predefined packages and their operations
+are implemented using OpenVMS Alpha files and input-output
+facilities. HP Ada supports asynchronous input-output on OpenVMS Alpha.
+Familiarity with the following is recommended:
+@itemize @bullet
+@item  RMS file organizations and access methods
+
+@item  OpenVMS file specifications and directories
+
+@item  OpenVMS File Definition Language (FDL)
+@end itemize
+
+@noindent
+GNAT provides I/O facilities that are completely
+compatible with HP Ada. The distribution includes the
+standard HP Ada versions of all I/O packages, operating
+in a manner compatible with HP Ada. In particular, the
+following packages are by default the HP Ada (Ada 83)
+versions of these packages rather than the renamings
+suggested in Annex J of the Ada Reference Manual:
+@itemize @bullet
+@item  @code{TEXT_IO}
+
+@item  @code{SEQUENTIAL_IO}
+
+@item  @code{DIRECT_IO}
+@end itemize
+
+@noindent
+The use of the standard child package syntax (for
+example, @code{ADA.TEXT_IO}) retrieves the post-Ada 83 versions of these
+packages.
+GNAT provides HP-compatible predefined instantiations
+of the @code{TEXT_IO} packages, and also
+provides the standard predefined instantiations required
+by the @cite{Ada Reference Manual}.
+
+For further information on how GNAT interfaces to the file
+system or how I/O is implemented in programs written in
+mixed languages, see the chapter ``Implementation of the
+Standard I/O'' in the @cite{GNAT Reference Manual}.
+This chapter covers the following:
+@itemize @bullet
+@item  Standard I/O packages
+
+@item  @code{FORM} strings
+
+@item  @code{ADA.DIRECT_IO}
+
+@item  @code{ADA.SEQUENTIAL_IO}
+
+@item  @code{ADA.TEXT_IO}
+
+@item  Stream pointer positioning
+
+@item  Reading and writing non-regular files
+
+@item  @code{GET_IMMEDIATE}
+
+@item  Treating @code{TEXT_IO} files as streams
+
+@item  Shared files
+
+@item  Open modes
+@end itemize
+
+@node Implementation Limits
+@section Implementation Limits
+
+@noindent
+The following table lists implementation limits for HP Ada
+and GNAT systems.
+@multitable @columnfractions .60 .20 .20
+@sp 1
+@item  @emph{Compilation Parameter}
+@tab   @emph{HP Ada}
+@tab   @emph{GNAT}
+@sp 1
 
-end ada_main;
+@item  In a subprogram or entry  declaration, maximum number of
+       formal parameters that are of an unconstrained record type
+@tab   32
+@tab   No set limit
+@sp 1
 
---  The following source file name pragmas allow the generated file
---  names to be unique for different main programs. They are needed
---  since the package name will always be Ada_Main.
+@item  Maximum identifier length (number of characters)
+@tab   255
+@tab   32766
+@sp 1
 
-pragma Source_File_Name (ada_main, Spec_File_Name => "b~hello.ads");
-pragma Source_File_Name (ada_main, Body_File_Name => "b~hello.adb");
+@item  Maximum number of characters in a source line
+@tab   255
+@tab   32766
+@sp 1
 
---  Generated package body for Ada_Main starts here
+@item  Maximum collection size   (number of bytes)
+@tab   2**31-1
+@tab   2**31-1
+@sp 1
 
-package body ada_main is
+@item  Maximum number of discriminants for a record type
+@tab   245
+@tab   No set limit
+@sp 1
 
-   --  The actual finalization is performed by calling the
-   --  library routine in System.Standard_Library.Adafinal
+@item  Maximum number of formal parameters in an entry or
+       subprogram declaration
+@tab   246
+@tab    No set limit
+@sp 1
 
-   procedure Do_Finalize;
-   pragma Import (C, Do_Finalize, "system__standard_library__adafinal");
+@item  Maximum number of dimensions in an array type
+@tab   255
+@tab   No set limit
+@sp 1
 
-   -------------
-   -- adainit --
-   -------------
+@item  Maximum number of library  units and subunits in a compilation.
+@tab   4095
+@tab   No set limit
+@sp 1
 
-@findex adainit
-   procedure adainit is
+@item  Maximum number of library units and subunits in an execution.
+@tab   16383
+@tab   No set limit
+@sp 1
 
-      --  These booleans are set to True once the associated unit has
-      --  been elaborated. It is also used to avoid elaborating the
-      --  same unit twice.
+@item  Maximum number of objects declared with the pragma @code{COMMON_OBJECT}
+       or @code{PSECT_OBJECT}
+@tab   32757
+@tab   No set limit
+@sp 1
 
-      E040 : Boolean;
-      pragma Import (Ada, E040, "interfaces__c_streams_E");
+@item  Maximum number of enumeration literals in an enumeration type
+       definition
+@tab   65535
+@tab   No set limit
+@sp 1
 
-      E008 : Boolean;
-      pragma Import (Ada, E008, "ada__exceptions_E");
+@item  Maximum number of lines in a source file
+@tab   65534
+@tab   No set limit
+@sp 1
 
-      E014 : Boolean;
-      pragma Import (Ada, E014, "system__exception_table_E");
+@item  Maximum number of bits in any object
+@tab   2**31-1
+@tab   2**31-1
+@sp 1
 
-      E053 : Boolean;
-      pragma Import (Ada, E053, "ada__io_exceptions_E");
+@item  Maximum size of the static portion of a stack frame (approximate)
+@tab   2**31-1
+@tab   2**31-1
+@end multitable
 
-      E017 : Boolean;
-      pragma Import (Ada, E017, "system__exceptions_E");
+@node Tools and Utilities
+@section Tools and Utilities
 
-      E024 : Boolean;
-      pragma Import (Ada, E024, "system__secondary_stack_E");
+@noindent
+The following table lists some of the OpenVMS development tools
+available for HP Ada, and the corresponding tools for
+use with @value{EDITION} on Alpha and I64 platforms.
+Aside from the debugger, all the OpenVMS tools identified are part
+of the DECset package.
 
-      E030 : Boolean;
-      pragma Import (Ada, E030, "system__stack_checking_E");
+@iftex
+@c Specify table in TeX since Texinfo does a poor job
+@tex
+\smallskip
+\smallskip
+\settabs\+Language-Sensitive Editor\quad
+   &Product with HP Ada\quad
+   &\cr
+\+\it Tool
+   &\it Product with HP Ada
+   & \it Product with GNAT Pro\cr
+\smallskip
+\+Code Management System
+   &HP CMS
+   & HP CMS\cr
+\smallskip
+\+Language-Sensitive Editor
+   &HP LSE
+   & emacs or HP LSE (Alpha)\cr
+\+
+   &
+   & HP LSE (I64)\cr
+\smallskip
+\+Debugger
+   &OpenVMS Debug
+   & gdb (Alpha),\cr
+\+
+   &
+   & OpenVMS Debug (I64)\cr
+\smallskip
+\+Source Code Analyzer /
+   &HP SCA
+   & GNAT XREF\cr
+\+Cross Referencer
+   &
+   &\cr
+\smallskip
+\+Test Manager
+   &HP Digital Test
+   & HP DTM\cr
+\+
+   &Manager (DTM)
+   &\cr
+\smallskip
+\+Performance and
+   & HP PCA
+   & HP PCA\cr
+\+Coverage Analyzer
+   &
+   &\cr
+\smallskip
+\+Module Management
+   & HP MMS
+   & Not applicable\cr
+\+ System
+   &
+   &\cr
+\smallskip
+\smallskip
+@end tex
+@end iftex
 
-      E028 : Boolean;
-      pragma Import (Ada, E028, "system__soft_links_E");
+@ifnottex
+@c This is the Texinfo version of the table.  It renders poorly in pdf, hence
+@c the TeX version above for the printed version
+@flushleft
+@c @multitable @columnfractions .3 .4 .4
+@multitable {Source Code Analyzer /}{Tool with HP Ada}{Tool with GNAT Pro}
+@item @i{Tool}
+ @tab @i{Tool with HP Ada}
+ @tab @i{Tool with @value{EDITION}}
+@item Code Management@*System
+ @tab HP CMS
+ @tab HP CMS
+@item Language-Sensitive@*Editor
+ @tab HP LSE
+ @tab emacs or HP LSE (Alpha)
+@item
+ @tab
+ @tab HP LSE (I64)
+@item Debugger
+ @tab OpenVMS Debug
+ @tab gdb (Alpha),
+@item
+ @tab
+ @tab OpenVMS Debug (I64)
+@item Source Code Analyzer /@*Cross Referencer
+ @tab HP SCA
+ @tab GNAT XREF
+@item Test Manager
+ @tab HP Digital Test@*Manager (DTM)
+ @tab HP DTM
+@item Performance and@*Coverage Analyzer
+ @tab HP PCA
+ @tab HP PCA
+@item Module Management@*System
+ @tab HP MMS
+ @tab Not applicable
+@end multitable
+@end flushleft
+@end ifnottex
 
-      E035 : Boolean;
-      pragma Import (Ada, E035, "ada__tags_E");
+@end ifset
 
-      E033 : Boolean;
-      pragma Import (Ada, E033, "ada__streams_E");
+@c **************************************
+@node Platform-Specific Information for the Run-Time Libraries
+@appendix Platform-Specific Information for the Run-Time Libraries
+@cindex Tasking and threads libraries
+@cindex Threads libraries and tasking
+@cindex Run-time libraries (platform-specific information)
 
-      E046 : Boolean;
-      pragma Import (Ada, E046, "system__finalization_root_E");
+@noindent
+The GNAT run-time implementation may vary with respect to both the
+underlying threads library and the exception handling scheme.
+For threads support, one or more of the following are supplied:
+@itemize @bullet
+@item @b{native threads library}, a binding to the thread package from
+the underlying operating system
 
-      E048 : Boolean;
-      pragma Import (Ada, E048, "system__finalization_implementation_E");
+@item @b{pthreads library} (Sparc Solaris only), a binding to the Solaris
+POSIX thread package
+@end itemize
 
-      E044 : Boolean;
-      pragma Import (Ada, E044, "ada__finalization_E");
+@noindent
+For exception handling, either or both of two models are supplied:
+@itemize @bullet
+@item @b{Zero-Cost Exceptions} (``ZCX''),@footnote{
+Most programs should experience a substantial speed improvement by
+being compiled with a ZCX run-time.
+This is especially true for
+tasking applications or applications with many exception handlers.}
+@cindex Zero-Cost Exceptions
+@cindex ZCX (Zero-Cost Exceptions)
+which uses binder-generated tables that
+are interrogated at run time to locate a handler
 
-      E057 : Boolean;
-      pragma Import (Ada, E057, "ada__finalization__list_controller_E");
+@item @b{setjmp / longjmp} (``SJLJ''),
+@cindex setjmp/longjmp Exception Model
+@cindex SJLJ (setjmp/longjmp Exception Model)
+which uses dynamically-set data to establish
+the set of handlers
+@end itemize
 
-      E055 : Boolean;
-      pragma Import (Ada, E055, "system__file_control_block_E");
+@noindent
+This appendix summarizes which combinations of threads and exception support
+are supplied on various GNAT platforms.
+It then shows how to select a particular library either
+permanently or temporarily,
+explains the properties of (and tradeoffs among) the various threads
+libraries, and provides some additional
+information about several specific platforms.
+
+@menu
+* Summary of Run-Time Configurations::
+* Specifying a Run-Time Library::
+* Choosing the Scheduling Policy::
+* Solaris-Specific Considerations::
+* Linux-Specific Considerations::
+* AIX-Specific Considerations::
+@end menu
+
+@node Summary of Run-Time Configurations
+@section Summary of Run-Time Configurations
+
+@multitable @columnfractions .30 .70
+@item @b{alpha-openvms}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab native VMS threads
+@item @code{@ @ @ @ }Exceptions @tab ZCX
+@*
+@item @b{alpha-tru64}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab native TRU64 threads
+@item @code{@ @ @ @ }Exceptions @tab ZCX
+@*
+@item @code{@ @ }@i{rts-sjlj}
+@item @code{@ @ @ @ }Tasking    @tab native TRU64 threads
+@item @code{@ @ @ @ }Exceptions @tab SJLJ
+@*
+@item @b{ia64-hp_linux}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab pthread library
+@item @code{@ @ @ @ }Exceptions @tab ZCX
+@*
+@item @b{ia64-hpux}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab native HP-UX threads
+@item @code{@ @ @ @ }Exceptions @tab SJLJ
+@*
+@item @b{ia64-openvms}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab native VMS threads
+@item @code{@ @ @ @ }Exceptions @tab ZCX
+@*
+@item @b{ia64-sgi_linux}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab pthread library
+@item @code{@ @ @ @ }Exceptions @tab ZCX
+@*
+@item @b{mips-irix}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab native IRIX threads
+@item @code{@ @ @ @ }Exceptions @tab ZCX
+@*
+@item @b{pa-hpux}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab native HP-UX threads
+@item @code{@ @ @ @ }Exceptions @tab ZCX
+@*
+@item @code{@ @ }@i{rts-sjlj}
+@item @code{@ @ @ @ }Tasking    @tab native HP-UX threads
+@item @code{@ @ @ @ }Exceptions @tab SJLJ
+@*
+@item @b{ppc-aix}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab native AIX threads
+@item @code{@ @ @ @ }Exceptions @tab SJLJ
+@*
+@item @b{ppc-darwin}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab native MacOS threads
+@item @code{@ @ @ @ }Exceptions @tab ZCX
+@*
+@item @b{sparc-solaris}  @tab
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab native Solaris threads library
+@item @code{@ @ @ @ }Exceptions @tab ZCX
+@*
+@item @code{@ @ }@i{rts-pthread}
+@item @code{@ @ @ @ }Tasking    @tab pthread library
+@item @code{@ @ @ @ }Exceptions @tab ZCX
+@*
+@item @code{@ @ }@i{rts-sjlj}
+@item @code{@ @ @ @ }Tasking    @tab native Solaris threads library
+@item @code{@ @ @ @ }Exceptions @tab SJLJ
+@*
+@item @b{sparc64-solaris}  @tab
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab native Solaris threads library
+@item @code{@ @ @ @ }Exceptions @tab ZCX
+@*
+@item @b{x86-linux}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab pthread library
+@item @code{@ @ @ @ }Exceptions @tab ZCX
+@*
+@item @code{@ @ }@i{rts-sjlj}
+@item @code{@ @ @ @ }Tasking    @tab pthread library
+@item @code{@ @ @ @ }Exceptions @tab SJLJ
+@*
+@item @b{x86-lynx}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab native LynxOS threads
+@item @code{@ @ @ @ }Exceptions @tab SJLJ
+@*
+@item @b{x86-solaris}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab native Solaris threads
+@item @code{@ @ @ @ }Exceptions @tab SJLJ
+@*
+@item @b{x86-windows}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab native Win32 threads
+@item @code{@ @ @ @ }Exceptions @tab ZCX
+@*
+@item @code{@ @ }@i{rts-sjlj (default)}
+@item @code{@ @ @ @ }Tasking    @tab native Win32 threads
+@item @code{@ @ @ @ }Exceptions @tab SJLJ
+@*
+@item @b{x86_64-linux}
+@item @code{@ @ }@i{rts-native (default)}
+@item @code{@ @ @ @ }Tasking    @tab pthread library
+@item @code{@ @ @ @ }Exceptions @tab ZCX
+@*
+@item @code{@ @ }@i{rts-sjlj}
+@item @code{@ @ @ @ }Tasking    @tab pthread library
+@item @code{@ @ @ @ }Exceptions @tab SJLJ
+@*
+@end multitable
+
+@node Specifying a Run-Time Library
+@section Specifying a Run-Time Library
 
-      E042 : Boolean;
-      pragma Import (Ada, E042, "system__file_io_E");
+@noindent
+The @file{adainclude} subdirectory containing the sources of the GNAT
+run-time library, and the @file{adalib} subdirectory containing the
+@file{ALI} files and the static and/or shared GNAT library, are located
+in the gcc target-dependent area:
 
-      E006 : Boolean;
-      pragma Import (Ada, E006, "ada__text_io_E");
+@smallexample
+target=$prefix/lib/gcc/gcc-@i{dumpmachine}/gcc-@i{dumpversion}/
+@end smallexample
 
-      --  Set_Globals is a library routine that stores away the
-      --  value of the indicated set of global values in global
-      --  variables within the library.
+@noindent
+As indicated above, on some platforms several run-time libraries are supplied.
+These libraries are installed in the target dependent area and
+contain a complete source and binary subdirectory. The detailed description
+below explains the differences between the different libraries in terms of
+their thread support.
 
-      procedure Set_Globals
-        (Main_Priority            : Integer;
-         Time_Slice_Value         : Integer;
-         WC_Encoding              : Character;
-         Locking_Policy           : Character;
-         Queuing_Policy           : Character;
-         Task_Dispatching_Policy  : Character;
-         Adafinal                 : System.Address;
-         Unreserve_All_Interrupts : Integer;
-         Exception_Tracebacks     : Integer);
-@findex __gnat_set_globals
-      pragma Import (C, Set_Globals, "__gnat_set_globals");
+The default run-time library (when GNAT is installed) is @emph{rts-native}.
+This default run time is selected by the means of soft links.
+For example on x86-linux:
 
-      --  SDP_Table_Build is a library routine used to build the
-      --  exception tables. See unit Ada.Exceptions in files
-      --  a-except.ads/adb for full details of how zero cost
-      --  exception handling works. This procedure, the call to
-      --  it, and the two following tables are all omitted if the
-      --  build is in longjmp/setjump exception mode.
+@smallexample
+@group
+ $(target-dir)
+     |
+     +--- adainclude----------+
+     |                        |
+     +--- adalib-----------+  |
+     |                     |  |
+     +--- rts-native       |  |
+     |    |                |  |
+     |    +--- adainclude <---+
+     |    |                |
+     |    +--- adalib <----+
+     |
+     +--- rts-sjlj
+          |
+          +--- adainclude
+          |
+          +--- adalib
+@end group
+@end smallexample
 
-@findex SDP_Table_Build
-@findex Zero Cost Exceptions
-      procedure SDP_Table_Build
-        (SDP_Addresses   : System.Address;
-         SDP_Count       : Natural;
-         Elab_Addresses  : System.Address;
-         Elab_Addr_Count : Natural);
-      pragma Import (C, SDP_Table_Build, "__gnat_SDP_Table_Build");
+@noindent
+If the @i{rts-sjlj} library is to be selected on a permanent basis,
+these soft links can be modified with the following commands:
 
-      --  Table of Unit_Exception_Table addresses. Used for zero
-      --  cost exception handling to build the top level table.
+@smallexample
+$ cd $target
+$ rm -f adainclude adalib
+$ ln -s rts-sjlj/adainclude adainclude
+$ ln -s rts-sjlj/adalib adalib
+@end smallexample
 
-      ST : aliased constant array (1 .. 23) of System.Address := (
-        Hello'UET_Address,
-        Ada.Text_Io'UET_Address,
-        Ada.Exceptions'UET_Address,
-        Gnat.Heap_Sort_A'UET_Address,
-        System.Exception_Table'UET_Address,
-        System.Machine_State_Operations'UET_Address,
-        System.Secondary_Stack'UET_Address,
-        System.Parameters'UET_Address,
-        System.Soft_Links'UET_Address,
-        System.Stack_Checking'UET_Address,
-        System.Traceback'UET_Address,
-        Ada.Streams'UET_Address,
-        Ada.Tags'UET_Address,
-        System.String_Ops'UET_Address,
-        Interfaces.C_Streams'UET_Address,
-        System.File_Io'UET_Address,
-        Ada.Finalization'UET_Address,
-        System.Finalization_Root'UET_Address,
-        System.Finalization_Implementation'UET_Address,
-        System.String_Ops_Concat_3'UET_Address,
-        System.Stream_Attributes'UET_Address,
-        System.File_Control_Block'UET_Address,
-        Ada.Finalization.List_Controller'UET_Address);
+@noindent
+Alternatively, you can specify @file{rts-sjlj/adainclude} in the file
+@file{$target/ada_source_path} and @file{rts-sjlj/adalib} in
+@file{$target/ada_object_path}.
 
-      --  Table of addresses of elaboration routines. Used for
-      --  zero cost exception handling to make sure these
-      --  addresses are included in the top level procedure
-      --  address table.
+Selecting another run-time library temporarily can be
+achieved by using the @option{--RTS} switch, e.g., @option{--RTS=sjlj}
+@cindex @option{--RTS} option
 
-      EA : aliased constant array (1 .. 23) of System.Address := (
-        adainit'Code_Address,
-        Do_Finalize'Code_Address,
-        Ada.Exceptions'Elab_Spec'Address,
-        System.Exceptions'Elab_Spec'Address,
-        Interfaces.C_Streams'Elab_Spec'Address,
-        System.Exception_Table'Elab_Body'Address,
-        Ada.Io_Exceptions'Elab_Spec'Address,
-        System.Stack_Checking'Elab_Spec'Address,
-        System.Soft_Links'Elab_Body'Address,
-        System.Secondary_Stack'Elab_Body'Address,
-        Ada.Tags'Elab_Spec'Address,
-        Ada.Tags'Elab_Body'Address,
-        Ada.Streams'Elab_Spec'Address,
-        System.Finalization_Root'Elab_Spec'Address,
-        Ada.Exceptions'Elab_Body'Address,
-        System.Finalization_Implementation'Elab_Spec'Address,
-        System.Finalization_Implementation'Elab_Body'Address,
-        Ada.Finalization'Elab_Spec'Address,
-        Ada.Finalization.List_Controller'Elab_Spec'Address,
-        System.File_Control_Block'Elab_Spec'Address,
-        System.File_Io'Elab_Body'Address,
-        Ada.Text_Io'Elab_Spec'Address,
-        Ada.Text_Io'Elab_Body'Address);
+@node Choosing the Scheduling Policy
+@section Choosing the Scheduling Policy
 
-   --  Start of processing for adainit
+@noindent
+When using a POSIX threads implementation, you have a choice of several
+scheduling policies: @code{SCHED_FIFO},
+@cindex @code{SCHED_FIFO} scheduling policy
+@code{SCHED_RR}
+@cindex @code{SCHED_RR} scheduling policy
+and @code{SCHED_OTHER}.
+@cindex @code{SCHED_OTHER} scheduling policy
+Typically, the default is @code{SCHED_OTHER}, while using @code{SCHED_FIFO}
+or @code{SCHED_RR} requires special (e.g., root) privileges.
 
-   begin
+By default, GNAT uses the @code{SCHED_OTHER} policy. To specify
+@code{SCHED_FIFO},
+@cindex @code{SCHED_FIFO} scheduling policy
+you can use one of the following:
 
-      --  Call SDP_Table_Build to build the top level procedure
-      --  table for zero cost exception handling (omitted in
-      --  longjmp/setjump mode).
+@itemize @bullet
+@item
+@code{pragma Time_Slice (0.0)}
+@cindex pragma Time_Slice
+@item
+the corresponding binder option @option{-T0}
+@cindex @option{-T0} option
+@item
+@code{pragma Task_Dispatching_Policy (FIFO_Within_Priorities)}
+@cindex pragma Task_Dispatching_Policy
+@end itemize
 
-      SDP_Table_Build (ST'Address, 23, EA'Address, 23);
+@noindent
+To specify @code{SCHED_RR},
+@cindex @code{SCHED_RR} scheduling policy
+you should use @code{pragma Time_Slice} with a
+value greater than @code{0.0}, or else use the corresponding @option{-T}
+binder option.
 
-      --  Call Set_Globals to record various information for
-      --  this partition.  The values are derived by the binder
-      --  from information stored in the ali files by the compiler.
+@node Solaris-Specific Considerations
+@section Solaris-Specific Considerations
+@cindex Solaris Sparc threads libraries
 
-@findex __gnat_set_globals
-      Set_Globals
-        (Main_Priority            => -1,
-         --  Priority of main program, -1 if no pragma Priority used
+@noindent
+This section addresses some topics related to the various threads libraries
+on Sparc Solaris.
 
-         Time_Slice_Value         => -1,
-         --  Time slice from Time_Slice pragma, -1 if none used
+@menu
+* Solaris Threads Issues::
+@end menu
 
-         WC_Encoding              => 'b',
-         --  Wide_Character encoding used, default is brackets
+@node Solaris Threads Issues
+@subsection Solaris Threads Issues
 
-         Locking_Policy           => ' ',
-         --  Locking_Policy used, default of space means not
-         --  specified, otherwise it is the first character of
-         --  the policy name.
+@noindent
+GNAT under Solaris/Sparc 32 bits comes with an alternate tasking run-time
+library based on POSIX threads --- @emph{rts-pthread}.
+@cindex rts-pthread threads library
+This run-time library has the advantage of being mostly shared across all
+POSIX-compliant thread implementations, and it also provides under
+@w{Solaris 8} the @code{PTHREAD_PRIO_INHERIT}
+@cindex @code{PTHREAD_PRIO_INHERIT} policy (under rts-pthread)
+and @code{PTHREAD_PRIO_PROTECT}
+@cindex @code{PTHREAD_PRIO_PROTECT} policy (under rts-pthread)
+semantics that can be selected using the predefined pragma
+@code{Locking_Policy}
+@cindex pragma Locking_Policy (under rts-pthread)
+with respectively
+@code{Inheritance_Locking} and @code{Ceiling_Locking} as the policy.
+@cindex @code{Inheritance_Locking} (under rts-pthread)
+@cindex @code{Ceiling_Locking} (under rts-pthread)
 
-         Queuing_Policy           => ' ',
-         --  Queuing_Policy used, default of space means not
-         --  specified, otherwise it is the first character of
-         --  the policy name.
+As explained above, the native run-time library is based on the Solaris thread
+library (@code{libthread}) and is the default library.
 
-         Task_Dispatching_Policy  => ' ',
-         --  Task_Dispatching_Policy used, default of space means
-         --  not specified, otherwise first character of the
-         --  policy name.
+When the Solaris threads library is used (this is the default), programs
+compiled with GNAT can automatically take advantage of
+and can thus execute on multiple processors.
+The user can alternatively specify a processor on which the program should run
+to emulate a single-processor system. The multiprocessor / uniprocessor choice
+is made by
+setting the environment variable @env{GNAT_PROCESSOR}
+@cindex @env{GNAT_PROCESSOR} environment variable (on Sparc Solaris)
+to one of the following:
 
-         Adafinal                 => System.Null_Address,
-         --  Address of Adafinal routine, not used anymore
+@table @code
+@item -2
+Use the default configuration (run the program on all
+         available processors) - this is the same as having
+         @code{GNAT_PROCESSOR} unset
 
-         Unreserve_All_Interrupts => 0,
-         --  Set true if pragma Unreserve_All_Interrupts was used
+@item -1
+Let the run-time implementation choose one processor and run the program on
+         that processor
 
-         Exception_Tracebacks     => 0);
-         --  Indicates if exception tracebacks are enabled
+@item 0 .. Last_Proc
+Run the program on the specified processor.
+  @code{Last_Proc} is equal to @code{_SC_NPROCESSORS_CONF - 1}
+(where @code{_SC_NPROCESSORS_CONF} is a system variable).
+@end table
 
-      Elab_Final_Code := 1;
+@node Linux-Specific Considerations
+@section Linux-Specific Considerations
+@cindex Linux threads libraries
 
-      --  Now we have the elaboration calls for all units in the partition.
-      --  The Elab_Spec and Elab_Body attributes generate references to the
-      --  implicit elaboration procedures generated by the compiler for
-      --  each unit that requires elaboration.
+@noindent
+On GNU/Linux without NPTL support (usually system with GNU C Library
+older than 2.3), the signal model is not POSIX compliant, which means
+that to send a signal to the process, you need to send the signal to all
+threads, e.g. by using @code{killpg()}.
 
-      if not E040 then
-         Interfaces.C_Streams'Elab_Spec;
-      end if;
-      E040 := True;
-      if not E008 then
-         Ada.Exceptions'Elab_Spec;
-      end if;
-      if not E014 then
-         System.Exception_Table'Elab_Body;
-         E014 := True;
-      end if;
-      if not E053 then
-         Ada.Io_Exceptions'Elab_Spec;
-         E053 := True;
-      end if;
-      if not E017 then
-         System.Exceptions'Elab_Spec;
-         E017 := True;
-      end if;
-      if not E030 then
-         System.Stack_Checking'Elab_Spec;
-      end if;
-      if not E028 then
-         System.Soft_Links'Elab_Body;
-         E028 := True;
-      end if;
-      E030 := True;
-      if not E024 then
-         System.Secondary_Stack'Elab_Body;
-         E024 := True;
-      end if;
-      if not E035 then
-         Ada.Tags'Elab_Spec;
-      end if;
-      if not E035 then
-         Ada.Tags'Elab_Body;
-         E035 := True;
-      end if;
-      if not E033 then
-         Ada.Streams'Elab_Spec;
-         E033 := True;
-      end if;
-      if not E046 then
-         System.Finalization_Root'Elab_Spec;
-      end if;
-      E046 := True;
-      if not E008 then
-         Ada.Exceptions'Elab_Body;
-         E008 := True;
-      end if;
-      if not E048 then
-         System.Finalization_Implementation'Elab_Spec;
-      end if;
-      if not E048 then
-         System.Finalization_Implementation'Elab_Body;
-         E048 := True;
-      end if;
-      if not E044 then
-         Ada.Finalization'Elab_Spec;
-      end if;
-      E044 := True;
-      if not E057 then
-         Ada.Finalization.List_Controller'Elab_Spec;
-      end if;
-      E057 := True;
-      if not E055 then
-         System.File_Control_Block'Elab_Spec;
-         E055 := True;
-      end if;
-      if not E042 then
-         System.File_Io'Elab_Body;
-         E042 := True;
-      end if;
-      if not E006 then
-         Ada.Text_Io'Elab_Spec;
-      end if;
-      if not E006 then
-         Ada.Text_Io'Elab_Body;
-         E006 := True;
-      end if;
+@node AIX-Specific Considerations
+@section AIX-Specific Considerations
+@cindex AIX resolver library
 
-      Elab_Final_Code := 0;
-   end adainit;
+@noindent
+On AIX, the resolver library initializes some internal structure on
+the first call to @code{get*by*} functions, which are used to implement
+@code{GNAT.Sockets.Get_Host_By_Name} and
+@code{GNAT.Sockets.Get_Host_By_Address}.
+If such initialization occurs within an Ada task, and the stack size for
+the task is the default size, a stack overflow may occur.
 
-   --------------
-   -- adafinal --
-   --------------
+To avoid this overflow, the user should either ensure that the first call
+to @code{GNAT.Sockets.Get_Host_By_Name} or
+@code{GNAT.Sockets.Get_Host_By_Addrss}
+occurs in the environment task, or use @code{pragma Storage_Size} to
+specify a sufficiently large size for the stack of the task that contains
+this call.
 
-@findex adafinal
-   procedure adafinal is
-   begin
-      Do_Finalize;
-   end adafinal;
+@c *******************************
+@node Example of Binder Output File
+@appendix Example of Binder Output File
 
-   ----------
-   -- main --
-   ----------
+@noindent
+This Appendix displays the source code for @command{gnatbind}'s output
+file generated for a simple ``Hello World'' program.
+Comments have been added for clarification purposes.
 
-   --  main is actually a function, as in the ANSI C standard,
-   --  defined to return the exit status. The three parameters
-   --  are the argument count, argument values and environment
-   --  pointer.
+@smallexample @c adanocomment
+@iftex
+@leftskip=0cm
+@end iftex
+--  The package is called Ada_Main unless this name is actually used
+--  as a unit name in the partition, in which case some other unique
+--  name is used.
 
-@findex Main Program
-   function main
-     (argc : Integer;
-      argv : System.Address;
-      envp : System.Address)
-      return Integer
-   is
-      --  The initialize routine performs low level system
-      --  initialization using a standard library routine which
-      --  sets up signal handling and performs any other
-      --  required setup. The routine can be found in file
-      --  a-init.c.
+with System;
+package ada_main is
 
-@findex __gnat_initialize
-      procedure initialize;
-      pragma Import (C, initialize, "__gnat_initialize");
+   Elab_Final_Code : Integer;
+   pragma Import (C, Elab_Final_Code, "__gnat_inside_elab_final_code");
 
-      --  The finalize routine performs low level system
-      --  finalization using a standard library routine. The
-      --  routine is found in file a-final.c and in the standard
-      --  distribution is a dummy routine that does nothing, so
-      --  really this is a hook for special user finalization.
+   --  The main program saves the parameters (argument count,
+   --  argument values, environment pointer) in global variables
+   --  for later access by other units including
+   --  Ada.Command_Line.
 
-@findex __gnat_finalize
-      procedure finalize;
-      pragma Import (C, finalize, "__gnat_finalize");
+   gnat_argc : Integer;
+   gnat_argv : System.Address;
+   gnat_envp : System.Address;
 
-      --  We get to the main program of the partition by using
-      --  pragma Import because if we try to with the unit and
-      --  call it Ada style, then not only do we waste time
-      --  recompiling it, but also, we don't really know the right
-      --  switches (e.g. identifier character set) to be used
-      --  to compile it.
+   --  The actual variables are stored in a library routine. This
+   --  is useful for some shared library situations, where there
+   --  are problems if variables are not in the library.
 
-      procedure Ada_Main_Program;
-      pragma Import (Ada, Ada_Main_Program, "_ada_hello");
+   pragma Import (C, gnat_argc);
+   pragma Import (C, gnat_argv);
+   pragma Import (C, gnat_envp);
 
-   --  Start of processing for main
+   --  The exit status is similarly an external location
 
-   begin
-      --  Save global variables
+   gnat_exit_status : Integer;
+   pragma Import (C, gnat_exit_status);
 
-      gnat_argc := argc;
-      gnat_argv := argv;
-      gnat_envp := envp;
+   GNAT_Version : constant String :=
+                    "GNAT Version: 6.0.0w (20061115)";
+   pragma Export (C, GNAT_Version, "__gnat_version");
 
-      --  Call low level system initialization
+   --  This is the generated adafinal routine that performs
+   --  finalization at the end of execution. In the case where
+   --  Ada is the main program, this main program makes a call
+   --  to adafinal at program termination.
 
-      Initialize;
+   procedure adafinal;
+   pragma Export (C, adafinal, "adafinal");
 
-      --  Call our generated Ada initialization routine
+   --  This is the generated adainit routine that performs
+   --  initialization at the start of execution. In the case
+   --  where Ada is the main program, this main program makes
+   --  a call to adainit at program startup.
 
-      adainit;
+   procedure adainit;
+   pragma Export (C, adainit, "adainit");
 
-      --  This is the point at which we want the debugger to get
-      --  control
+   --  This routine is called at the start of execution. It is
+   --  a dummy routine that is used by the debugger to breakpoint
+   --  at the start of execution.
 
-      Break_Start;
+   procedure Break_Start;
+   pragma Import (C, Break_Start, "__gnat_break_start");
 
-      --  Now we call the main program of the partition
+   --  This is the actual generated main program (it would be
+   --  suppressed if the no main program switch were used). As
+   --  required by standard system conventions, this program has
+   --  the external name main.
 
-      Ada_Main_Program;
+   function main
+     (argc : Integer;
+      argv : System.Address;
+      envp : System.Address)
+      return Integer;
+   pragma Export (C, main, "main");
 
-      --  Perform Ada finalization
+   --  The following set of constants give the version
+   --  identification values for every unit in the bound
+   --  partition. This identification is computed from all
+   --  dependent semantic units, and corresponds to the
+   --  string that would be returned by use of the
+   --  Body_Version or Version attributes.
 
-      adafinal;
+   type Version_32 is mod 2 ** 32;
+   u00001 : constant Version_32 := 16#7880BEB3#;
+   u00002 : constant Version_32 := 16#0D24CBD0#;
+   u00003 : constant Version_32 := 16#3283DBEB#;
+   u00004 : constant Version_32 := 16#2359F9ED#;
+   u00005 : constant Version_32 := 16#664FB847#;
+   u00006 : constant Version_32 := 16#68E803DF#;
+   u00007 : constant Version_32 := 16#5572E604#;
+   u00008 : constant Version_32 := 16#46B173D8#;
+   u00009 : constant Version_32 := 16#156A40CF#;
+   u00010 : constant Version_32 := 16#033DABE0#;
+   u00011 : constant Version_32 := 16#6AB38FEA#;
+   u00012 : constant Version_32 := 16#22B6217D#;
+   u00013 : constant Version_32 := 16#68A22947#;
+   u00014 : constant Version_32 := 16#18CC4A56#;
+   u00015 : constant Version_32 := 16#08258E1B#;
+   u00016 : constant Version_32 := 16#367D5222#;
+   u00017 : constant Version_32 := 16#20C9ECA4#;
+   u00018 : constant Version_32 := 16#50D32CB6#;
+   u00019 : constant Version_32 := 16#39A8BB77#;
+   u00020 : constant Version_32 := 16#5CF8FA2B#;
+   u00021 : constant Version_32 := 16#2F1EB794#;
+   u00022 : constant Version_32 := 16#31AB6444#;
+   u00023 : constant Version_32 := 16#1574B6E9#;
+   u00024 : constant Version_32 := 16#5109C189#;
+   u00025 : constant Version_32 := 16#56D770CD#;
+   u00026 : constant Version_32 := 16#02F9DE3D#;
+   u00027 : constant Version_32 := 16#08AB6B2C#;
+   u00028 : constant Version_32 := 16#3FA37670#;
+   u00029 : constant Version_32 := 16#476457A0#;
+   u00030 : constant Version_32 := 16#731E1B6E#;
+   u00031 : constant Version_32 := 16#23C2E789#;
+   u00032 : constant Version_32 := 16#0F1BD6A1#;
+   u00033 : constant Version_32 := 16#7C25DE96#;
+   u00034 : constant Version_32 := 16#39ADFFA2#;
+   u00035 : constant Version_32 := 16#571DE3E7#;
+   u00036 : constant Version_32 := 16#5EB646AB#;
+   u00037 : constant Version_32 := 16#4249379B#;
+   u00038 : constant Version_32 := 16#0357E00A#;
+   u00039 : constant Version_32 := 16#3784FB72#;
+   u00040 : constant Version_32 := 16#2E723019#;
+   u00041 : constant Version_32 := 16#623358EA#;
+   u00042 : constant Version_32 := 16#107F9465#;
+   u00043 : constant Version_32 := 16#6843F68A#;
+   u00044 : constant Version_32 := 16#63305874#;
+   u00045 : constant Version_32 := 16#31E56CE1#;
+   u00046 : constant Version_32 := 16#02917970#;
+   u00047 : constant Version_32 := 16#6CCBA70E#;
+   u00048 : constant Version_32 := 16#41CD4204#;
+   u00049 : constant Version_32 := 16#572E3F58#;
+   u00050 : constant Version_32 := 16#20729FF5#;
+   u00051 : constant Version_32 := 16#1D4F93E8#;
+   u00052 : constant Version_32 := 16#30B2EC3D#;
+   u00053 : constant Version_32 := 16#34054F96#;
+   u00054 : constant Version_32 := 16#5A199860#;
+   u00055 : constant Version_32 := 16#0E7F912B#;
+   u00056 : constant Version_32 := 16#5760634A#;
+   u00057 : constant Version_32 := 16#5D851835#;
 
-      --  Perform low level system finalization
+   --  The following Export pragmas export the version numbers
+   --  with symbolic names ending in B (for body) or S
+   --  (for spec) so that they can be located in a link. The
+   --  information provided here is sufficient to track down
+   --  the exact versions of units used in a given build.
 
-      Finalize;
+   pragma Export (C, u00001, "helloB");
+   pragma Export (C, u00002, "system__standard_libraryB");
+   pragma Export (C, u00003, "system__standard_libraryS");
+   pragma Export (C, u00004, "adaS");
+   pragma Export (C, u00005, "ada__text_ioB");
+   pragma Export (C, u00006, "ada__text_ioS");
+   pragma Export (C, u00007, "ada__exceptionsB");
+   pragma Export (C, u00008, "ada__exceptionsS");
+   pragma Export (C, u00009, "gnatS");
+   pragma Export (C, u00010, "gnat__heap_sort_aB");
+   pragma Export (C, u00011, "gnat__heap_sort_aS");
+   pragma Export (C, u00012, "systemS");
+   pragma Export (C, u00013, "system__exception_tableB");
+   pragma Export (C, u00014, "system__exception_tableS");
+   pragma Export (C, u00015, "gnat__htableB");
+   pragma Export (C, u00016, "gnat__htableS");
+   pragma Export (C, u00017, "system__exceptionsS");
+   pragma Export (C, u00018, "system__machine_state_operationsB");
+   pragma Export (C, u00019, "system__machine_state_operationsS");
+   pragma Export (C, u00020, "system__machine_codeS");
+   pragma Export (C, u00021, "system__storage_elementsB");
+   pragma Export (C, u00022, "system__storage_elementsS");
+   pragma Export (C, u00023, "system__secondary_stackB");
+   pragma Export (C, u00024, "system__secondary_stackS");
+   pragma Export (C, u00025, "system__parametersB");
+   pragma Export (C, u00026, "system__parametersS");
+   pragma Export (C, u00027, "system__soft_linksB");
+   pragma Export (C, u00028, "system__soft_linksS");
+   pragma Export (C, u00029, "system__stack_checkingB");
+   pragma Export (C, u00030, "system__stack_checkingS");
+   pragma Export (C, u00031, "system__tracebackB");
+   pragma Export (C, u00032, "system__tracebackS");
+   pragma Export (C, u00033, "ada__streamsS");
+   pragma Export (C, u00034, "ada__tagsB");
+   pragma Export (C, u00035, "ada__tagsS");
+   pragma Export (C, u00036, "system__string_opsB");
+   pragma Export (C, u00037, "system__string_opsS");
+   pragma Export (C, u00038, "interfacesS");
+   pragma Export (C, u00039, "interfaces__c_streamsB");
+   pragma Export (C, u00040, "interfaces__c_streamsS");
+   pragma Export (C, u00041, "system__file_ioB");
+   pragma Export (C, u00042, "system__file_ioS");
+   pragma Export (C, u00043, "ada__finalizationB");
+   pragma Export (C, u00044, "ada__finalizationS");
+   pragma Export (C, u00045, "system__finalization_rootB");
+   pragma Export (C, u00046, "system__finalization_rootS");
+   pragma Export (C, u00047, "system__finalization_implementationB");
+   pragma Export (C, u00048, "system__finalization_implementationS");
+   pragma Export (C, u00049, "system__string_ops_concat_3B");
+   pragma Export (C, u00050, "system__string_ops_concat_3S");
+   pragma Export (C, u00051, "system__stream_attributesB");
+   pragma Export (C, u00052, "system__stream_attributesS");
+   pragma Export (C, u00053, "ada__io_exceptionsS");
+   pragma Export (C, u00054, "system__unsigned_typesS");
+   pragma Export (C, u00055, "system__file_control_blockS");
+   pragma Export (C, u00056, "ada__finalization__list_controllerB");
+   pragma Export (C, u00057, "ada__finalization__list_controllerS");
 
-      --  Return the proper exit status
-      return (gnat_exit_status);
-   end;
+   -- BEGIN ELABORATION ORDER
+   -- ada (spec)
+   -- gnat (spec)
+   -- gnat.heap_sort_a (spec)
+   -- gnat.heap_sort_a (body)
+   -- gnat.htable (spec)
+   -- gnat.htable (body)
+   -- interfaces (spec)
+   -- system (spec)
+   -- system.machine_code (spec)
+   -- system.parameters (spec)
+   -- system.parameters (body)
+   -- interfaces.c_streams (spec)
+   -- interfaces.c_streams (body)
+   -- system.standard_library (spec)
+   -- ada.exceptions (spec)
+   -- system.exception_table (spec)
+   -- system.exception_table (body)
+   -- ada.io_exceptions (spec)
+   -- system.exceptions (spec)
+   -- system.storage_elements (spec)
+   -- system.storage_elements (body)
+   -- system.machine_state_operations (spec)
+   -- system.machine_state_operations (body)
+   -- system.secondary_stack (spec)
+   -- system.stack_checking (spec)
+   -- system.soft_links (spec)
+   -- system.soft_links (body)
+   -- system.stack_checking (body)
+   -- system.secondary_stack (body)
+   -- system.standard_library (body)
+   -- system.string_ops (spec)
+   -- system.string_ops (body)
+   -- ada.tags (spec)
+   -- ada.tags (body)
+   -- ada.streams (spec)
+   -- system.finalization_root (spec)
+   -- system.finalization_root (body)
+   -- system.string_ops_concat_3 (spec)
+   -- system.string_ops_concat_3 (body)
+   -- system.traceback (spec)
+   -- system.traceback (body)
+   -- ada.exceptions (body)
+   -- system.unsigned_types (spec)
+   -- system.stream_attributes (spec)
+   -- system.stream_attributes (body)
+   -- system.finalization_implementation (spec)
+   -- system.finalization_implementation (body)
+   -- ada.finalization (spec)
+   -- ada.finalization (body)
+   -- ada.finalization.list_controller (spec)
+   -- ada.finalization.list_controller (body)
+   -- system.file_control_block (spec)
+   -- system.file_io (spec)
+   -- system.file_io (body)
+   -- ada.text_io (spec)
+   -- ada.text_io (body)
+   -- hello (body)
+   -- END ELABORATION ORDER
 
---  This section is entirely comments, so it has no effect on the
---  compilation of the Ada_Main package. It provides the list of
---  object files and linker options, as well as some standard
---  libraries needed for the link. The gnatlink utility parses
---  this b~hello.adb file to read these comment lines to generate
---  the appropriate command line arguments for the call to the
---  system linker. The BEGIN/END lines are used for sentinels for
---  this parsing operation.
+end ada_main;
 
---  The exact file names will of course depend on the environment,
---  host/target and location of files on the host system.
+--  The following source file name pragmas allow the generated file
+--  names to be unique for different main programs. They are needed
+--  since the package name will always be Ada_Main.
 
-@findex Object file list
--- BEGIN Object file/option list
-   --   ./hello.o
-   --   -L./
-   --   -L/usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/
-   --   /usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/libgnat.a
--- END Object file/option list
+pragma Source_File_Name (ada_main, Spec_File_Name => "b~hello.ads");
+pragma Source_File_Name (ada_main, Body_File_Name => "b~hello.adb");
 
-end ada_main;
-@end smallexample
+--  Generated package body for Ada_Main starts here
 
-@noindent
-The Ada code in the above example is exactly what is generated by the
-binder. We have added comments to more clearly indicate the function
-of each part of the generated @code{Ada_Main} package.
+package body ada_main is
 
-The code is standard Ada in all respects, and can be processed by any
-tools that handle Ada. In particular, it is possible to use the debugger
-in Ada mode to debug the generated @code{Ada_Main} package. For example,
-suppose that for reasons that you do not understand, your program is crashing
-during elaboration of the body of @code{Ada.Text_IO}. To locate this bug,
-you can place a breakpoint on the call:
+   --  The actual finalization is performed by calling the
+   --  library routine in System.Standard_Library.Adafinal
 
-@smallexample @c ada
-Ada.Text_Io'Elab_Body;
-@end smallexample
+   procedure Do_Finalize;
+   pragma Import (C, Do_Finalize, "system__standard_library__adafinal");
 
-@noindent
-and trace the elaboration routine for this package to find out where
-the problem might be (more usually of course you would be debugging
-elaboration code in your own application).
+   -------------
+   -- adainit --
+   -------------
 
+@findex adainit
+   procedure adainit is
 
-@node Elaboration Order Handling in GNAT
-@appendix Elaboration Order Handling in GNAT
-@cindex Order of elaboration
-@cindex Elaboration control
+      --  These booleans are set to True once the associated unit has
+      --  been elaborated. It is also used to avoid elaborating the
+      --  same unit twice.
 
-@menu
-* Elaboration Code in Ada 95::
-* Checking the Elaboration Order in Ada 95::
-* Controlling the Elaboration Order in Ada 95::
-* Controlling Elaboration in GNAT - Internal Calls::
-* Controlling Elaboration in GNAT - External Calls::
-* Default Behavior in GNAT - Ensuring Safety::
-* Treatment of Pragma Elaborate::
-* Elaboration Issues for Library Tasks::
-* Mixing Elaboration Models::
-* What to Do If the Default Elaboration Behavior Fails::
-* Elaboration for Access-to-Subprogram Values::
-* Summary of Procedures for Elaboration Control::
-* Other Elaboration Order Considerations::
-@end menu
+      E040 : Boolean;
+      pragma Import (Ada, E040, "interfaces__c_streams_E");
 
-@noindent
-This chapter describes the handling of elaboration code in Ada 95 and
-in GNAT, and discusses how the order of elaboration of program units can
-be controlled in GNAT, either automatically or with explicit programming
-features.
+      E008 : Boolean;
+      pragma Import (Ada, E008, "ada__exceptions_E");
 
-@node Elaboration Code in Ada 95
-@section Elaboration Code in Ada 95
+      E014 : Boolean;
+      pragma Import (Ada, E014, "system__exception_table_E");
 
-@noindent
-Ada 95 provides rather general mechanisms for executing code at elaboration
-time, that is to say before the main program starts executing. Such code arises
-in three contexts:
+      E053 : Boolean;
+      pragma Import (Ada, E053, "ada__io_exceptions_E");
 
-@table @asis
-@item Initializers for variables.
-Variables declared at the library level, in package specs or bodies, can
-require initialization that is performed at elaboration time, as in:
-@smallexample @c ada
-@cartouche
-Sqrt_Half : Float := Sqrt (0.5);
-@end cartouche
-@end smallexample
+      E017 : Boolean;
+      pragma Import (Ada, E017, "system__exceptions_E");
 
-@item Package initialization code
-Code in a @code{BEGIN-END} section at the outer level of a package body is
-executed as part of the package body elaboration code.
+      E024 : Boolean;
+      pragma Import (Ada, E024, "system__secondary_stack_E");
 
-@item Library level task allocators
-Tasks that are declared using task allocators at the library level
-start executing immediately and hence can execute at elaboration time.
-@end table
+      E030 : Boolean;
+      pragma Import (Ada, E030, "system__stack_checking_E");
 
-@noindent
-Subprogram calls are possible in any of these contexts, which means that
-any arbitrary part of the program may be executed as part of the elaboration
-code. It is even possible to write a program which does all its work at
-elaboration time, with a null main program, although stylistically this
-would usually be considered an inappropriate way to structure
-a program.
+      E028 : Boolean;
+      pragma Import (Ada, E028, "system__soft_links_E");
 
-An important concern arises in the context of elaboration code:
-we have to be sure that it is executed in an appropriate order. What we
-have is a series of elaboration code sections, potentially one section
-for each unit in the program. It is important that these execute
-in the correct order. Correctness here means that, taking the above
-example of the declaration of @code{Sqrt_Half},
-if some other piece of
-elaboration code references @code{Sqrt_Half},
-then it must run after the
-section of elaboration code that contains the declaration of
-@code{Sqrt_Half}.
+      E035 : Boolean;
+      pragma Import (Ada, E035, "ada__tags_E");
 
-There would never be any order of elaboration problem if we made a rule
-that whenever you @code{with} a unit, you must elaborate both the spec and body
-of that unit before elaborating the unit doing the @code{with}'ing:
+      E033 : Boolean;
+      pragma Import (Ada, E033, "ada__streams_E");
 
-@smallexample @c ada
-@group
-@cartouche
-with Unit_1;
-package Unit_2 is ...
-@end cartouche
-@end group
-@end smallexample
+      E046 : Boolean;
+      pragma Import (Ada, E046, "system__finalization_root_E");
 
-@noindent
-would require that both the body and spec of @code{Unit_1} be elaborated
-before the spec of @code{Unit_2}. However, a rule like that would be far too
-restrictive. In particular, it would make it impossible to have routines
-in separate packages that were mutually recursive.
+      E048 : Boolean;
+      pragma Import (Ada, E048, "system__finalization_implementation_E");
 
-You might think that a clever enough compiler could look at the actual
-elaboration code and determine an appropriate correct order of elaboration,
-but in the general case, this is not possible. Consider the following
-example.
+      E044 : Boolean;
+      pragma Import (Ada, E044, "ada__finalization_E");
 
-In the body of @code{Unit_1}, we have a procedure @code{Func_1}
-that references
-the variable @code{Sqrt_1}, which is declared in the elaboration code
-of the body of @code{Unit_1}:
+      E057 : Boolean;
+      pragma Import (Ada, E057, "ada__finalization__list_controller_E");
 
-@smallexample @c ada
-@cartouche
-Sqrt_1 : Float := Sqrt (0.1);
-@end cartouche
-@end smallexample
+      E055 : Boolean;
+      pragma Import (Ada, E055, "system__file_control_block_E");
 
-@noindent
-The elaboration code of the body of @code{Unit_1} also contains:
+      E042 : Boolean;
+      pragma Import (Ada, E042, "system__file_io_E");
 
-@smallexample @c ada
-@group
-@cartouche
-if expression_1 = 1 then
-   Q := Unit_2.Func_2;
-end if;
-@end cartouche
-@end group
-@end smallexample
+      E006 : Boolean;
+      pragma Import (Ada, E006, "ada__text_io_E");
 
-@noindent
-@code{Unit_2} is exactly parallel,
-it has a procedure @code{Func_2} that references
-the variable @code{Sqrt_2}, which is declared in the elaboration code of
-the body @code{Unit_2}:
+      --  Set_Globals is a library routine that stores away the
+      --  value of the indicated set of global values in global
+      --  variables within the library.
 
-@smallexample @c ada
-@cartouche
-Sqrt_2 : Float := Sqrt (0.1);
-@end cartouche
-@end smallexample
+      procedure Set_Globals
+        (Main_Priority            : Integer;
+         Time_Slice_Value         : Integer;
+         WC_Encoding              : Character;
+         Locking_Policy           : Character;
+         Queuing_Policy           : Character;
+         Task_Dispatching_Policy  : Character;
+         Adafinal                 : System.Address;
+         Unreserve_All_Interrupts : Integer;
+         Exception_Tracebacks     : Integer);
+@findex __gnat_set_globals
+      pragma Import (C, Set_Globals, "__gnat_set_globals");
 
-@noindent
-The elaboration code of the body of @code{Unit_2} also contains:
+      --  SDP_Table_Build is a library routine used to build the
+      --  exception tables. See unit Ada.Exceptions in files
+      --  a-except.ads/adb for full details of how zero cost
+      --  exception handling works. This procedure, the call to
+      --  it, and the two following tables are all omitted if the
+      --  build is in longjmp/setjump exception mode.
 
-@smallexample @c ada
-@group
-@cartouche
-if expression_2 = 2 then
-   Q := Unit_1.Func_1;
-end if;
-@end cartouche
-@end group
-@end smallexample
+@findex SDP_Table_Build
+@findex Zero Cost Exceptions
+      procedure SDP_Table_Build
+        (SDP_Addresses   : System.Address;
+         SDP_Count       : Natural;
+         Elab_Addresses  : System.Address;
+         Elab_Addr_Count : Natural);
+      pragma Import (C, SDP_Table_Build, "__gnat_SDP_Table_Build");
 
-@noindent
-Now the question is, which of the following orders of elaboration is
-acceptable:
+      --  Table of Unit_Exception_Table addresses. Used for zero
+      --  cost exception handling to build the top level table.
 
-@smallexample
-@group
-Spec of Unit_1
-Spec of Unit_2
-Body of Unit_1
-Body of Unit_2
-@end group
-@end smallexample
+      ST : aliased constant array (1 .. 23) of System.Address := (
+        Hello'UET_Address,
+        Ada.Text_Io'UET_Address,
+        Ada.Exceptions'UET_Address,
+        Gnat.Heap_Sort_A'UET_Address,
+        System.Exception_Table'UET_Address,
+        System.Machine_State_Operations'UET_Address,
+        System.Secondary_Stack'UET_Address,
+        System.Parameters'UET_Address,
+        System.Soft_Links'UET_Address,
+        System.Stack_Checking'UET_Address,
+        System.Traceback'UET_Address,
+        Ada.Streams'UET_Address,
+        Ada.Tags'UET_Address,
+        System.String_Ops'UET_Address,
+        Interfaces.C_Streams'UET_Address,
+        System.File_Io'UET_Address,
+        Ada.Finalization'UET_Address,
+        System.Finalization_Root'UET_Address,
+        System.Finalization_Implementation'UET_Address,
+        System.String_Ops_Concat_3'UET_Address,
+        System.Stream_Attributes'UET_Address,
+        System.File_Control_Block'UET_Address,
+        Ada.Finalization.List_Controller'UET_Address);
 
-@noindent
-or
+      --  Table of addresses of elaboration routines. Used for
+      --  zero cost exception handling to make sure these
+      --  addresses are included in the top level procedure
+      --  address table.
 
-@smallexample
-@group
-Spec of Unit_2
-Spec of Unit_1
-Body of Unit_2
-Body of Unit_1
-@end group
-@end smallexample
+      EA : aliased constant array (1 .. 23) of System.Address := (
+        adainit'Code_Address,
+        Do_Finalize'Code_Address,
+        Ada.Exceptions'Elab_Spec'Address,
+        System.Exceptions'Elab_Spec'Address,
+        Interfaces.C_Streams'Elab_Spec'Address,
+        System.Exception_Table'Elab_Body'Address,
+        Ada.Io_Exceptions'Elab_Spec'Address,
+        System.Stack_Checking'Elab_Spec'Address,
+        System.Soft_Links'Elab_Body'Address,
+        System.Secondary_Stack'Elab_Body'Address,
+        Ada.Tags'Elab_Spec'Address,
+        Ada.Tags'Elab_Body'Address,
+        Ada.Streams'Elab_Spec'Address,
+        System.Finalization_Root'Elab_Spec'Address,
+        Ada.Exceptions'Elab_Body'Address,
+        System.Finalization_Implementation'Elab_Spec'Address,
+        System.Finalization_Implementation'Elab_Body'Address,
+        Ada.Finalization'Elab_Spec'Address,
+        Ada.Finalization.List_Controller'Elab_Spec'Address,
+        System.File_Control_Block'Elab_Spec'Address,
+        System.File_Io'Elab_Body'Address,
+        Ada.Text_Io'Elab_Spec'Address,
+        Ada.Text_Io'Elab_Body'Address);
 
-@noindent
-If you carefully analyze the flow here, you will see that you cannot tell
-at compile time the answer to this question.
-If @code{expression_1} is not equal to 1,
-and @code{expression_2} is not equal to 2,
-then either order is acceptable, because neither of the function calls is
-executed. If both tests evaluate to true, then neither order is acceptable
-and in fact there is no correct order.
+   --  Start of processing for adainit
 
-If one of the two expressions is true, and the other is false, then one
-of the above orders is correct, and the other is incorrect. For example,
-if @code{expression_1} = 1 and @code{expression_2} /= 2,
-then the call to @code{Func_2}
-will occur, but not the call to @code{Func_1.}
-This means that it is essential
-to elaborate the body of @code{Unit_1} before
-the body of @code{Unit_2}, so the first
-order of elaboration is correct and the second is wrong.
+   begin
 
-By making @code{expression_1} and @code{expression_2}
-depend on input data, or perhaps
-the time of day, we can make it impossible for the compiler or binder
-to figure out which of these expressions will be true, and hence it
-is impossible to guarantee a safe order of elaboration at run time.
+      --  Call SDP_Table_Build to build the top level procedure
+      --  table for zero cost exception handling (omitted in
+      --  longjmp/setjump mode).
 
-@node Checking the Elaboration Order in Ada 95
-@section Checking the Elaboration Order in Ada 95
+      SDP_Table_Build (ST'Address, 23, EA'Address, 23);
 
-@noindent
-In some languages that involve the same kind of elaboration problems,
-e.g. Java and C++, the programmer is expected to worry about these
-ordering problems himself, and it is common to
-write a program in which an incorrect elaboration order  gives
-surprising results, because it references variables before they
-are initialized.
-Ada 95 is designed to be a safe language, and a programmer-beware approach is
-clearly not sufficient. Consequently, the language provides three lines
-of defense:
+      --  Call Set_Globals to record various information for
+      --  this partition.  The values are derived by the binder
+      --  from information stored in the ali files by the compiler.
 
-@table @asis
-@item Standard rules
-Some standard rules restrict the possible choice of elaboration
-order. In particular, if you @code{with} a unit, then its spec is always
-elaborated before the unit doing the @code{with}. Similarly, a parent
-spec is always elaborated before the child spec, and finally
-a spec is always elaborated before its corresponding body.
+@findex __gnat_set_globals
+      Set_Globals
+        (Main_Priority            => -1,
+         --  Priority of main program, -1 if no pragma Priority used
 
-@item Dynamic elaboration checks
-@cindex Elaboration checks
-@cindex Checks, elaboration
-Dynamic checks are made at run time, so that if some entity is accessed
-before it is elaborated (typically  by means of a subprogram call)
-then the exception (@code{Program_Error}) is raised.
+         Time_Slice_Value         => -1,
+         --  Time slice from Time_Slice pragma, -1 if none used
 
-@item Elaboration control
-Facilities are provided for the programmer to specify the desired order
-of elaboration.
-@end table
+         WC_Encoding              => 'b',
+         --  Wide_Character encoding used, default is brackets
 
-Let's look at these facilities in more detail. First, the rules for
-dynamic checking. One possible rule would be simply to say that the
-exception is raised if you access a variable which has not yet been
-elaborated. The trouble with this approach is that it could require
-expensive checks on every variable reference. Instead Ada 95 has two
-rules which are a little more restrictive, but easier to check, and
-easier to state:
+         Locking_Policy           => ' ',
+         --  Locking_Policy used, default of space means not
+         --  specified, otherwise it is the first character of
+         --  the policy name.
 
-@table @asis
-@item Restrictions on calls
-A subprogram can only be called at elaboration time if its body
-has been elaborated. The rules for elaboration given above guarantee
-that the spec of the subprogram has been elaborated before the
-call, but not the body. If this rule is violated, then the
-exception @code{Program_Error} is raised.
+         Queuing_Policy           => ' ',
+         --  Queuing_Policy used, default of space means not
+         --  specified, otherwise it is the first character of
+         --  the policy name.
 
-@item Restrictions on instantiations
-A generic unit can only be instantiated if the body of the generic
-unit has been elaborated. Again, the rules for elaboration given above
-guarantee that the spec of the generic unit has been elaborated
-before the instantiation, but not the body. If this rule is
-violated, then the exception @code{Program_Error} is raised.
-@end table
+         Task_Dispatching_Policy  => ' ',
+         --  Task_Dispatching_Policy used, default of space means
+         --  not specified, otherwise first character of the
+         --  policy name.
 
-@noindent
-The idea is that if the body has been elaborated, then any variables
-it references must have been elaborated; by checking for the body being
-elaborated we guarantee that none of its references causes any
-trouble. As we noted above, this is a little too restrictive, because a
-subprogram that has no non-local references in its body may in fact be safe
-to call. However, it really would be unsafe to rely on this, because
-it would mean that the caller was aware of details of the implementation
-in the body. This goes against the basic tenets of Ada.
+         Adafinal                 => System.Null_Address,
+         --  Address of Adafinal routine, not used anymore
 
-A plausible implementation can be described as follows.
-A Boolean variable is associated with each subprogram
-and each generic unit. This variable is initialized to False, and is set to
-True at the point body is elaborated. Every call or instantiation checks the
-variable, and raises @code{Program_Error} if the variable is False.
+         Unreserve_All_Interrupts => 0,
+         --  Set true if pragma Unreserve_All_Interrupts was used
 
-Note that one might think that it would be good enough to have one Boolean
-variable for each package, but that would not deal with cases of trying
-to call a body in the same package as the call
-that has not been elaborated yet.
-Of course a compiler may be able to do enough analysis to optimize away
-some of the Boolean variables as unnecessary, and @code{GNAT} indeed
-does such optimizations, but still the easiest conceptual model is to
-think of there being one variable per subprogram.
+         Exception_Tracebacks     => 0);
+         --  Indicates if exception tracebacks are enabled
 
-@node Controlling the Elaboration Order in Ada 95
-@section Controlling the Elaboration Order in Ada 95
+      Elab_Final_Code := 1;
 
-@noindent
-In the previous section we discussed the rules in Ada 95 which ensure
-that @code{Program_Error} is raised if an incorrect elaboration order is
-chosen. This prevents erroneous executions, but we need mechanisms to
-specify a correct execution and avoid the exception altogether.
-To achieve this, Ada 95 provides a number of features for controlling
-the order of elaboration. We discuss these features in this section.
+      --  Now we have the elaboration calls for all units in the partition.
+      --  The Elab_Spec and Elab_Body attributes generate references to the
+      --  implicit elaboration procedures generated by the compiler for
+      --  each unit that requires elaboration.
 
-First, there are several ways of indicating to the compiler that a given
-unit has no elaboration problems:
+      if not E040 then
+         Interfaces.C_Streams'Elab_Spec;
+      end if;
+      E040 := True;
+      if not E008 then
+         Ada.Exceptions'Elab_Spec;
+      end if;
+      if not E014 then
+         System.Exception_Table'Elab_Body;
+         E014 := True;
+      end if;
+      if not E053 then
+         Ada.Io_Exceptions'Elab_Spec;
+         E053 := True;
+      end if;
+      if not E017 then
+         System.Exceptions'Elab_Spec;
+         E017 := True;
+      end if;
+      if not E030 then
+         System.Stack_Checking'Elab_Spec;
+      end if;
+      if not E028 then
+         System.Soft_Links'Elab_Body;
+         E028 := True;
+      end if;
+      E030 := True;
+      if not E024 then
+         System.Secondary_Stack'Elab_Body;
+         E024 := True;
+      end if;
+      if not E035 then
+         Ada.Tags'Elab_Spec;
+      end if;
+      if not E035 then
+         Ada.Tags'Elab_Body;
+         E035 := True;
+      end if;
+      if not E033 then
+         Ada.Streams'Elab_Spec;
+         E033 := True;
+      end if;
+      if not E046 then
+         System.Finalization_Root'Elab_Spec;
+      end if;
+      E046 := True;
+      if not E008 then
+         Ada.Exceptions'Elab_Body;
+         E008 := True;
+      end if;
+      if not E048 then
+         System.Finalization_Implementation'Elab_Spec;
+      end if;
+      if not E048 then
+         System.Finalization_Implementation'Elab_Body;
+         E048 := True;
+      end if;
+      if not E044 then
+         Ada.Finalization'Elab_Spec;
+      end if;
+      E044 := True;
+      if not E057 then
+         Ada.Finalization.List_Controller'Elab_Spec;
+      end if;
+      E057 := True;
+      if not E055 then
+         System.File_Control_Block'Elab_Spec;
+         E055 := True;
+      end if;
+      if not E042 then
+         System.File_Io'Elab_Body;
+         E042 := True;
+      end if;
+      if not E006 then
+         Ada.Text_Io'Elab_Spec;
+      end if;
+      if not E006 then
+         Ada.Text_Io'Elab_Body;
+         E006 := True;
+      end if;
 
-@table @asis
-@item packages that do not require a body
-In Ada 95, a library package that does not require a body does not permit
-a body. This means that if we have a such a package, as in:
+      Elab_Final_Code := 0;
+   end adainit;
 
-@smallexample @c ada
-@group
-@cartouche
-package Definitions is
-   generic
-      type m is new integer;
-   package Subp is
-      type a is array (1 .. 10) of m;
-      type b is array (1 .. 20) of m;
-   end Subp;
-end Definitions;
-@end cartouche
-@end group
-@end smallexample
+   --------------
+   -- adafinal --
+   --------------
 
-@noindent
-A package that @code{with}'s @code{Definitions} may safely instantiate
-@code{Definitions.Subp} because the compiler can determine that there
-definitely is no package body to worry about in this case
+@findex adafinal
+   procedure adafinal is
+   begin
+      Do_Finalize;
+   end adafinal;
 
-@item pragma Pure
-@cindex pragma Pure
-@findex Pure
-Places sufficient restrictions on a unit to guarantee that
-no call to any subprogram in the unit can result in an
-elaboration problem. This means that the compiler does not need
-to worry about the point of elaboration of such units, and in
-particular, does not need to check any calls to any subprograms
-in this unit.
+   ----------
+   -- main --
+   ----------
 
-@item pragma Preelaborate
-@findex Preelaborate
-@cindex pragma Preelaborate
-This pragma places slightly less stringent restrictions on a unit than
-does pragma Pure,
-but these restrictions are still sufficient to ensure that there
-are no elaboration problems with any calls to the unit.
+   --  main is actually a function, as in the ANSI C standard,
+   --  defined to return the exit status. The three parameters
+   --  are the argument count, argument values and environment
+   --  pointer.
 
-@item pragma Elaborate_Body
-@findex Elaborate_Body
-@cindex pragma Elaborate_Body
-This pragma requires that the body of a unit be elaborated immediately
-after its spec. Suppose a unit @code{A} has such a pragma,
-and unit @code{B} does
-a @code{with} of unit @code{A}. Recall that the standard rules require
-the spec of unit @code{A}
-to be elaborated before the @code{with}'ing unit; given the pragma in
-@code{A}, we also know that the body of @code{A}
-will be elaborated before @code{B}, so
-that calls to @code{A} are safe and do not need a check.
-@end table
+@findex Main Program
+   function main
+     (argc : Integer;
+      argv : System.Address;
+      envp : System.Address)
+      return Integer
+   is
+      --  The initialize routine performs low level system
+      --  initialization using a standard library routine which
+      --  sets up signal handling and performs any other
+      --  required setup. The routine can be found in file
+      --  a-init.c.
+
+@findex __gnat_initialize
+      procedure initialize;
+      pragma Import (C, initialize, "__gnat_initialize");
+
+      --  The finalize routine performs low level system
+      --  finalization using a standard library routine. The
+      --  routine is found in file a-final.c and in the standard
+      --  distribution is a dummy routine that does nothing, so
+      --  really this is a hook for special user finalization.
 
-@noindent
-Note that,
-unlike pragma @code{Pure} and pragma @code{Preelaborate},
-the use of
-@code{Elaborate_Body} does not guarantee that the program is
-free of elaboration problems, because it may not be possible
-to satisfy the requested elaboration order.
-Let's go back to the example with @code{Unit_1} and @code{Unit_2}.
-If a programmer
-marks @code{Unit_1} as @code{Elaborate_Body},
-and not @code{Unit_2,} then the order of
-elaboration will be:
+@findex __gnat_finalize
+      procedure finalize;
+      pragma Import (C, finalize, "__gnat_finalize");
 
-@smallexample
-@group
-Spec of Unit_2
-Spec of Unit_1
-Body of Unit_1
-Body of Unit_2
-@end group
-@end smallexample
+      --  We get to the main program of the partition by using
+      --  pragma Import because if we try to with the unit and
+      --  call it Ada style, then not only do we waste time
+      --  recompiling it, but also, we don't really know the right
+      --  switches (e.g. identifier character set) to be used
+      --  to compile it.
 
-@noindent
-Now that means that the call to @code{Func_1} in @code{Unit_2}
-need not be checked,
-it must be safe. But the call to @code{Func_2} in
-@code{Unit_1} may still fail if
-@code{Expression_1} is equal to 1,
-and the programmer must still take
-responsibility for this not being the case.
+      procedure Ada_Main_Program;
+      pragma Import (Ada, Ada_Main_Program, "_ada_hello");
 
-If all units carry a pragma @code{Elaborate_Body}, then all problems are
-eliminated, except for calls entirely within a body, which are
-in any case fully under programmer control. However, using the pragma
-everywhere is not always possible.
-In particular, for our @code{Unit_1}/@code{Unit_2} example, if
-we marked both of them as having pragma @code{Elaborate_Body}, then
-clearly there would be no possible elaboration order.
+   --  Start of processing for main
 
-The above pragmas allow a server to guarantee safe use by clients, and
-clearly this is the preferable approach. Consequently a good rule in
-Ada 95 is to mark units as @code{Pure} or @code{Preelaborate} if possible,
-and if this is not possible,
-mark them as @code{Elaborate_Body} if possible.
-As we have seen, there are situations where neither of these
-three pragmas can be used.
-So we also provide methods for clients to control the
-order of elaboration of the servers on which they depend:
+   begin
+      --  Save global variables
 
-@table @asis
-@item pragma Elaborate (unit)
-@findex Elaborate
-@cindex pragma Elaborate
-This pragma is placed in the context clause, after a @code{with} clause,
-and it requires that the body of the named unit be elaborated before
-the unit in which the pragma occurs. The idea is to use this pragma
-if the current unit calls at elaboration time, directly or indirectly,
-some subprogram in the named unit.
+      gnat_argc := argc;
+      gnat_argv := argv;
+      gnat_envp := envp;
 
-@item pragma Elaborate_All (unit)
-@findex Elaborate_All
-@cindex pragma Elaborate_All
-This is a stronger version of the Elaborate pragma. Consider the
-following example:
+      --  Call low level system initialization
 
-@smallexample
-Unit A @code{with}'s unit B and calls B.Func in elab code
-Unit B @code{with}'s unit C, and B.Func calls C.Func
-@end smallexample
+      Initialize;
 
-@noindent
-Now if we put a pragma @code{Elaborate (B)}
-in unit @code{A}, this ensures that the
-body of @code{B} is elaborated before the call, but not the
-body of @code{C}, so
-the call to @code{C.Func} could still cause @code{Program_Error} to
-be raised.
+      --  Call our generated Ada initialization routine
 
-The effect of a pragma @code{Elaborate_All} is stronger, it requires
-not only that the body of the named unit be elaborated before the
-unit doing the @code{with}, but also the bodies of all units that the
-named unit uses, following @code{with} links transitively. For example,
-if we put a pragma @code{Elaborate_All (B)} in unit @code{A},
-then it requires
-not only that the body of @code{B} be elaborated before @code{A},
-but also the
-body of @code{C}, because @code{B} @code{with}'s @code{C}.
-@end table
+      adainit;
 
-@noindent
-We are now in a position to give a usage rule in Ada 95 for avoiding
-elaboration problems, at least if dynamic dispatching and access to
-subprogram values are not used. We will handle these cases separately
-later.
+      --  This is the point at which we want the debugger to get
+      --  control
 
-The rule is simple. If a unit has elaboration code that can directly or
-indirectly make a call to a subprogram in a @code{with}'ed unit, or instantiate
-a generic unit in a @code{with}'ed unit,
-then if the @code{with}'ed unit does not have
-pragma @code{Pure} or @code{Preelaborate}, then the client should have
-a pragma @code{Elaborate_All}
-for the @code{with}'ed unit. By following this rule a client is
-assured that calls can be made without risk of an exception.
-If this rule is not followed, then a program may be in one of four
-states:
+      Break_Start;
 
-@table @asis
-@item No order exists
-No order of elaboration exists which follows the rules, taking into
-account any @code{Elaborate}, @code{Elaborate_All},
-or @code{Elaborate_Body} pragmas. In
-this case, an Ada 95 compiler must diagnose the situation at bind
-time, and refuse to build an executable program.
+      --  Now we call the main program of the partition
 
-@item One or more orders exist, all incorrect
-One or more acceptable elaboration orders exists, and all of them
-generate an elaboration order problem. In this case, the binder
-can build an executable program, but @code{Program_Error} will be raised
-when the program is run.
+      Ada_Main_Program;
 
-@item Several orders exist, some right, some incorrect
-One or more acceptable elaboration orders exists, and some of them
-work, and some do not. The programmer has not controlled
-the order of elaboration, so the binder may or may not pick one of
-the correct orders, and the program may or may not raise an
-exception when it is run. This is the worst case, because it means
-that the program may fail when moved to another compiler, or even
-another version of the same compiler.
+      --  Perform Ada finalization
 
-@item One or more orders exists, all correct
-One ore more acceptable elaboration orders exist, and all of them
-work. In this case the program runs successfully. This state of
-affairs can be guaranteed by following the rule we gave above, but
-may be true even if the rule is not followed.
-@end table
+      adafinal;
 
-@noindent
-Note that one additional advantage of following our Elaborate_All rule
-is that the program continues to stay in the ideal (all orders OK) state
-even if maintenance
-changes some bodies of some subprograms. Conversely, if a program that does
-not follow this rule happens to be safe at some point, this state of affairs
-may deteriorate silently as a result of maintenance changes.
+      --  Perform low level system finalization
 
-You may have noticed that the above discussion did not mention
-the use of @code{Elaborate_Body}. This was a deliberate omission. If you
-@code{with} an @code{Elaborate_Body} unit, it still may be the case that
-code in the body makes calls to some other unit, so it is still necessary
-to use @code{Elaborate_All} on such units.
+      Finalize;
 
-@node Controlling Elaboration in GNAT - Internal Calls
-@section Controlling Elaboration in GNAT - Internal Calls
+      --  Return the proper exit status
+      return (gnat_exit_status);
+   end;
 
-@noindent
-In the case of internal calls, i.e. calls within a single package, the
-programmer has full control over the order of elaboration, and it is up
-to the programmer to elaborate declarations in an appropriate order. For
-example writing:
+--  This section is entirely comments, so it has no effect on the
+--  compilation of the Ada_Main package. It provides the list of
+--  object files and linker options, as well as some standard
+--  libraries needed for the link. The gnatlink utility parses
+--  this b~hello.adb file to read these comment lines to generate
+--  the appropriate command line arguments for the call to the
+--  system linker. The BEGIN/END lines are used for sentinels for
+--  this parsing operation.
 
-@smallexample @c ada
-@group
-@cartouche
-function One return Float;
+--  The exact file names will of course depend on the environment,
+--  host/target and location of files on the host system.
 
-Q : Float := One;
+@findex Object file list
+-- BEGIN Object file/option list
+   --   ./hello.o
+   --   -L./
+   --   -L/usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/
+   --   /usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/libgnat.a
+-- END Object file/option list
 
-function One return Float is
-begin
-     return 1.0;
-end One;
-@end cartouche
-@end group
+end ada_main;
 @end smallexample
 
 @noindent
-will obviously raise @code{Program_Error} at run time, because function
-One will be called before its body is elaborated. In this case GNAT will
-generate a warning that the call will raise @code{Program_Error}:
+The Ada code in the above example is exactly what is generated by the
+binder. We have added comments to more clearly indicate the function
+of each part of the generated @code{Ada_Main} package.
 
-@smallexample
-@group
-@cartouche
- 1. procedure y is
- 2.    function One return Float;
- 3.
- 4.    Q : Float := One;
-                    |
-    >>> warning: cannot call "One" before body is elaborated
-    >>> warning: Program_Error will be raised at run time
+The code is standard Ada in all respects, and can be processed by any
+tools that handle Ada. In particular, it is possible to use the debugger
+in Ada mode to debug the generated @code{Ada_Main} package. For example,
+suppose that for reasons that you do not understand, your program is crashing
+during elaboration of the body of @code{Ada.Text_IO}. To locate this bug,
+you can place a breakpoint on the call:
 
- 5.
- 6.    function One return Float is
- 7.    begin
- 8.         return 1.0;
- 9.    end One;
-10.
-11. begin
-12.    null;
-13. end;
-@end cartouche
-@end group
+@smallexample @c ada
+Ada.Text_Io'Elab_Body;
 @end smallexample
 
 @noindent
-Note that in this particular case, it is likely that the call is safe, because
-the function @code{One} does not access any global variables.
-Nevertheless in Ada 95, we do not want the validity of the check to depend on
-the contents of the body (think about the separate compilation case), so this
-is still wrong, as we discussed in the previous sections.
+and trace the elaboration routine for this package to find out where
+the problem might be (more usually of course you would be debugging
+elaboration code in your own application).
+
+@node Elaboration Order Handling in GNAT
+@appendix Elaboration Order Handling in GNAT
+@cindex Order of elaboration
+@cindex Elaboration control
+
+@menu
+* Elaboration Code::
+* Checking the Elaboration Order::
+* Controlling the Elaboration Order::
+* Controlling Elaboration in GNAT - Internal Calls::
+* Controlling Elaboration in GNAT - External Calls::
+* Default Behavior in GNAT - Ensuring Safety::
+* Treatment of Pragma Elaborate::
+* Elaboration Issues for Library Tasks::
+* Mixing Elaboration Models::
+* What to Do If the Default Elaboration Behavior Fails::
+* Elaboration for Access-to-Subprogram Values::
+* Summary of Procedures for Elaboration Control::
+* Other Elaboration Order Considerations::
+@end menu
+
+@noindent
+This chapter describes the handling of elaboration code in Ada and
+in GNAT, and discusses how the order of elaboration of program units can
+be controlled in GNAT, either automatically or with explicit programming
+features.
 
-The error is easily corrected by rearranging the declarations so that the
-body of One appears before the declaration containing the call
-(note that in Ada 95,
-declarations can appear in any order, so there is no restriction that
-would prevent this reordering, and if we write:
+@node Elaboration Code
+@section Elaboration Code
+
+@noindent
+Ada provides rather general mechanisms for executing code at elaboration
+time, that is to say before the main program starts executing. Such code arises
+in three contexts:
 
+@table @asis
+@item Initializers for variables.
+Variables declared at the library level, in package specs or bodies, can
+require initialization that is performed at elaboration time, as in:
 @smallexample @c ada
-@group
 @cartouche
-function One return Float;
-
-function One return Float is
-begin
-     return 1.0;
-end One;
-
-Q : Float := One;
+Sqrt_Half : Float := Sqrt (0.5);
 @end cartouche
-@end group
 @end smallexample
 
+@item Package initialization code
+Code in a @code{BEGIN-END} section at the outer level of a package body is
+executed as part of the package body elaboration code.
+
+@item Library level task allocators
+Tasks that are declared using task allocators at the library level
+start executing immediately and hence can execute at elaboration time.
+@end table
+
 @noindent
-then all is well, no warning is generated, and no
-@code{Program_Error} exception
-will be raised.
-Things are more complicated when a chain of subprograms is executed:
+Subprogram calls are possible in any of these contexts, which means that
+any arbitrary part of the program may be executed as part of the elaboration
+code. It is even possible to write a program which does all its work at
+elaboration time, with a null main program, although stylistically this
+would usually be considered an inappropriate way to structure
+a program.
+
+An important concern arises in the context of elaboration code:
+we have to be sure that it is executed in an appropriate order. What we
+have is a series of elaboration code sections, potentially one section
+for each unit in the program. It is important that these execute
+in the correct order. Correctness here means that, taking the above
+example of the declaration of @code{Sqrt_Half},
+if some other piece of
+elaboration code references @code{Sqrt_Half},
+then it must run after the
+section of elaboration code that contains the declaration of
+@code{Sqrt_Half}.
+
+There would never be any order of elaboration problem if we made a rule
+that whenever you @code{with} a unit, you must elaborate both the spec and body
+of that unit before elaborating the unit doing the @code{with}'ing:
 
 @smallexample @c ada
 @group
 @cartouche
-function A return Integer;
-function B return Integer;
-function C return Integer;
-
-function B return Integer is begin return A; end;
-function C return Integer is begin return B; end;
-
-X : Integer := C;
-
-function A return Integer is begin return 1; end;
+with Unit_1;
+package Unit_2 is @dots{}
 @end cartouche
 @end group
 @end smallexample
 
 @noindent
-Now the call to @code{C}
-at elaboration time in the declaration of @code{X} is correct, because
-the body of @code{C} is already elaborated,
-and the call to @code{B} within the body of
-@code{C} is correct, but the call
-to @code{A} within the body of @code{B} is incorrect, because the body
-of @code{A} has not been elaborated, so @code{Program_Error}
-will be raised on the call to @code{A}.
-In this case GNAT will generate a
-warning that @code{Program_Error} may be
-raised at the point of the call. Let's look at the warning:
+would require that both the body and spec of @code{Unit_1} be elaborated
+before the spec of @code{Unit_2}. However, a rule like that would be far too
+restrictive. In particular, it would make it impossible to have routines
+in separate packages that were mutually recursive.
 
-@smallexample
-@group
-@cartouche
- 1. procedure x is
- 2.    function A return Integer;
- 3.    function B return Integer;
- 4.    function C return Integer;
- 5.
- 6.    function B return Integer is begin return A; end;
-                                                    |
-    >>> warning: call to "A" before body is elaborated may
-                 raise Program_Error
-    >>> warning: "B" called at line 7
-    >>> warning: "C" called at line 9
+You might think that a clever enough compiler could look at the actual
+elaboration code and determine an appropriate correct order of elaboration,
+but in the general case, this is not possible. Consider the following
+example.
 
- 7.    function C return Integer is begin return B; end;
- 8.
- 9.    X : Integer := C;
-10.
-11.    function A return Integer is begin return 1; end;
-12.
-13. begin
-14.    null;
-15. end;
+In the body of @code{Unit_1}, we have a procedure @code{Func_1}
+that references
+the variable @code{Sqrt_1}, which is declared in the elaboration code
+of the body of @code{Unit_1}:
+
+@smallexample @c ada
+@cartouche
+Sqrt_1 : Float := Sqrt (0.1);
 @end cartouche
-@end group
 @end smallexample
 
 @noindent
-Note that the message here says ``may raise'', instead of the direct case,
-where the message says ``will be raised''. That's because whether
-@code{A} is
-actually called depends in general on run-time flow of control.
-For example, if the body of @code{B} said
+The elaboration code of the body of @code{Unit_1} also contains:
 
 @smallexample @c ada
 @group
 @cartouche
-function B return Integer is
-begin
-   if some-condition-depending-on-input-data then
-      return A;
-   else
-      return 1;
-   end if;
-end B;
+if expression_1 = 1 then
+   Q := Unit_2.Func_2;
+end if;
 @end cartouche
 @end group
 @end smallexample
 
 @noindent
-then we could not know until run time whether the incorrect call to A would
-actually occur, so @code{Program_Error} might
-or might not be raised. It is possible for a compiler to
-do a better job of analyzing bodies, to
-determine whether or not @code{Program_Error}
-might be raised, but it certainly
-couldn't do a perfect job (that would require solving the halting problem
-and is provably impossible), and because this is a warning anyway, it does
-not seem worth the effort to do the analysis. Cases in which it
-would be relevant are rare.
-
-In practice, warnings of either of the forms given
-above will usually correspond to
-real errors, and should be examined carefully and eliminated.
-In the rare case where a warning is bogus, it can be suppressed by any of
-the following methods:
-
-@itemize @bullet
-@item
-Compile with the @option{-gnatws} switch set
-
-@item
-Suppress @code{Elaboration_Check} for the called subprogram
-
-@item
-Use pragma @code{Warnings_Off} to turn warnings off for the call
-@end itemize
-
-@noindent
-For the internal elaboration check case,
-GNAT by default generates the
-necessary run-time checks to ensure
-that @code{Program_Error} is raised if any
-call fails an elaboration check. Of course this can only happen if a
-warning has been issued as described above. The use of pragma
-@code{Suppress (Elaboration_Check)} may (but is not guaranteed to) suppress
-some of these checks, meaning that it may be possible (but is not
-guaranteed) for a program to be able to call a subprogram whose body
-is not yet elaborated, without raising a @code{Program_Error} exception.
-
-@node Controlling Elaboration in GNAT - External Calls
-@section Controlling Elaboration in GNAT - External Calls
-
-@noindent
-The previous section discussed the case in which the execution of a
-particular thread of elaboration code occurred entirely within a
-single unit. This is the easy case to handle, because a programmer
-has direct and total control over the order of elaboration, and
-furthermore, checks need only be generated in cases which are rare
-and which the compiler can easily detect.
-The situation is more complex when separate compilation is taken into account.
-Consider the following:
+@code{Unit_2} is exactly parallel,
+it has a procedure @code{Func_2} that references
+the variable @code{Sqrt_2}, which is declared in the elaboration code of
+the body @code{Unit_2}:
 
 @smallexample @c ada
 @cartouche
-@group
-package Math is
-   function Sqrt (Arg : Float) return Float;
-end Math;
-
-package body Math is
-   function Sqrt (Arg : Float) return Float is
-   begin
-         ...
-   end Sqrt;
-end Math;
-@end group
-@group
-with Math;
-package Stuff is
-   X : Float := Math.Sqrt (0.5);
-end Stuff;
-
-with Stuff;
-procedure Main is
-begin
-   ...
-end Main;
-@end group
+Sqrt_2 : Float := Sqrt (0.1);
 @end cartouche
-@end smallexample
-
-@noindent
-where @code{Main} is the main program. When this program is executed, the
-elaboration code must first be executed, and one of the jobs of the
-binder is to determine the order in which the units of a program are
-to be elaborated. In this case we have four units: the spec and body
-of @code{Math},
-the spec of @code{Stuff} and the body of @code{Main}).
-In what order should the four separate sections of elaboration code
-be executed?
-
-There are some restrictions in the order of elaboration that the binder
-can choose. In particular, if unit U has a @code{with}
-for a package @code{X}, then you
-are assured that the spec of @code{X}
-is elaborated before U , but you are
-not assured that the body of @code{X}
-is elaborated before U.
-This means that in the above case, the binder is allowed to choose the
-order:
-
-@smallexample
-spec of Math
-spec of Stuff
-body of Math
-body of Main
-@end smallexample
-
-@noindent
-but that's not good, because now the call to @code{Math.Sqrt}
-that happens during
-the elaboration of the @code{Stuff}
-spec happens before the body of @code{Math.Sqrt} is
-elaborated, and hence causes @code{Program_Error} exception to be raised.
-At first glance, one might say that the binder is misbehaving, because
-obviously you want to elaborate the body of something you @code{with}
-first, but
-that is not a general rule that can be followed in all cases. Consider
+@end smallexample
+
+@noindent
+The elaboration code of the body of @code{Unit_2} also contains:
 
 @smallexample @c ada
 @group
 @cartouche
-package X is ...
+if expression_2 = 2 then
+   Q := Unit_1.Func_1;
+end if;
+@end cartouche
+@end group
+@end smallexample
 
-package Y is ...
+@noindent
+Now the question is, which of the following orders of elaboration is
+acceptable:
 
-with X;
-package body Y is ...
+@smallexample
+@group
+Spec of Unit_1
+Spec of Unit_2
+Body of Unit_1
+Body of Unit_2
+@end group
+@end smallexample
 
-with Y;
-package body X is ...
-@end cartouche
+@noindent
+or
+
+@smallexample
+@group
+Spec of Unit_2
+Spec of Unit_1
+Body of Unit_2
+Body of Unit_1
 @end group
 @end smallexample
 
 @noindent
-This is a common arrangement, and, apart from the order of elaboration
-problems that might arise in connection with elaboration code, this works fine.
-A rule that says that you must first elaborate the body of anything you
-@code{with} cannot work in this case:
-the body of @code{X} @code{with}'s @code{Y},
-which means you would have to
-elaborate the body of @code{Y} first, but that @code{with}'s @code{X},
-which means
-you have to elaborate the body of @code{X} first, but ... and we have a
-loop that cannot be broken.
+If you carefully analyze the flow here, you will see that you cannot tell
+at compile time the answer to this question.
+If @code{expression_1} is not equal to 1,
+and @code{expression_2} is not equal to 2,
+then either order is acceptable, because neither of the function calls is
+executed. If both tests evaluate to true, then neither order is acceptable
+and in fact there is no correct order.
 
-It is true that the binder can in many cases guess an order of elaboration
-that is unlikely to cause a @code{Program_Error}
-exception to be raised, and it tries to do so (in the
-above example of @code{Math/Stuff/Spec}, the GNAT binder will
-by default
-elaborate the body of @code{Math} right after its spec, so all will be well).
+If one of the two expressions is true, and the other is false, then one
+of the above orders is correct, and the other is incorrect. For example,
+if @code{expression_1} /= 1 and @code{expression_2} = 2,
+then the call to @code{Func_1}
+will occur, but not the call to @code{Func_2.}
+This means that it is essential
+to elaborate the body of @code{Unit_1} before
+the body of @code{Unit_2}, so the first
+order of elaboration is correct and the second is wrong.
 
-However, a program that blindly relies on the binder to be helpful can
-get into trouble, as we discussed in the previous sections, so
-GNAT
-provides a number of facilities for assisting the programmer in
-developing programs that are robust with respect to elaboration order.
+By making @code{expression_1} and @code{expression_2}
+depend on input data, or perhaps
+the time of day, we can make it impossible for the compiler or binder
+to figure out which of these expressions will be true, and hence it
+is impossible to guarantee a safe order of elaboration at run time.
 
-@node Default Behavior in GNAT - Ensuring Safety
-@section Default Behavior in GNAT - Ensuring Safety
+@node Checking the Elaboration Order
+@section Checking the Elaboration Order
 
 @noindent
-The default behavior in GNAT ensures elaboration safety. In its
-default mode GNAT implements the
-rule we previously described as the right approach. Let's restate it:
+In some languages that involve the same kind of elaboration problems,
+e.g. Java and C++, the programmer is expected to worry about these
+ordering problems himself, and it is common to
+write a program in which an incorrect elaboration order  gives
+surprising results, because it references variables before they
+are initialized.
+Ada is designed to be a safe language, and a programmer-beware approach is
+clearly not sufficient. Consequently, the language provides three lines
+of defense:
 
-@itemize
-@item
-@emph{If a unit has elaboration code that can directly or indirectly make a
-call to a subprogram in a @code{with}'ed unit, or instantiate a generic unit
-in a @code{with}'ed unit, then if the @code{with}'ed unit
-does not have pragma @code{Pure} or
-@code{Preelaborate}, then the client should have an
-@code{Elaborate_All} for the @code{with}'ed unit.}
-@end itemize
+@table @asis
+@item Standard rules
+Some standard rules restrict the possible choice of elaboration
+order. In particular, if you @code{with} a unit, then its spec is always
+elaborated before the unit doing the @code{with}. Similarly, a parent
+spec is always elaborated before the child spec, and finally
+a spec is always elaborated before its corresponding body.
 
-@noindent
-By following this rule a client is assured that calls and instantiations
-can be made without risk of an exception.
+@item Dynamic elaboration checks
+@cindex Elaboration checks
+@cindex Checks, elaboration
+Dynamic checks are made at run time, so that if some entity is accessed
+before it is elaborated (typically  by means of a subprogram call)
+then the exception (@code{Program_Error}) is raised.
 
-In this mode GNAT traces all calls that are potentially made from
-elaboration code, and puts in any missing implicit @code{Elaborate_All}
-pragmas.
-The advantage of this approach is that no elaboration problems
-are possible if the binder can find an elaboration order that is
-consistent with these implicit @code{Elaborate_All} pragmas. The
-disadvantage of this approach is that no such order may exist.
+@item Elaboration control
+Facilities are provided for the programmer to specify the desired order
+of elaboration.
+@end table
 
-If the binder does not generate any diagnostics, then it means that it
-has found an elaboration order that is guaranteed to be safe. However,
-the binder may still be relying on implicitly generated
-@code{Elaborate_All} pragmas so portability to other compilers than
-GNAT is not guaranteed.
+Let's look at these facilities in more detail. First, the rules for
+dynamic checking. One possible rule would be simply to say that the
+exception is raised if you access a variable which has not yet been
+elaborated. The trouble with this approach is that it could require
+expensive checks on every variable reference. Instead Ada has two
+rules which are a little more restrictive, but easier to check, and
+easier to state:
 
-If it is important to guarantee portability, then the compilations should
-use the
-@option{-gnatwl}
-(warn on elaboration problems) switch. This will cause warning messages
-to be generated indicating the missing @code{Elaborate_All} pragmas.
-Consider the following source program:
+@table @asis
+@item Restrictions on calls
+A subprogram can only be called at elaboration time if its body
+has been elaborated. The rules for elaboration given above guarantee
+that the spec of the subprogram has been elaborated before the
+call, but not the body. If this rule is violated, then the
+exception @code{Program_Error} is raised.
 
-@smallexample @c ada
-@group
-@cartouche
-with k;
-package j is
-  m : integer := k.r;
-end;
-@end cartouche
-@end group
-@end smallexample
+@item Restrictions on instantiations
+A generic unit can only be instantiated if the body of the generic
+unit has been elaborated. Again, the rules for elaboration given above
+guarantee that the spec of the generic unit has been elaborated
+before the instantiation, but not the body. If this rule is
+violated, then the exception @code{Program_Error} is raised.
+@end table
 
 @noindent
-where it is clear that there
-should be a pragma @code{Elaborate_All}
-for unit @code{k}. An implicit pragma will be generated, and it is
-likely that the binder will be able to honor it. However, if you want
-to port this program to some other Ada compiler than GNAT.
-it is safer to include the pragma explicitly in the source. If this
-unit is compiled with the
-@option{-gnatwl}
-switch, then the compiler outputs a warning:
+The idea is that if the body has been elaborated, then any variables
+it references must have been elaborated; by checking for the body being
+elaborated we guarantee that none of its references causes any
+trouble. As we noted above, this is a little too restrictive, because a
+subprogram that has no non-local references in its body may in fact be safe
+to call. However, it really would be unsafe to rely on this, because
+it would mean that the caller was aware of details of the implementation
+in the body. This goes against the basic tenets of Ada.
 
-@smallexample
+A plausible implementation can be described as follows.
+A Boolean variable is associated with each subprogram
+and each generic unit. This variable is initialized to False, and is set to
+True at the point body is elaborated. Every call or instantiation checks the
+variable, and raises @code{Program_Error} if the variable is False.
+
+Note that one might think that it would be good enough to have one Boolean
+variable for each package, but that would not deal with cases of trying
+to call a body in the same package as the call
+that has not been elaborated yet.
+Of course a compiler may be able to do enough analysis to optimize away
+some of the Boolean variables as unnecessary, and @code{GNAT} indeed
+does such optimizations, but still the easiest conceptual model is to
+think of there being one variable per subprogram.
+
+@node Controlling the Elaboration Order
+@section Controlling the Elaboration Order
+
+@noindent
+In the previous section we discussed the rules in Ada which ensure
+that @code{Program_Error} is raised if an incorrect elaboration order is
+chosen. This prevents erroneous executions, but we need mechanisms to
+specify a correct execution and avoid the exception altogether.
+To achieve this, Ada provides a number of features for controlling
+the order of elaboration. We discuss these features in this section.
+
+First, there are several ways of indicating to the compiler that a given
+unit has no elaboration problems:
+
+@table @asis
+@item packages that do not require a body
+A library package that does not require a body does not permit
+a body (this rule was introduced in Ada 95).
+Thus if we have a such a package, as in:
+
+@smallexample @c ada
 @group
 @cartouche
-1. with k;
-2. package j is
-3.   m : integer := k.r;
-                     |
-   >>> warning: call to "r" may raise Program_Error
-   >>> warning: missing pragma Elaborate_All for "k"
-
-4. end;
+package Definitions is
+   generic
+      type m is new integer;
+   package Subp is
+      type a is array (1 .. 10) of m;
+      type b is array (1 .. 20) of m;
+   end Subp;
+end Definitions;
 @end cartouche
 @end group
 @end smallexample
 
 @noindent
-and these warnings can be used as a guide for supplying manually
-the missing pragmas. It is usually a bad idea to use this warning
-option during development. That's because it will warn you when
-you need to put in a pragma, but cannot warn you when it is time
-to take it out. So the use of pragma Elaborate_All may lead to
-unnecessary dependencies and even false circularities.
-
-This default mode is more restrictive than the Ada Reference
-Manual, and it is possible to construct programs which will compile
-using the dynamic model described there, but will run into a
-circularity using the safer static model we have described.
+A package that @code{with}'s @code{Definitions} may safely instantiate
+@code{Definitions.Subp} because the compiler can determine that there
+definitely is no package body to worry about in this case
 
-Of course any Ada compiler must be able to operate in a mode
-consistent with the requirements of the Ada Reference Manual,
-and in particular must have the capability of implementing the
-standard dynamic model of elaboration with run-time checks.
+@item pragma Pure
+@cindex pragma Pure
+@findex Pure
+Places sufficient restrictions on a unit to guarantee that
+no call to any subprogram in the unit can result in an
+elaboration problem. This means that the compiler does not need
+to worry about the point of elaboration of such units, and in
+particular, does not need to check any calls to any subprograms
+in this unit.
 
-In GNAT, this standard mode can be achieved either by the use of
-the @option{-gnatE} switch on the compiler (@code{gcc} or @code{gnatmake})
-command, or by the use of the configuration pragma:
+@item pragma Preelaborate
+@findex Preelaborate
+@cindex pragma Preelaborate
+This pragma places slightly less stringent restrictions on a unit than
+does pragma Pure,
+but these restrictions are still sufficient to ensure that there
+are no elaboration problems with any calls to the unit.
 
-@smallexample @c ada
-pragma Elaboration_Checks (RM);
-@end smallexample
+@item pragma Elaborate_Body
+@findex Elaborate_Body
+@cindex pragma Elaborate_Body
+This pragma requires that the body of a unit be elaborated immediately
+after its spec. Suppose a unit @code{A} has such a pragma,
+and unit @code{B} does
+a @code{with} of unit @code{A}. Recall that the standard rules require
+the spec of unit @code{A}
+to be elaborated before the @code{with}'ing unit; given the pragma in
+@code{A}, we also know that the body of @code{A}
+will be elaborated before @code{B}, so
+that calls to @code{A} are safe and do not need a check.
+@end table
 
 @noindent
-Either approach will cause the unit affected to be compiled using the
-standard dynamic run-time elaboration checks described in the Ada
-Reference Manual. The static model is generally preferable, since it
-is clearly safer to rely on compile and link time checks rather than
-run-time checks. However, in the case of legacy code, it may be
-difficult to meet the requirements of the static model. This
-issue is further discussed in
-@ref{What to Do If the Default Elaboration Behavior Fails}.
-
-Note that the static model provides a strict subset of the allowed
-behavior and programs of the Ada Reference Manual, so if you do
-adhere to the static model and no circularities exist,
-then you are assured that your program will
-work using the dynamic model, providing that you remove any
-pragma Elaborate statements from the source.
+Note that,
+unlike pragma @code{Pure} and pragma @code{Preelaborate},
+the use of
+@code{Elaborate_Body} does not guarantee that the program is
+free of elaboration problems, because it may not be possible
+to satisfy the requested elaboration order.
+Let's go back to the example with @code{Unit_1} and @code{Unit_2}.
+If a programmer
+marks @code{Unit_1} as @code{Elaborate_Body},
+and not @code{Unit_2,} then the order of
+elaboration will be:
 
-@node Treatment of Pragma Elaborate
-@section Treatment of Pragma Elaborate
-@cindex Pragma Elaborate
+@smallexample
+@group
+Spec of Unit_2
+Spec of Unit_1
+Body of Unit_1
+Body of Unit_2
+@end group
+@end smallexample
 
 @noindent
-The use of @code{pragma Elaborate}
-should generally be avoided in Ada 95 programs.
-The reason for this is that there is no guarantee that transitive calls
-will be properly handled. Indeed at one point, this pragma was placed
-in Annex J (Obsolescent Features), on the grounds that it is never useful.
+Now that means that the call to @code{Func_1} in @code{Unit_2}
+need not be checked,
+it must be safe. But the call to @code{Func_2} in
+@code{Unit_1} may still fail if
+@code{Expression_1} is equal to 1,
+and the programmer must still take
+responsibility for this not being the case.
 
-Now that's a bit restrictive. In practice, the case in which
-@code{pragma Elaborate} is useful is when the caller knows that there
-are no transitive calls, or that the called unit contains all necessary
-transitive @code{pragma Elaborate} statements, and legacy code often
-contains such uses.
+If all units carry a pragma @code{Elaborate_Body}, then all problems are
+eliminated, except for calls entirely within a body, which are
+in any case fully under programmer control. However, using the pragma
+everywhere is not always possible.
+In particular, for our @code{Unit_1}/@code{Unit_2} example, if
+we marked both of them as having pragma @code{Elaborate_Body}, then
+clearly there would be no possible elaboration order.
 
-Strictly speaking the static mode in GNAT should ignore such pragmas,
-since there is no assurance at compile time that the necessary safety
-conditions are met. In practice, this would cause GNAT to be incompatible
-with correctly written Ada 83 code that had all necessary
-@code{pragma Elaborate} statements in place. Consequently, we made the
-decision that GNAT in its default mode will believe that if it encounters
-a @code{pragma Elaborate} then the programmer knows what they are doing,
-and it will trust that no elaboration errors can occur.
+The above pragmas allow a server to guarantee safe use by clients, and
+clearly this is the preferable approach. Consequently a good rule
+is to mark units as @code{Pure} or @code{Preelaborate} if possible,
+and if this is not possible,
+mark them as @code{Elaborate_Body} if possible.
+As we have seen, there are situations where neither of these
+three pragmas can be used.
+So we also provide methods for clients to control the
+order of elaboration of the servers on which they depend:
 
-The result of this decision is two-fold. First to be safe using the
-static mode, you should remove all @code{pragma Elaborate} statements.
-Second, when fixing circularities in existing code, you can selectively
-use @code{pragma Elaborate} statements to convince the static mode of
-GNAT that it need not generate an implicit @code{pragma Elaborate_All}
-statement.
+@table @asis
+@item pragma Elaborate (unit)
+@findex Elaborate
+@cindex pragma Elaborate
+This pragma is placed in the context clause, after a @code{with} clause,
+and it requires that the body of the named unit be elaborated before
+the unit in which the pragma occurs. The idea is to use this pragma
+if the current unit calls at elaboration time, directly or indirectly,
+some subprogram in the named unit.
 
-When using the static mode with @option{-gnatwl}, any use of
-@code{pragma Elaborate} will generate a warning about possible
-problems.
+@item pragma Elaborate_All (unit)
+@findex Elaborate_All
+@cindex pragma Elaborate_All
+This is a stronger version of the Elaborate pragma. Consider the
+following example:
 
-@node Elaboration Issues for Library Tasks
-@section Elaboration Issues for Library Tasks
-@cindex Library tasks, elaboration issues
-@cindex Elaboration of library tasks
+@smallexample
+Unit A @code{with}'s unit B and calls B.Func in elab code
+Unit B @code{with}'s unit C, and B.Func calls C.Func
+@end smallexample
 
 @noindent
-In this section we examine special elaboration issues that arise for
-programs that declare library level tasks.
-
-Generally the model of execution of an Ada program is that all units are
-elaborated, and then execution of the program starts. However, the
-declaration of library tasks definitely does not fit this model. The
-reason for this is that library tasks start as soon as they are declared
-(more precisely, as soon as the statement part of the enclosing package
-body is reached), that is to say before elaboration
-of the program is complete. This means that if such a task calls a
-subprogram, or an entry in another task, the callee may or may not be
-elaborated yet, and in the standard
-Reference Manual model of dynamic elaboration checks, you can even
-get timing dependent Program_Error exceptions, since there can be
-a race between the elaboration code and the task code.
-
-The static model of elaboration in GNAT seeks to avoid all such
-dynamic behavior, by being conservative, and the conservative
-approach in this particular case is to assume that all the code
-in a task body is potentially executed at elaboration time if
-a task is declared at the library level.
+Now if we put a pragma @code{Elaborate (B)}
+in unit @code{A}, this ensures that the
+body of @code{B} is elaborated before the call, but not the
+body of @code{C}, so
+the call to @code{C.Func} could still cause @code{Program_Error} to
+be raised.
 
-This can definitely result in unexpected circularities. Consider
-the following example
+The effect of a pragma @code{Elaborate_All} is stronger, it requires
+not only that the body of the named unit be elaborated before the
+unit doing the @code{with}, but also the bodies of all units that the
+named unit uses, following @code{with} links transitively. For example,
+if we put a pragma @code{Elaborate_All (B)} in unit @code{A},
+then it requires
+not only that the body of @code{B} be elaborated before @code{A},
+but also the
+body of @code{C}, because @code{B} @code{with}'s @code{C}.
+@end table
 
-@smallexample @c ada
-package Decls is
-  task Lib_Task is
-     entry Start;
-  end Lib_Task;
+@noindent
+We are now in a position to give a usage rule in Ada for avoiding
+elaboration problems, at least if dynamic dispatching and access to
+subprogram values are not used. We will handle these cases separately
+later.
 
-  type My_Int is new Integer;
+The rule is simple. If a unit has elaboration code that can directly or
+indirectly make a call to a subprogram in a @code{with}'ed unit, or instantiate
+a generic package in a @code{with}'ed unit,
+then if the @code{with}'ed unit does not have
+pragma @code{Pure} or @code{Preelaborate}, then the client should have
+a pragma @code{Elaborate_All}
+for the @code{with}'ed unit. By following this rule a client is
+assured that calls can be made without risk of an exception.
 
-  function Ident (M : My_Int) return My_Int;
-end Decls;
+For generic subprogram instantiations, the rule can be relaxed to
+require only a pragma @code{Elaborate} since elaborating the body
+of a subprogram cannot cause any transitive elaboration (we are
+not calling the subprogram in this case, just elaborating its
+declaration).
 
-with Utils;
-package body Decls is
-  task body Lib_Task is
-  begin
-     accept Start;
-     Utils.Put_Val (2);
-  end Lib_Task;
+If this rule is not followed, then a program may be in one of four
+states:
 
-  function Ident (M : My_Int) return My_Int is
-  begin
-     return M;
-  end Ident;
-end Decls;
+@table @asis
+@item No order exists
+No order of elaboration exists which follows the rules, taking into
+account any @code{Elaborate}, @code{Elaborate_All},
+or @code{Elaborate_Body} pragmas. In
+this case, an Ada compiler must diagnose the situation at bind
+time, and refuse to build an executable program.
 
-with Decls;
-package Utils is
-  procedure Put_Val (Arg : Decls.My_Int);
-end Utils;
+@item One or more orders exist, all incorrect
+One or more acceptable elaboration orders exist, and all of them
+generate an elaboration order problem. In this case, the binder
+can build an executable program, but @code{Program_Error} will be raised
+when the program is run.
 
-with Text_IO;
-package body Utils is
-  procedure Put_Val (Arg : Decls.My_Int) is
-  begin
-     Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg)));
-  end Put_Val;
-end Utils;
+@item Several orders exist, some right, some incorrect
+One or more acceptable elaboration orders exists, and some of them
+work, and some do not. The programmer has not controlled
+the order of elaboration, so the binder may or may not pick one of
+the correct orders, and the program may or may not raise an
+exception when it is run. This is the worst case, because it means
+that the program may fail when moved to another compiler, or even
+another version of the same compiler.
 
-with Decls;
-procedure Main is
-begin
-   Decls.Lib_Task.Start;
-end;
-@end smallexample
+@item One or more orders exists, all correct
+One ore more acceptable elaboration orders exist, and all of them
+work. In this case the program runs successfully. This state of
+affairs can be guaranteed by following the rule we gave above, but
+may be true even if the rule is not followed.
+@end table
 
 @noindent
-If the above example is compiled in the default static elaboration
-mode, then a circularity occurs. The circularity comes from the call
-@code{Utils.Put_Val} in the task body of @code{Decls.Lib_Task}. Since
-this call occurs in elaboration code, we need an implicit pragma
-@code{Elaborate_All} for @code{Utils}. This means that not only must
-the spec and body of @code{Utils} be elaborated before the body
-of @code{Decls}, but also the spec and body of any unit that is
-@code{with'ed} by the body of @code{Utils} must also be elaborated before
-the body of @code{Decls}. This is the transitive implication of
-pragma @code{Elaborate_All} and it makes sense, because in general
-the body of @code{Put_Val} might have a call to something in a
-@code{with'ed} unit.
-
-In this case, the body of Utils (actually its spec) @code{with's}
-@code{Decls}. Unfortunately this means that the body of @code{Decls}
-must be elaborated before itself, in case there is a call from the
-body of @code{Utils}.
-
-Here is the exact chain of events we are worrying about:
+Note that one additional advantage of following our rules on the use
+of @code{Elaborate} and @code{Elaborate_All}
+is that the program continues to stay in the ideal (all orders OK) state
+even if maintenance
+changes some bodies of some units. Conversely, if a program that does
+not follow this rule happens to be safe at some point, this state of affairs
+may deteriorate silently as a result of maintenance changes.
 
-@enumerate
-@item
-In the body of @code{Decls} a call is made from within the body of a library
-task to a subprogram in the package @code{Utils}. Since this call may
-occur at elaboration time (given that the task is activated at elaboration
-time), we have to assume the worst, i.e. that the
-call does happen at elaboration time.
+You may have noticed that the above discussion did not mention
+the use of @code{Elaborate_Body}. This was a deliberate omission. If you
+@code{with} an @code{Elaborate_Body} unit, it still may be the case that
+code in the body makes calls to some other unit, so it is still necessary
+to use @code{Elaborate_All} on such units.
 
-@item
-This means that the body and spec of @code{Util} must be elaborated before
-the body of @code{Decls} so that this call does not cause an access before
-elaboration.
+@node Controlling Elaboration in GNAT - Internal Calls
+@section Controlling Elaboration in GNAT - Internal Calls
 
-@item
-Within the body of @code{Util}, specifically within the body of
-@code{Util.Put_Val} there may be calls to any unit @code{with}'ed
-by this package.
+@noindent
+In the case of internal calls, i.e. calls within a single package, the
+programmer has full control over the order of elaboration, and it is up
+to the programmer to elaborate declarations in an appropriate order. For
+example writing:
 
-@item
-One such @code{with}'ed package is package @code{Decls}, so there
-might be a call to a subprogram in @code{Decls} in @code{Put_Val}.
-In fact there is such a call in this example, but we would have to
-assume that there was such a call even if it were not there, since
-we are not supposed to write the body of @code{Decls} knowing what
-is in the body of @code{Utils}; certainly in the case of the
-static elaboration model, the compiler does not know what is in
-other bodies and must assume the worst.
+@smallexample @c ada
+@group
+@cartouche
+function One return Float;
 
-@item
-This means that the spec and body of @code{Decls} must also be
-elaborated before we elaborate the unit containing the call, but
-that unit is @code{Decls}! This means that the body of @code{Decls}
-must be elaborated before itself, and that's a circularity.
-@end enumerate
+Q : Float := One;
+
+function One return Float is
+begin
+     return 1.0;
+end One;
+@end cartouche
+@end group
+@end smallexample
 
 @noindent
-Indeed, if you add an explicit pragma Elaborate_All for @code{Utils} in
-the body of @code{Decls} you will get a true Ada Reference Manual
-circularity that makes the program illegal.
+will obviously raise @code{Program_Error} at run time, because function
+One will be called before its body is elaborated. In this case GNAT will
+generate a warning that the call will raise @code{Program_Error}:
 
-In practice, we have found that problems with the static model of
-elaboration in existing code often arise from library tasks, so
-we must address this particular situation.
+@smallexample
+@group
+@cartouche
+ 1. procedure y is
+ 2.    function One return Float;
+ 3.
+ 4.    Q : Float := One;
+                    |
+    >>> warning: cannot call "One" before body is elaborated
+    >>> warning: Program_Error will be raised at run time
 
-Note that if we compile and run the program above, using the dynamic model of
-elaboration (that is to say use the @option{-gnatE} switch),
-then it compiles, binds,
-links, and runs, printing the expected result of 2. Therefore in some sense
-the circularity here is only apparent, and we need to capture
-the properties of this program that  distinguish it from other library-level
-tasks that have real elaboration problems.
+ 5.
+ 6.    function One return Float is
+ 7.    begin
+ 8.         return 1.0;
+ 9.    end One;
+10.
+11. begin
+12.    null;
+13. end;
+@end cartouche
+@end group
+@end smallexample
 
-We have four possible answers to this question:
+@noindent
+Note that in this particular case, it is likely that the call is safe, because
+the function @code{One} does not access any global variables.
+Nevertheless in Ada, we do not want the validity of the check to depend on
+the contents of the body (think about the separate compilation case), so this
+is still wrong, as we discussed in the previous sections.
 
-@itemize @bullet
+The error is easily corrected by rearranging the declarations so that the
+body of @code{One} appears before the declaration containing the call
+(note that in Ada 95 and Ada 2005,
+declarations can appear in any order, so there is no restriction that
+would prevent this reordering, and if we write:
 
-@item
-Use the dynamic model of elaboration.
+@smallexample @c ada
+@group
+@cartouche
+function One return Float;
 
-If we use the @option{-gnatE} switch, then as noted above, the program works.
-Why is this? If we examine the task body, it is apparent that the task cannot
-proceed past the
-@code{accept} statement until after elaboration has been completed, because
-the corresponding entry call comes from the main program, not earlier.
-This is why the dynamic model works here. But that's really giving
-up on a precise analysis, and we prefer to take this approach only if we cannot
-solve the
-problem in any other manner. So let us examine two ways to reorganize
-the program to avoid the potential elaboration problem.
+function One return Float is
+begin
+     return 1.0;
+end One;
 
-@item
-Split library tasks into separate packages.
+Q : Float := One;
+@end cartouche
+@end group
+@end smallexample
 
-Write separate packages, so that library tasks are isolated from
-other declarations as much as possible. Let us look at a variation on
-the above program.
+@noindent
+then all is well, no warning is generated, and no
+@code{Program_Error} exception
+will be raised.
+Things are more complicated when a chain of subprograms is executed:
 
 @smallexample @c ada
-package Decls1 is
-  task Lib_Task is
-     entry Start;
-  end Lib_Task;
-end Decls1;
+@group
+@cartouche
+function A return Integer;
+function B return Integer;
+function C return Integer;
 
-with Utils;
-package body Decls1 is
-  task body Lib_Task is
-  begin
-     accept Start;
-     Utils.Put_Val (2);
-  end Lib_Task;
-end Decls1;
+function B return Integer is begin return A; end;
+function C return Integer is begin return B; end;
 
-package Decls2 is
-  type My_Int is new Integer;
-  function Ident (M : My_Int) return My_Int;
-end Decls2;
+X : Integer := C;
 
-with Utils;
-package body Decls2 is
-  function Ident (M : My_Int) return My_Int is
-  begin
-     return M;
-  end Ident;
-end Decls2;
+function A return Integer is begin return 1; end;
+@end cartouche
+@end group
+@end smallexample
 
-with Decls2;
-package Utils is
-  procedure Put_Val (Arg : Decls2.My_Int);
-end Utils;
+@noindent
+Now the call to @code{C}
+at elaboration time in the declaration of @code{X} is correct, because
+the body of @code{C} is already elaborated,
+and the call to @code{B} within the body of
+@code{C} is correct, but the call
+to @code{A} within the body of @code{B} is incorrect, because the body
+of @code{A} has not been elaborated, so @code{Program_Error}
+will be raised on the call to @code{A}.
+In this case GNAT will generate a
+warning that @code{Program_Error} may be
+raised at the point of the call. Let's look at the warning:
 
-with Text_IO;
-package body Utils is
-  procedure Put_Val (Arg : Decls2.My_Int) is
-  begin
-     Text_IO.Put_Line (Decls2.My_Int'Image (Decls2.Ident (Arg)));
-  end Put_Val;
-end Utils;
+@smallexample
+@group
+@cartouche
+ 1. procedure x is
+ 2.    function A return Integer;
+ 3.    function B return Integer;
+ 4.    function C return Integer;
+ 5.
+ 6.    function B return Integer is begin return A; end;
+                                                    |
+    >>> warning: call to "A" before body is elaborated may
+                 raise Program_Error
+    >>> warning: "B" called at line 7
+    >>> warning: "C" called at line 9
 
-with Decls1;
-procedure Main is
+ 7.    function C return Integer is begin return B; end;
+ 8.
+ 9.    X : Integer := C;
+10.
+11.    function A return Integer is begin return 1; end;
+12.
+13. begin
+14.    null;
+15. end;
+@end cartouche
+@end group
+@end smallexample
+
+@noindent
+Note that the message here says ``may raise'', instead of the direct case,
+where the message says ``will be raised''. That's because whether
+@code{A} is
+actually called depends in general on run-time flow of control.
+For example, if the body of @code{B} said
+
+@smallexample @c ada
+@group
+@cartouche
+function B return Integer is
 begin
-   Decls1.Lib_Task.Start;
-end;
+   if some-condition-depending-on-input-data then
+      return A;
+   else
+      return 1;
+   end if;
+end B;
+@end cartouche
+@end group
 @end smallexample
 
 @noindent
-All we have done is to split @code{Decls} into two packages, one
-containing the library task, and one containing everything else. Now
-there is no cycle, and the program compiles, binds, links and executes
-using the default static model of elaboration.
+then we could not know until run time whether the incorrect call to A would
+actually occur, so @code{Program_Error} might
+or might not be raised. It is possible for a compiler to
+do a better job of analyzing bodies, to
+determine whether or not @code{Program_Error}
+might be raised, but it certainly
+couldn't do a perfect job (that would require solving the halting problem
+and is provably impossible), and because this is a warning anyway, it does
+not seem worth the effort to do the analysis. Cases in which it
+would be relevant are rare.
+
+In practice, warnings of either of the forms given
+above will usually correspond to
+real errors, and should be examined carefully and eliminated.
+In the rare case where a warning is bogus, it can be suppressed by any of
+the following methods:
 
+@itemize @bullet
 @item
-Declare separate task types.
-
-A significant part of the problem arises because of the use of the
-single task declaration form. This means that the elaboration of
-the task type, and the elaboration of the task itself (i.e. the
-creation of the task) happen at the same time. A good rule
-of style in Ada 95 is to always create explicit task types. By
-following the additional step of placing task objects in separate
-packages from the task type declaration, many elaboration problems
-are avoided. Here is another modified example of the example program:
-
-@smallexample @c ada
-package Decls is
-  task type Lib_Task_Type is
-     entry Start;
-  end Lib_Task_Type;
+Compile with the @option{-gnatws} switch set
 
-  type My_Int is new Integer;
+@item
+Suppress @code{Elaboration_Check} for the called subprogram
 
-  function Ident (M : My_Int) return My_Int;
-end Decls;
+@item
+Use pragma @code{Warnings_Off} to turn warnings off for the call
+@end itemize
 
-with Utils;
-package body Decls is
-  task body Lib_Task_Type is
-  begin
-     accept Start;
-     Utils.Put_Val (2);
-  end Lib_Task_Type;
+@noindent
+For the internal elaboration check case,
+GNAT by default generates the
+necessary run-time checks to ensure
+that @code{Program_Error} is raised if any
+call fails an elaboration check. Of course this can only happen if a
+warning has been issued as described above. The use of pragma
+@code{Suppress (Elaboration_Check)} may (but is not guaranteed to) suppress
+some of these checks, meaning that it may be possible (but is not
+guaranteed) for a program to be able to call a subprogram whose body
+is not yet elaborated, without raising a @code{Program_Error} exception.
 
-  function Ident (M : My_Int) return My_Int is
-  begin
-     return M;
-  end Ident;
-end Decls;
+@node Controlling Elaboration in GNAT - External Calls
+@section Controlling Elaboration in GNAT - External Calls
 
-with Decls;
-package Utils is
-  procedure Put_Val (Arg : Decls.My_Int);
-end Utils;
+@noindent
+The previous section discussed the case in which the execution of a
+particular thread of elaboration code occurred entirely within a
+single unit. This is the easy case to handle, because a programmer
+has direct and total control over the order of elaboration, and
+furthermore, checks need only be generated in cases which are rare
+and which the compiler can easily detect.
+The situation is more complex when separate compilation is taken into account.
+Consider the following:
 
-with Text_IO;
-package body Utils is
-  procedure Put_Val (Arg : Decls.My_Int) is
-  begin
-     Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg)));
-  end Put_Val;
-end Utils;
+@smallexample @c ada
+@cartouche
+@group
+package Math is
+   function Sqrt (Arg : Float) return Float;
+end Math;
 
-with Decls;
-package Declst is
-   Lib_Task : Decls.Lib_Task_Type;
-end Declst;
+package body Math is
+   function Sqrt (Arg : Float) return Float is
+   begin
+         @dots{}
+   end Sqrt;
+end Math;
+@end group
+@group
+with Math;
+package Stuff is
+   X : Float := Math.Sqrt (0.5);
+end Stuff;
 
-with Declst;
+with Stuff;
 procedure Main is
 begin
-   Declst.Lib_Task.Start;
-end;
+   @dots{}
+end Main;
+@end group
+@end cartouche
 @end smallexample
 
 @noindent
-What we have done here is to replace the @code{task} declaration in
-package @code{Decls} with a @code{task type} declaration. Then we
-introduce a separate package @code{Declst} to contain the actual
-task object. This separates the elaboration issues for
-the @code{task type}
-declaration, which causes no trouble, from the elaboration issues
-of the task object, which is also unproblematic, since it is now independent
-of the elaboration of  @code{Utils}.
-This separation of concerns also corresponds to
-a generally sound engineering principle of separating declarations
-from instances. This version of the program also compiles, binds, links,
-and executes, generating the expected output.
+where @code{Main} is the main program. When this program is executed, the
+elaboration code must first be executed, and one of the jobs of the
+binder is to determine the order in which the units of a program are
+to be elaborated. In this case we have four units: the spec and body
+of @code{Math},
+the spec of @code{Stuff} and the body of @code{Main}).
+In what order should the four separate sections of elaboration code
+be executed?
 
-@item
-Use No_Entry_Calls_In_Elaboration_Code restriction.
-@cindex No_Entry_Calls_In_Elaboration_Code
+There are some restrictions in the order of elaboration that the binder
+can choose. In particular, if unit U has a @code{with}
+for a package @code{X}, then you
+are assured that the spec of @code{X}
+is elaborated before U , but you are
+not assured that the body of @code{X}
+is elaborated before U.
+This means that in the above case, the binder is allowed to choose the
+order:
 
-The previous two approaches described how a program can be restructured
-to avoid the special problems caused by library task bodies. in practice,
-however, such restructuring may be difficult to apply to existing legacy code,
-so we must consider solutions that do not require massive rewriting.
+@smallexample
+spec of Math
+spec of Stuff
+body of Math
+body of Main
+@end smallexample
 
-Let us consider more carefully why our original sample program works
-under the dynamic model of elaboration. The reason is that the code
-in the task body blocks immediately on the @code{accept}
-statement. Now of course there is nothing to prohibit elaboration
-code from making entry calls (for example from another library level task),
-so we cannot tell in isolation that
-the task will not execute the accept statement  during elaboration.
+@noindent
+but that's not good, because now the call to @code{Math.Sqrt}
+that happens during
+the elaboration of the @code{Stuff}
+spec happens before the body of @code{Math.Sqrt} is
+elaborated, and hence causes @code{Program_Error} exception to be raised.
+At first glance, one might say that the binder is misbehaving, because
+obviously you want to elaborate the body of something you @code{with}
+first, but
+that is not a general rule that can be followed in all cases. Consider
 
-However, in practice it is very unusual to see elaboration code
-make any entry calls, and the pattern of tasks starting
-at elaboration time and then immediately blocking on @code{accept} or
-@code{select} statements is very common. What this means is that
-the compiler is being too pessimistic when it analyzes the
-whole package body as though it might be executed at elaboration
-time.
+@smallexample @c ada
+@group
+@cartouche
+package X is @dots{}
 
-If we know that the elaboration code contains no entry calls, (a very safe
-assumption most of the time, that could almost be made the default
-behavior), then we can compile all units of the program under control
-of the following configuration pragma:
+package Y is @dots{}
 
-@smallexample
-pragma Restrictions (No_Entry_Calls_In_Elaboration_Code);
+with X;
+package body Y is @dots{}
+
+with Y;
+package body X is @dots{}
+@end cartouche
+@end group
 @end smallexample
 
 @noindent
-This pragma can be placed in the @file{gnat.adc} file in the usual
-manner. If we take our original unmodified program and compile it
-in the presence of a @file{gnat.adc} containing the above pragma,
-then once again, we can compile, bind, link, and execute, obtaining
-the expected result. In the presence of this pragma, the compiler does
-not trace calls in a task body, that appear after the first @code{accept}
-or @code{select} statement, and therefore does not report a potential
-circularity in the original program.
+This is a common arrangement, and, apart from the order of elaboration
+problems that might arise in connection with elaboration code, this works fine.
+A rule that says that you must first elaborate the body of anything you
+@code{with} cannot work in this case:
+the body of @code{X} @code{with}'s @code{Y},
+which means you would have to
+elaborate the body of @code{Y} first, but that @code{with}'s @code{X},
+which means
+you have to elaborate the body of @code{X} first, but @dots{} and we have a
+loop that cannot be broken.
 
-The compiler will check to the extent it can that the above
-restriction is not violated, but it is not always possible to do a
-complete check at compile time, so it is important to use this
-pragma only if the stated restriction is in fact met, that is to say
-no task receives an entry call before elaboration of all units is completed.
+It is true that the binder can in many cases guess an order of elaboration
+that is unlikely to cause a @code{Program_Error}
+exception to be raised, and it tries to do so (in the
+above example of @code{Math/Stuff/Spec}, the GNAT binder will
+by default
+elaborate the body of @code{Math} right after its spec, so all will be well).
 
-@end itemize
+However, a program that blindly relies on the binder to be helpful can
+get into trouble, as we discussed in the previous sections, so
+GNAT
+provides a number of facilities for assisting the programmer in
+developing programs that are robust with respect to elaboration order.
 
-@node Mixing Elaboration Models
-@section Mixing Elaboration Models
-@noindent
-So far, we have assumed that the entire program is either compiled
-using the dynamic model or static model, ensuring consistency. It
-is possible to mix the two models, but rules have to be followed
-if this mixing is done to ensure that elaboration checks are not
-omitted.
+@node Default Behavior in GNAT - Ensuring Safety
+@section Default Behavior in GNAT - Ensuring Safety
 
-The basic rule is that @emph{a unit compiled with the static model cannot
-be @code{with'ed} by a unit compiled with the dynamic model}. The
-reason for this is that in the static model, a unit assumes that
-its clients guarantee to use (the equivalent of) pragma
-@code{Elaborate_All} so that no elaboration checks are required
-in inner subprograms, and this assumption is violated if the
-client is compiled with dynamic checks.
+@noindent
+The default behavior in GNAT ensures elaboration safety. In its
+default mode GNAT implements the
+rule we previously described as the right approach. Let's restate it:
 
-The precise rule is as follows. A unit that is compiled with dynamic
-checks can only @code{with} a unit that meets at least one of the
-following criteria:
+@itemize
+@item
+@emph{If a unit has elaboration code that can directly or indirectly make a
+call to a subprogram in a @code{with}'ed unit, or instantiate a generic
+package in a @code{with}'ed unit, then if the @code{with}'ed unit
+does not have pragma @code{Pure} or
+@code{Preelaborate}, then the client should have an
+@code{Elaborate_All} pragma for the @code{with}'ed unit.}
 
-@itemize @bullet
+@emph{In the case of instantiating a generic subprogram, it is always
+sufficient to have only an @code{Elaborate} pragma for the
+@code{with}'ed unit.}
+@end itemize
 
-@item
-The @code{with'ed} unit is itself compiled with dynamic elaboration
-checks (that is with the @option{-gnatE} switch.
+@noindent
+By following this rule a client is assured that calls and instantiations
+can be made without risk of an exception.
 
-@item
-The @code{with'ed} unit is an internal GNAT implementation unit from
-the System, Interfaces, Ada, or GNAT hierarchies.
+In this mode GNAT traces all calls that are potentially made from
+elaboration code, and puts in any missing implicit @code{Elaborate}
+and @code{Elaborate_All} pragmas.
+The advantage of this approach is that no elaboration problems
+are possible if the binder can find an elaboration order that is
+consistent with these implicit @code{Elaborate} and
+@code{Elaborate_All} pragmas. The
+disadvantage of this approach is that no such order may exist.
 
-@item
-The @code{with'ed} unit has pragma Preelaborate or pragma Pure.
+If the binder does not generate any diagnostics, then it means that it has
+found an elaboration order that is guaranteed to be safe. However, the binder
+may still be relying on implicitly generated @code{Elaborate} and
+@code{Elaborate_All} pragmas so portability to other compilers than GNAT is not
+guaranteed.
 
-@item
-The @code{with'ing} unit (that is the client) has an explicit pragma
-@code{Elaborate_All} for the @code{with'ed} unit.
+If it is important to guarantee portability, then the compilations should
+use the
+@option{-gnatwl}
+(warn on elaboration problems) switch. This will cause warning messages
+to be generated indicating the missing @code{Elaborate} and
+@code{Elaborate_All} pragmas.
+Consider the following source program:
 
-@end itemize
+@smallexample @c ada
+@group
+@cartouche
+with k;
+package j is
+  m : integer := k.r;
+end;
+@end cartouche
+@end group
+@end smallexample
 
 @noindent
-If this rule is violated, that is if a unit with dynamic elaboration
-checks @code{with's} a unit that does not meet one of the above four
-criteria, then the binder (@code{gnatbind}) will issue a warning
-similar to that in the following example:
+where it is clear that there
+should be a pragma @code{Elaborate_All}
+for unit @code{k}. An implicit pragma will be generated, and it is
+likely that the binder will be able to honor it. However, if you want
+to port this program to some other Ada compiler than GNAT.
+it is safer to include the pragma explicitly in the source. If this
+unit is compiled with the
+@option{-gnatwl}
+switch, then the compiler outputs a warning:
 
 @smallexample
-warning: "x.ads" has dynamic elaboration checks and with's
-warning:   "y.ads" which has static elaboration checks
+@group
+@cartouche
+1. with k;
+2. package j is
+3.   m : integer := k.r;
+                     |
+   >>> warning: call to "r" may raise Program_Error
+   >>> warning: missing pragma Elaborate_All for "k"
+
+4. end;
+@end cartouche
+@end group
 @end smallexample
 
 @noindent
-These warnings indicate that the rule has been violated, and that as a result
-elaboration checks may be missed in the resulting executable file.
-This warning may be suppressed using the @option{-ws} binder switch
-in the usual manner.
+and these warnings can be used as a guide for supplying manually
+the missing pragmas. It is usually a bad idea to use this warning
+option during development. That's because it will warn you when
+you need to put in a pragma, but cannot warn you when it is time
+to take it out. So the use of pragma @code{Elaborate_All} may lead to
+unnecessary dependencies and even false circularities.
 
-One useful application of this mixing rule is in the case of a subsystem
-which does not itself @code{with} units from the remainder of the
-application. In this case, the entire subsystem can be compiled with
-dynamic checks to resolve a circularity in the subsystem, while
-allowing the main application that uses this subsystem to be compiled
-using the more reliable default static model.
+This default mode is more restrictive than the Ada Reference
+Manual, and it is possible to construct programs which will compile
+using the dynamic model described there, but will run into a
+circularity using the safer static model we have described.
 
-@node What to Do If the Default Elaboration Behavior Fails
-@section What to Do If the Default Elaboration Behavior Fails
+Of course any Ada compiler must be able to operate in a mode
+consistent with the requirements of the Ada Reference Manual,
+and in particular must have the capability of implementing the
+standard dynamic model of elaboration with run-time checks.
 
-@noindent
-If the binder cannot find an acceptable order, it outputs detailed
-diagnostics. For example:
-@smallexample
-@group
-@iftex
-@leftskip=0cm
-@end iftex
-error: elaboration circularity detected
-info:   "proc (body)" must be elaborated before "pack (body)"
-info:     reason: Elaborate_All probably needed in unit "pack (body)"
-info:     recompile "pack (body)" with -gnatwl
-info:                             for full details
-info:       "proc (body)"
-info:         is needed by its spec:
-info:       "proc (spec)"
-info:         which is withed by:
-info:       "pack (body)"
-info:  "pack (body)" must be elaborated before "proc (body)"
-info:     reason: pragma Elaborate in unit "proc (body)"
-@end group
+In GNAT, this standard mode can be achieved either by the use of
+the @option{-gnatE} switch on the compiler (@command{gcc} or
+@command{gnatmake}) command, or by the use of the configuration pragma:
 
+@smallexample @c ada
+pragma Elaboration_Checks (RM);
 @end smallexample
 
 @noindent
-In this case we have a cycle that the binder cannot break. On the one
-hand, there is an explicit pragma Elaborate in @code{proc} for
-@code{pack}. This means that the body of @code{pack} must be elaborated
-before the body of @code{proc}. On the other hand, there is elaboration
-code in @code{pack} that calls a subprogram in @code{proc}. This means
-that for maximum safety, there should really be a pragma
-Elaborate_All in @code{pack} for @code{proc} which would require that
-the body of @code{proc} be elaborated before the body of
-@code{pack}. Clearly both requirements cannot be satisfied.
-Faced with a circularity of this kind, you have three different options.
-
-@table @asis
-@item Fix the program
-The most desirable option from the point of view of long-term maintenance
-is to rearrange the program so that the elaboration problems are avoided.
-One useful technique is to place the elaboration code into separate
-child packages. Another is to move some of the initialization code to
-explicitly called subprograms, where the program controls the order
-of initialization explicitly. Although this is the most desirable option,
-it may be impractical and involve too much modification, especially in
-the case of complex legacy code.
+Either approach will cause the unit affected to be compiled using the
+standard dynamic run-time elaboration checks described in the Ada
+Reference Manual. The static model is generally preferable, since it
+is clearly safer to rely on compile and link time checks rather than
+run-time checks. However, in the case of legacy code, it may be
+difficult to meet the requirements of the static model. This
+issue is further discussed in
+@ref{What to Do If the Default Elaboration Behavior Fails}.
 
-@item Perform dynamic checks
-If the compilations are done using the
-@option{-gnatE}
-(dynamic elaboration check) switch, then GNAT behaves in
-a quite different manner. Dynamic checks are generated for all calls
-that could possibly result in raising an exception. With this switch,
-the compiler does not generate implicit @code{Elaborate_All} pragmas.
-The behavior then is exactly as specified in the Ada 95 Reference Manual.
-The binder will generate an executable program that may or may not
-raise @code{Program_Error}, and then it is the programmer's job to ensure
-that it does not raise an exception. Note that it is important to
-compile all units with the switch, it cannot be used selectively.
+Note that the static model provides a strict subset of the allowed
+behavior and programs of the Ada Reference Manual, so if you do
+adhere to the static model and no circularities exist,
+then you are assured that your program will
+work using the dynamic model, providing that you remove any
+pragma Elaborate statements from the source.
 
-@item Suppress checks
-The drawback of dynamic checks is that they generate a
-significant overhead at run time, both in space and time. If you
-are absolutely sure that your program cannot raise any elaboration
-exceptions, and you still want to use the dynamic elaboration model,
-then you can use the configuration pragma
-@code{Suppress (Elaboration_Check)} to suppress all such checks. For
-example this pragma could be placed in the @file{gnat.adc} file.
+@node Treatment of Pragma Elaborate
+@section Treatment of Pragma Elaborate
+@cindex Pragma Elaborate
 
-@item Suppress checks selectively
-When you know that certain calls in elaboration code cannot possibly
-lead to an elaboration error, and the binder nevertheless generates warnings
-on those calls and inserts Elaborate_All pragmas that lead to elaboration
-circularities, it is possible to remove those warnings locally and obtain
-a program that will bind. Clearly this can be unsafe, and it is the
-responsibility of the programmer to make sure that the resulting program has
-no elaboration anomalies. The pragma @code{Suppress (Elaboration_Check)} can
-be used with different granularity to suppress warnings and break
-elaboration circularities:
+@noindent
+The use of @code{pragma Elaborate}
+should generally be avoided in Ada 95 and Ada 2005 programs,
+since there is no guarantee that transitive calls
+will be properly handled. Indeed at one point, this pragma was placed
+in Annex J (Obsolescent Features), on the grounds that it is never useful.
 
-@itemize @bullet
-@item
-Place the pragma that names the called subprogram in the declarative part
-that contains the call.
+Now that's a bit restrictive. In practice, the case in which
+@code{pragma Elaborate} is useful is when the caller knows that there
+are no transitive calls, or that the called unit contains all necessary
+transitive @code{pragma Elaborate} statements, and legacy code often
+contains such uses.
 
-@item
-Place the pragma in the declarative part, without naming an entity. This
-disables warnings on all calls in the corresponding  declarative region.
+Strictly speaking the static mode in GNAT should ignore such pragmas,
+since there is no assurance at compile time that the necessary safety
+conditions are met. In practice, this would cause GNAT to be incompatible
+with correctly written Ada 83 code that had all necessary
+@code{pragma Elaborate} statements in place. Consequently, we made the
+decision that GNAT in its default mode will believe that if it encounters
+a @code{pragma Elaborate} then the programmer knows what they are doing,
+and it will trust that no elaboration errors can occur.
 
-@item
-Place the pragma in the package spec that declares the called subprogram,
-and name the subprogram. This disables warnings on all elaboration calls to
-that subprogram.
+The result of this decision is two-fold. First to be safe using the
+static mode, you should remove all @code{pragma Elaborate} statements.
+Second, when fixing circularities in existing code, you can selectively
+use @code{pragma Elaborate} statements to convince the static mode of
+GNAT that it need not generate an implicit @code{pragma Elaborate_All}
+statement.
 
-@item
-Place the pragma in the package spec that declares the called subprogram,
-without naming any entity. This disables warnings on all elaboration calls to
-all subprograms declared in this spec.
+When using the static mode with @option{-gnatwl}, any use of
+@code{pragma Elaborate} will generate a warning about possible
+problems.
 
-@item Use Pragma Elaborate
-As previously described in section @xref{Treatment of Pragma Elaborate},
-GNAT in static mode assumes that a @code{pragma} Elaborate indicates correctly
-that no elaboration checks are required on calls to the designated unit.
-There may be cases in which the caller knows that no transitive calls
-can occur, so that a @code{pragma Elaborate} will be sufficient in a
-case where @code{pragma Elaborate_All} would cause a circularity.
-@end itemize
+@node Elaboration Issues for Library Tasks
+@section Elaboration Issues for Library Tasks
+@cindex Library tasks, elaboration issues
+@cindex Elaboration of library tasks
 
 @noindent
-These five cases are listed in order of decreasing safety, and therefore
-require increasing programmer care in their application. Consider the
-following program:
+In this section we examine special elaboration issues that arise for
+programs that declare library level tasks.
 
-@smallexample @c adanocomment
-package Pack1 is
-  function F1 return Integer;
-  X1 : Integer;
-end Pack1;
+Generally the model of execution of an Ada program is that all units are
+elaborated, and then execution of the program starts. However, the
+declaration of library tasks definitely does not fit this model. The
+reason for this is that library tasks start as soon as they are declared
+(more precisely, as soon as the statement part of the enclosing package
+body is reached), that is to say before elaboration
+of the program is complete. This means that if such a task calls a
+subprogram, or an entry in another task, the callee may or may not be
+elaborated yet, and in the standard
+Reference Manual model of dynamic elaboration checks, you can even
+get timing dependent Program_Error exceptions, since there can be
+a race between the elaboration code and the task code.
 
-package Pack2 is
-  function F2 return Integer;
-  function Pure (x : integer) return integer;
-  --  pragma Suppress (Elaboration_Check, On => Pure);  -- (3)
-  --  pragma Suppress (Elaboration_Check);              -- (4)
-end Pack2;
+The static model of elaboration in GNAT seeks to avoid all such
+dynamic behavior, by being conservative, and the conservative
+approach in this particular case is to assume that all the code
+in a task body is potentially executed at elaboration time if
+a task is declared at the library level.
 
-with Pack2;
-package body Pack1 is
-  function F1 return Integer is
-  begin
-    return 100;
-  end F1;
-  Val : integer := Pack2.Pure (11);    --  Elab. call (1)
-begin
-  declare
-    --  pragma Suppress(Elaboration_Check, Pack2.F2);   -- (1)
-    --  pragma Suppress(Elaboration_Check);             -- (2)
+This can definitely result in unexpected circularities. Consider
+the following example
+
+@smallexample @c ada
+package Decls is
+  task Lib_Task is
+     entry Start;
+  end Lib_Task;
+
+  type My_Int is new Integer;
+
+  function Ident (M : My_Int) return My_Int;
+end Decls;
+
+with Utils;
+package body Decls is
+  task body Lib_Task is
   begin
-    X1 := Pack2.F2 + 1;                --  Elab. call (2)
-  end;
-end Pack1;
+     accept Start;
+     Utils.Put_Val (2);
+  end Lib_Task;
 
-with Pack1;
-package body Pack2 is
-  function F2 return Integer is
+  function Ident (M : My_Int) return My_Int is
   begin
-     return Pack1.F1;
-  end F2;
-  function Pure (x : integer) return integer is
+     return M;
+  end Ident;
+end Decls;
+
+with Decls;
+package Utils is
+  procedure Put_Val (Arg : Decls.My_Int);
+end Utils;
+
+with Text_IO;
+package body Utils is
+  procedure Put_Val (Arg : Decls.My_Int) is
   begin
-     return x ** 3 - 3 * x;
-  end;
-end Pack2;
+     Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg)));
+  end Put_Val;
+end Utils;
 
-with Pack1, Ada.Text_IO;
-procedure Proc3 is
+with Decls;
+procedure Main is
 begin
-  Ada.Text_IO.Put_Line(Pack1.X1'Img); -- 101
-end Proc3;
-@end smallexample
-In the absence of any pragmas, an attempt to bind this program produces
-the following diagnostics:
-@smallexample
-@group
-@iftex
-@leftskip=.5cm
-@end iftex
-error: elaboration circularity detected
-info:    "pack1 (body)" must be elaborated before "pack1 (body)"
-info:       reason: Elaborate_All probably needed in unit "pack1 (body)"
-info:       recompile "pack1 (body)" with -gnatwl for full details
-info:          "pack1 (body)"
-info:             must be elaborated along with its spec:
-info:          "pack1 (spec)"
-info:             which is withed by:
-info:          "pack2 (body)"
-info:             which must be elaborated along with its spec:
-info:          "pack2 (spec)"
-info:             which is withed by:
-info:          "pack1 (body)"
-@end group
+   Decls.Lib_Task.Start;
+end;
 @end smallexample
-The sources of the circularity are the two calls to @code{Pack2.Pure} and
-@code{Pack2.F2} in the body of @code{Pack1}. We can see that the call to
-F2 is safe, even though F2 calls F1, because the call appears after the
-elaboration of the body of F1. Therefore the pragma (1) is safe, and will
-remove the warning on the call. It is also possible to use pragma (2)
-because there are no other potentially unsafe calls in the block.
-
-@noindent
-The call to @code{Pure} is safe because this function does not depend on the
-state of @code{Pack2}. Therefore any call to this function is safe, and it
-is correct to place pragma (3) in the corresponding package spec.
-
-@noindent
-Finally, we could place pragma (4) in the spec of @code{Pack2} to disable
-warnings on all calls to functions declared therein. Note that this is not
-necessarily safe, and requires more detailed examination of the subprogram
-bodies involved. In particular, a call to @code{F2} requires that @code{F1}
-be already elaborated.
-@end table
 
 @noindent
-It is hard to generalize on which of these four approaches should be
-taken. Obviously if it is possible to fix the program so that the default
-treatment works, this is preferable, but this may not always be practical.
-It is certainly simple enough to use
-@option{-gnatE}
-but the danger in this case is that, even if the GNAT binder
-finds a correct elaboration order, it may not always do so,
-and certainly a binder from another Ada compiler might not. A
-combination of testing and analysis (for which the warnings generated
-with the
-@option{-gnatwl}
-switch can be useful) must be used to ensure that the program is free
-of errors. One switch that is useful in this testing is the
-@option{^-p (pessimistic elaboration order)^/PESSIMISTIC_ELABORATION_ORDER^}
-switch for
-@code{gnatbind}.
-Normally the binder tries to find an order that has the best chance of
-of avoiding elaboration problems. With this switch, the binder
-plays a devil's advocate role, and tries to choose the order that
-has the best chance of failing. If your program works even with this
-switch, then it has a better chance of being error free, but this is still
-not a guarantee.
-
-For an example of this approach in action, consider the C-tests (executable
-tests) from the ACVC suite. If these are compiled and run with the default
-treatment, then all but one of them succeed without generating any error
-diagnostics from the binder. However, there is one test that fails, and
-this is not surprising, because the whole point of this test is to ensure
-that the compiler can handle cases where it is impossible to determine
-a correct order statically, and it checks that an exception is indeed
-raised at run time.
-
-This one test must be compiled and run using the
-@option{-gnatE}
-switch, and then it passes. Alternatively, the entire suite can
-be run using this switch. It is never wrong to run with the dynamic
-elaboration switch if your code is correct, and we assume that the
-C-tests are indeed correct (it is less efficient, but efficiency is
-not a factor in running the ACVC tests.)
-
-@node Elaboration for Access-to-Subprogram Values
-@section Elaboration for Access-to-Subprogram Values
-@cindex Access-to-subprogram
+If the above example is compiled in the default static elaboration
+mode, then a circularity occurs. The circularity comes from the call
+@code{Utils.Put_Val} in the task body of @code{Decls.Lib_Task}. Since
+this call occurs in elaboration code, we need an implicit pragma
+@code{Elaborate_All} for @code{Utils}. This means that not only must
+the spec and body of @code{Utils} be elaborated before the body
+of @code{Decls}, but also the spec and body of any unit that is
+@code{with'ed} by the body of @code{Utils} must also be elaborated before
+the body of @code{Decls}. This is the transitive implication of
+pragma @code{Elaborate_All} and it makes sense, because in general
+the body of @code{Put_Val} might have a call to something in a
+@code{with'ed} unit.
 
-@noindent
-The introduction of access-to-subprogram types in Ada 95 complicates
-the handling of elaboration. The trouble is that it becomes
-impossible to tell at compile time which procedure
-is being called. This means that it is not possible for the binder
-to analyze the elaboration requirements in this case.
+In this case, the body of Utils (actually its spec) @code{with's}
+@code{Decls}. Unfortunately this means that the body of @code{Decls}
+must be elaborated before itself, in case there is a call from the
+body of @code{Utils}.
 
-If at the point at which the access value is created
-(i.e., the evaluation of @code{P'Access} for a subprogram @code{P}),
-the body of the subprogram is
-known to have been elaborated, then the access value is safe, and its use
-does not require a check. This may be achieved by appropriate arrangement
-of the order of declarations if the subprogram is in the current unit,
-or, if the subprogram is in another unit, by using pragma
-@code{Pure}, @code{Preelaborate}, or @code{Elaborate_Body}
-on the referenced unit.
+Here is the exact chain of events we are worrying about:
 
-If the referenced body is not known to have been elaborated at the point
-the access value is created, then any use of the access value must do a
-dynamic check, and this dynamic check will fail and raise a
-@code{Program_Error} exception if the body has not been elaborated yet.
-GNAT will generate the necessary checks, and in addition, if the
-@option{-gnatwl}
-switch is set, will generate warnings that such checks are required.
+@enumerate
+@item
+In the body of @code{Decls} a call is made from within the body of a library
+task to a subprogram in the package @code{Utils}. Since this call may
+occur at elaboration time (given that the task is activated at elaboration
+time), we have to assume the worst, i.e. that the
+call does happen at elaboration time.
 
-The use of dynamic dispatching for tagged types similarly generates
-a requirement for dynamic checks, and premature calls to any primitive
-operation of a tagged type before the body of the operation has been
-elaborated, will result in the raising of @code{Program_Error}.
+@item
+This means that the body and spec of @code{Util} must be elaborated before
+the body of @code{Decls} so that this call does not cause an access before
+elaboration.
 
-@node Summary of Procedures for Elaboration Control
-@section Summary of Procedures for Elaboration Control
-@cindex Elaboration control
+@item
+Within the body of @code{Util}, specifically within the body of
+@code{Util.Put_Val} there may be calls to any unit @code{with}'ed
+by this package.
 
-@noindent
-First, compile your program with the default options, using none of
-the special elaboration control switches. If the binder successfully
-binds your program, then you can be confident that, apart from issues
-raised by the use of access-to-subprogram types and dynamic dispatching,
-the program is free of elaboration errors. If it is important that the
-program be portable, then use the
-@option{-gnatwl}
-switch to generate warnings about missing @code{Elaborate_All}
-pragmas, and supply the missing pragmas.
+@item
+One such @code{with}'ed package is package @code{Decls}, so there
+might be a call to a subprogram in @code{Decls} in @code{Put_Val}.
+In fact there is such a call in this example, but we would have to
+assume that there was such a call even if it were not there, since
+we are not supposed to write the body of @code{Decls} knowing what
+is in the body of @code{Utils}; certainly in the case of the
+static elaboration model, the compiler does not know what is in
+other bodies and must assume the worst.
 
-If the program fails to bind using the default static elaboration
-handling, then you can fix the program to eliminate the binder
-message, or recompile the entire program with the
-@option{-gnatE} switch to generate dynamic elaboration checks,
-and, if you are sure there really are no elaboration problems,
-use a global pragma @code{Suppress (Elaboration_Check)}.
+@item
+This means that the spec and body of @code{Decls} must also be
+elaborated before we elaborate the unit containing the call, but
+that unit is @code{Decls}! This means that the body of @code{Decls}
+must be elaborated before itself, and that's a circularity.
+@end enumerate
 
-@node Other Elaboration Order Considerations
-@section Other Elaboration Order Considerations
 @noindent
-This section has been entirely concerned with the issue of finding a valid
-elaboration order, as defined by the Ada Reference Manual. In a case
-where several elaboration orders are valid, the task is to find one
-of the possible valid elaboration orders (and the static model in GNAT
-will ensure that this is achieved).
-
-The purpose of the elaboration rules in the Ada Reference Manual is to
-make sure that no entity is accessed before it has been elaborated. For
-a subprogram, this means that the spec and body must have been elaborated
-before the subprogram is called. For an object, this means that the object
-must have been elaborated before its value is read or written. A violation
-of either of these two requirements is an access before elaboration order,
-and this section has been all about avoiding such errors.
+Indeed, if you add an explicit pragma @code{Elaborate_All} for @code{Utils} in
+the body of @code{Decls} you will get a true Ada Reference Manual
+circularity that makes the program illegal.
 
-In the case where more than one order of elaboration is possible, in the
-sense that access before elaboration errors are avoided, then any one of
-the orders is ``correct'' in the sense that it meets the requirements of
-the Ada Reference Manual, and no such error occurs.
+In practice, we have found that problems with the static model of
+elaboration in existing code often arise from library tasks, so
+we must address this particular situation.
 
-However, it may be the case for a given program, that there are
-constraints on the order of elaboration that come not from consideration
-of avoiding elaboration errors, but rather from extra-lingual logic
-requirements. Consider this example:
+Note that if we compile and run the program above, using the dynamic model of
+elaboration (that is to say use the @option{-gnatE} switch),
+then it compiles, binds,
+links, and runs, printing the expected result of 2. Therefore in some sense
+the circularity here is only apparent, and we need to capture
+the properties of this program that  distinguish it from other library-level
+tasks that have real elaboration problems.
 
-@smallexample @c ada
-with Init_Constants;
-package Constants is
-   X : Integer := 0;
-   Y : Integer := 0;
-end Constants;
+We have four possible answers to this question:
 
-package Init_Constants is
-   procedure P; -- require a body
-end Init_Constants;
+@itemize @bullet
 
-with Constants;
-package body Init_Constants is
-   procedure P is begin null; end;
-begin
-   Constants.X := 3;
-   Constants.Y := 4;
-end Init_Constants;
+@item
+Use the dynamic model of elaboration.
 
-with Constants;
-package Calc is
-   Z : Integer := Constants.X + Constants.Y;
-end Calc;
+If we use the @option{-gnatE} switch, then as noted above, the program works.
+Why is this? If we examine the task body, it is apparent that the task cannot
+proceed past the
+@code{accept} statement until after elaboration has been completed, because
+the corresponding entry call comes from the main program, not earlier.
+This is why the dynamic model works here. But that's really giving
+up on a precise analysis, and we prefer to take this approach only if we cannot
+solve the
+problem in any other manner. So let us examine two ways to reorganize
+the program to avoid the potential elaboration problem.
 
-with Calc;
-with Text_IO; use Text_IO;
-procedure Main is
-begin
-   Put_Line (Calc.Z'Img);
-end Main;
-@end smallexample
+@item
+Split library tasks into separate packages.
 
-@noindent
-In this example, there is more than one valid order of elaboration. For
-example both the following are correct orders:
+Write separate packages, so that library tasks are isolated from
+other declarations as much as possible. Let us look at a variation on
+the above program.
 
-@smallexample
-Init_Constants spec
-Constants spec
-Calc spec
-Init_Constants body
-Main body
+@smallexample @c ada
+package Decls1 is
+  task Lib_Task is
+     entry Start;
+  end Lib_Task;
+end Decls1;
 
-  and
+with Utils;
+package body Decls1 is
+  task body Lib_Task is
+  begin
+     accept Start;
+     Utils.Put_Val (2);
+  end Lib_Task;
+end Decls1;
 
-Init_Constants spec
-Init_Constants body
-Constants spec
-Calc spec
-Main body
-@end smallexample
+package Decls2 is
+  type My_Int is new Integer;
+  function Ident (M : My_Int) return My_Int;
+end Decls2;
 
-@noindent
-There is no language rule to prefer one or the other, both are correct
-from an order of elaboration point of view. But the programmatic effects
-of the two orders are very different. In the first, the elaboration routine
-of @code{Calc} initializes @code{Z} to zero, and then the main program
-runs with this value of zero. But in the second order, the elaboration
-routine of @code{Calc} runs after the body of Init_Constants has set
-@code{X} and @code{Y} and thus @code{Z} is set to 7 before @code{Main}
-runs.
+with Utils;
+package body Decls2 is
+  function Ident (M : My_Int) return My_Int is
+  begin
+     return M;
+  end Ident;
+end Decls2;
 
-One could perhaps by applying pretty clever non-artificial intelligence
-to the situation guess that it is more likely that the second order of
-elaboration is the one desired, but there is no formal linguistic reason
-to prefer one over the other. In fact in this particular case, GNAT will
-prefer the second order, because of the rule that bodies are elaborated
-as soon as possible, but it's just luck that this is what was wanted
-(if indeed the second order was preferred).
+with Decls2;
+package Utils is
+  procedure Put_Val (Arg : Decls2.My_Int);
+end Utils;
 
-If the program cares about the order of elaboration routines in a case like
-this, it is important to specify the order required. In this particular
-case, that could have been achieved by adding to the spec of Calc:
+with Text_IO;
+package body Utils is
+  procedure Put_Val (Arg : Decls2.My_Int) is
+  begin
+     Text_IO.Put_Line (Decls2.My_Int'Image (Decls2.Ident (Arg)));
+  end Put_Val;
+end Utils;
 
-@smallexample @c ada
-pragma Elaborate_All (Constants);
+with Decls1;
+procedure Main is
+begin
+   Decls1.Lib_Task.Start;
+end;
 @end smallexample
 
 @noindent
-which requires that the body (if any) and spec of @code{Constants},
-as well as the body and spec of any unit @code{with}'ed by
-@code{Constants} be elaborated before @code{Calc} is elaborated.
+All we have done is to split @code{Decls} into two packages, one
+containing the library task, and one containing everything else. Now
+there is no cycle, and the program compiles, binds, links and executes
+using the default static model of elaboration.
 
-Clearly no automatic method can always guess which alternative you require,
-and if you are working with legacy code that had constraints of this kind
-which were not properly specified by adding @code{Elaborate} or
-@code{Elaborate_All} pragmas, then indeed it is possible that two different
-compilers can choose different orders.
+@item
+Declare separate task types.
 
-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
-instead of as early as possible. In the example above, it would have forced
-the choice of the first elaboration order. If you get different results
-when using this switch, and particularly if one set of results is right,
-and one is wrong as far as you are concerned, it shows that you have some
-missing @code{Elaborate} pragmas. For the example above, we have the
-following output:
+A significant part of the problem arises because of the use of the
+single task declaration form. This means that the elaboration of
+the task type, and the elaboration of the task itself (i.e. the
+creation of the task) happen at the same time. A good rule
+of style in Ada is to always create explicit task types. By
+following the additional step of placing task objects in separate
+packages from the task type declaration, many elaboration problems
+are avoided. Here is another modified example of the example program:
 
-@smallexample
-gnatmake -f -q main
-main
- 7
-gnatmake -f -q main -bargs -p
-main
- 0
-@end smallexample
+@smallexample @c ada
+package Decls is
+  task type Lib_Task_Type is
+     entry Start;
+  end Lib_Task_Type;
 
-@noindent
-It is of course quite unlikely that both these results are correct, so
-it is up to you in a case like this to investigate the source of the
-difference, by looking at the two elaboration orders that are chosen,
-and figuring out which is correct, and then adding the necessary
-@code{Elaborate_All} pragmas to ensure the desired order.
+  type My_Int is new Integer;
 
+  function Ident (M : My_Int) return My_Int;
+end Decls;
 
-@node Inline Assembler
-@appendix Inline Assembler
+with Utils;
+package body Decls is
+  task body Lib_Task_Type is
+  begin
+     accept Start;
+     Utils.Put_Val (2);
+  end Lib_Task_Type;
 
-@noindent
-If you need to write low-level software that interacts directly
-with the hardware, Ada provides two ways to incorporate assembly
-language code into your program.  First, you can import and invoke
-external routines written in assembly language, an Ada feature fully
-supported by GNAT.  However, for small sections of code it may be simpler
-or more efficient to include assembly language statements directly
-in your Ada source program, using the facilities of the implementation-defined
-package @code{System.Machine_Code}, which incorporates the gcc
-Inline Assembler.  The Inline Assembler approach offers a number of advantages,
-including the following:
+  function Ident (M : My_Int) return My_Int is
+  begin
+     return M;
+  end Ident;
+end Decls;
 
-@itemize @bullet
-@item No need to use non-Ada tools
-@item Consistent interface over different targets
-@item Automatic usage of the proper calling conventions
-@item Access to Ada constants and variables
-@item Definition of intrinsic routines
-@item Possibility of inlining a subprogram comprising assembler code
-@item Code optimizer can take Inline Assembler code into account
-@end itemize
+with Decls;
+package Utils is
+  procedure Put_Val (Arg : Decls.My_Int);
+end Utils;
 
-This chapter presents a series of examples to show you how to use
-the Inline Assembler.  Although it focuses on the Intel x86,
-the general approach applies also to other processors.
-It is assumed that you are familiar with Ada
-and with assembly language programming.
+with Text_IO;
+package body Utils is
+  procedure Put_Val (Arg : Decls.My_Int) is
+  begin
+     Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg)));
+  end Put_Val;
+end Utils;
 
-@menu
-* Basic Assembler Syntax::
-* A Simple Example of Inline Assembler::
-* Output Variables in Inline Assembler::
-* Input Variables in Inline Assembler::
-* Inlining Inline Assembler Code::
-* Other Asm Functionality::
-* A Complete Example::
-@end menu
+with Decls;
+package Declst is
+   Lib_Task : Decls.Lib_Task_Type;
+end Declst;
 
-@c ---------------------------------------------------------------------------
-@node Basic Assembler Syntax
-@section Basic Assembler Syntax
+with Declst;
+procedure Main is
+begin
+   Declst.Lib_Task.Start;
+end;
+@end smallexample
 
 @noindent
-The assembler used by GNAT and gcc is based not on the Intel assembly
-language, but rather on a language that descends from the AT&T Unix
-assembler @emph{as} (and which is often referred to as ``AT&T syntax'').
-The following table summarizes the main features of @emph{as} syntax
-and points out the differences from the Intel conventions.
-See the gcc @emph{as} and @emph{gas} (an @emph{as} macro
-pre-processor) documentation for further information.
-
-@table @asis
-@item Register names
-gcc / @emph{as}: Prefix with ``%''; for example @code{%eax}
-@*
-Intel: No extra punctuation; for example @code{eax}
+What we have done here is to replace the @code{task} declaration in
+package @code{Decls} with a @code{task type} declaration. Then we
+introduce a separate package @code{Declst} to contain the actual
+task object. This separates the elaboration issues for
+the @code{task type}
+declaration, which causes no trouble, from the elaboration issues
+of the task object, which is also unproblematic, since it is now independent
+of the elaboration of  @code{Utils}.
+This separation of concerns also corresponds to
+a generally sound engineering principle of separating declarations
+from instances. This version of the program also compiles, binds, links,
+and executes, generating the expected output.
 
-@item Immediate operand
-gcc / @emph{as}: Prefix with ``$''; for example @code{$4}
-@*
-Intel: No extra punctuation; for example @code{4}
+@item
+Use No_Entry_Calls_In_Elaboration_Code restriction.
+@cindex No_Entry_Calls_In_Elaboration_Code
 
-@item Address
-gcc / @emph{as}: Prefix with ``$''; for example @code{$loc}
-@*
-Intel: No extra punctuation; for example @code{loc}
+The previous two approaches described how a program can be restructured
+to avoid the special problems caused by library task bodies. in practice,
+however, such restructuring may be difficult to apply to existing legacy code,
+so we must consider solutions that do not require massive rewriting.
 
-@item Memory contents
-gcc / @emph{as}: No extra punctuation; for example @code{loc}
-@*
-Intel: Square brackets; for example @code{[loc]}
+Let us consider more carefully why our original sample program works
+under the dynamic model of elaboration. The reason is that the code
+in the task body blocks immediately on the @code{accept}
+statement. Now of course there is nothing to prohibit elaboration
+code from making entry calls (for example from another library level task),
+so we cannot tell in isolation that
+the task will not execute the accept statement  during elaboration.
 
-@item Register contents
-gcc / @emph{as}: Parentheses; for example @code{(%eax)}
-@*
-Intel: Square brackets; for example @code{[eax]}
+However, in practice it is very unusual to see elaboration code
+make any entry calls, and the pattern of tasks starting
+at elaboration time and then immediately blocking on @code{accept} or
+@code{select} statements is very common. What this means is that
+the compiler is being too pessimistic when it analyzes the
+whole package body as though it might be executed at elaboration
+time.
 
-@item Hexadecimal numbers
-gcc / @emph{as}: Leading ``0x'' (C language syntax); for example @code{0xA0}
-@*
-Intel: Trailing ``h''; for example @code{A0h}
+If we know that the elaboration code contains no entry calls, (a very safe
+assumption most of the time, that could almost be made the default
+behavior), then we can compile all units of the program under control
+of the following configuration pragma:
 
-@item Operand size
-gcc / @emph{as}: Explicit in op code; for example @code{movw} to move
-a 16-bit word
-@*
-Intel: Implicit, deduced by assembler; for example @code{mov}
+@smallexample
+pragma Restrictions (No_Entry_Calls_In_Elaboration_Code);
+@end smallexample
 
-@item Instruction repetition
-gcc / @emph{as}: Split into two lines; for example
-@*
-@code{rep}
-@*
-@code{stosl}
-@*
-Intel: Keep on one line; for example @code{rep stosl}
+@noindent
+This pragma can be placed in the @file{gnat.adc} file in the usual
+manner. If we take our original unmodified program and compile it
+in the presence of a @file{gnat.adc} containing the above pragma,
+then once again, we can compile, bind, link, and execute, obtaining
+the expected result. In the presence of this pragma, the compiler does
+not trace calls in a task body, that appear after the first @code{accept}
+or @code{select} statement, and therefore does not report a potential
+circularity in the original program.
 
-@item Order of operands
-gcc / @emph{as}: Source first; for example @code{movw $4, %eax}
-@*
-Intel: Destination first; for example @code{mov eax, 4}
-@end table
+The compiler will check to the extent it can that the above
+restriction is not violated, but it is not always possible to do a
+complete check at compile time, so it is important to use this
+pragma only if the stated restriction is in fact met, that is to say
+no task receives an entry call before elaboration of all units is completed.
 
-@c ---------------------------------------------------------------------------
-@node A Simple Example of Inline Assembler
-@section A Simple Example of Inline Assembler
+@end itemize
 
+@node Mixing Elaboration Models
+@section Mixing Elaboration Models
 @noindent
-The following example will generate a single assembly language statement,
-@code{nop}, which does nothing.  Despite its lack of run-time effect,
-the example will be useful in illustrating the basics of
-the Inline Assembler facility.
-
-@smallexample @c ada
-@group
-with System.Machine_Code; use System.Machine_Code;
-procedure Nothing is
-begin
-   Asm ("nop");
-end Nothing;
-@end group
-@end smallexample
+So far, we have assumed that the entire program is either compiled
+using the dynamic model or static model, ensuring consistency. It
+is possible to mix the two models, but rules have to be followed
+if this mixing is done to ensure that elaboration checks are not
+omitted.
 
-@code{Asm} is a procedure declared in package @code{System.Machine_Code};
-here it takes one parameter, a @emph{template string} that must be a static
-expression and that will form the generated instruction.
-@code{Asm} may be regarded as a compile-time procedure that parses
-the template string and additional parameters (none here),
-from which it generates a sequence of assembly language instructions.
+The basic rule is that @emph{a unit compiled with the static model cannot
+be @code{with'ed} by a unit compiled with the dynamic model}. The
+reason for this is that in the static model, a unit assumes that
+its clients guarantee to use (the equivalent of) pragma
+@code{Elaborate_All} so that no elaboration checks are required
+in inner subprograms, and this assumption is violated if the
+client is compiled with dynamic checks.
 
-The examples in this chapter will illustrate several of the forms
-for invoking @code{Asm}; a complete specification of the syntax
-is found in the @cite{GNAT Reference Manual}.
+The precise rule is as follows. A unit that is compiled with dynamic
+checks can only @code{with} a unit that meets at least one of the
+following criteria:
 
-Under the standard GNAT conventions, the @code{Nothing} procedure
-should be in a file named @file{nothing.adb}.
-You can build the executable in the usual way:
-@smallexample
-gnatmake nothing
-@end smallexample
-However, the interesting aspect of this example is not its run-time behavior
-but rather the generated assembly code.
-To see this output, invoke the compiler as follows:
-@smallexample
-   gcc -c -S -fomit-frame-pointer -gnatp @file{nothing.adb}
-@end smallexample
-where the options are:
+@itemize @bullet
 
-@table @code
-@item -c
-compile only (no bind or link)
-@item -S
-generate assembler listing
-@item -fomit-frame-pointer
-do not set up separate stack frames
-@item -gnatp
-do not add runtime checks
-@end table
+@item
+The @code{with'ed} unit is itself compiled with dynamic elaboration
+checks (that is with the @option{-gnatE} switch.
 
-This gives a human-readable assembler version of the code. The resulting
-file will have the same name as the Ada source file, but with a @code{.s}
-extension. In our example, the file @file{nothing.s} has the following
-contents:
+@item
+The @code{with'ed} unit is an internal GNAT implementation unit from
+the System, Interfaces, Ada, or GNAT hierarchies.
 
-@smallexample
-@group
-.file "nothing.adb"
-gcc2_compiled.:
-___gnu_compiled_ada:
-.text
-   .align 4
-.globl __ada_nothing
-__ada_nothing:
-#APP
-   nop
-#NO_APP
-   jmp L1
-   .align 2,0x90
-L1:
-   ret
-@end group
-@end smallexample
+@item
+The @code{with'ed} unit has pragma Preelaborate or pragma Pure.
 
-The assembly code you included is clearly indicated by
-the compiler, between the @code{#APP} and @code{#NO_APP}
-delimiters. The character before the 'APP' and 'NOAPP'
-can differ on different targets. For example, GNU/Linux uses '#APP' while
-on NT you will see '/APP'.
+@item
+The @code{with'ing} unit (that is the client) has an explicit pragma
+@code{Elaborate_All} for the @code{with'ed} unit.
 
-If you make a mistake in your assembler code (such as using the
-wrong size modifier, or using a wrong operand for the instruction) GNAT
-will report this error in a temporary file, which will be deleted when
-the compilation is finished.  Generating an assembler file will help
-in such cases, since you can assemble this file separately using the
-@emph{as} assembler that comes with gcc.
+@end itemize
 
-Assembling the file using the command
+@noindent
+If this rule is violated, that is if a unit with dynamic elaboration
+checks @code{with's} a unit that does not meet one of the above four
+criteria, then the binder (@code{gnatbind}) will issue a warning
+similar to that in the following example:
 
 @smallexample
-as @file{nothing.s}
+warning: "x.ads" has dynamic elaboration checks and with's
+warning:   "y.ads" which has static elaboration checks
 @end smallexample
-@noindent
-will give you error messages whose lines correspond to the assembler
-input file, so you can easily find and correct any mistakes you made.
-If there are no errors, @emph{as} will generate an object file
-@file{nothing.out}.
-
-@c ---------------------------------------------------------------------------
-@node Output Variables in Inline Assembler
-@section Output Variables in Inline Assembler
 
 @noindent
-The examples in this section, showing how to access the processor flags,
-illustrate how to specify the destination operands for assembly language
-statements.
+These warnings indicate that the rule has been violated, and that as a result
+elaboration checks may be missed in the resulting executable file.
+This warning may be suppressed using the @option{-ws} binder switch
+in the usual manner.
 
-@smallexample @c ada
-@group
-with Interfaces; use Interfaces;
-with Ada.Text_IO; use Ada.Text_IO;
-with System.Machine_Code; use System.Machine_Code;
-procedure Get_Flags is
-   Flags : Unsigned_32;
-   use ASCII;
-begin
-   Asm ("pushfl"          & LF & HT & -- push flags on stack
-        "popl %%eax"      & LF & HT & -- load eax with flags
-        "movl %%eax, %0",             -- store flags in variable
-        Outputs => Unsigned_32'Asm_Output ("=g", Flags));
-   Put_Line ("Flags register:" & Flags'Img);
-end Get_Flags;
-@end group
-@end smallexample
+One useful application of this mixing rule is in the case of a subsystem
+which does not itself @code{with} units from the remainder of the
+application. In this case, the entire subsystem can be compiled with
+dynamic checks to resolve a circularity in the subsystem, while
+allowing the main application that uses this subsystem to be compiled
+using the more reliable default static model.
 
-In order to have a nicely aligned assembly listing, we have separated
-multiple assembler statements in the Asm template string with linefeed
-(ASCII.LF) and horizontal tab (ASCII.HT) characters.
-The resulting section of the assembly output file is:
+@node What to Do If the Default Elaboration Behavior Fails
+@section What to Do If the Default Elaboration Behavior Fails
 
+@noindent
+If the binder cannot find an acceptable order, it outputs detailed
+diagnostics. For example:
 @smallexample
 @group
-#APP
-   pushfl
-   popl %eax
-   movl %eax, -40(%ebp)
-#NO_APP
+@iftex
+@leftskip=0cm
+@end iftex
+error: elaboration circularity detected
+info:   "proc (body)" must be elaborated before "pack (body)"
+info:     reason: Elaborate_All probably needed in unit "pack (body)"
+info:     recompile "pack (body)" with -gnatwl
+info:                             for full details
+info:       "proc (body)"
+info:         is needed by its spec:
+info:       "proc (spec)"
+info:         which is withed by:
+info:       "pack (body)"
+info:  "pack (body)" must be elaborated before "proc (body)"
+info:     reason: pragma Elaborate in unit "proc (body)"
 @end group
-@end smallexample
-
-It would have been legal to write the Asm invocation as:
 
-@smallexample
-Asm ("pushfl popl %%eax movl %%eax, %0")
 @end smallexample
 
-but in the generated assembler file, this would come out as:
-
-@smallexample
-#APP
-   pushfl popl %eax movl %eax, -40(%ebp)
-#NO_APP
-@end smallexample
+@noindent
+In this case we have a cycle that the binder cannot break. On the one
+hand, there is an explicit pragma Elaborate in @code{proc} for
+@code{pack}. This means that the body of @code{pack} must be elaborated
+before the body of @code{proc}. On the other hand, there is elaboration
+code in @code{pack} that calls a subprogram in @code{proc}. This means
+that for maximum safety, there should really be a pragma
+Elaborate_All in @code{pack} for @code{proc} which would require that
+the body of @code{proc} be elaborated before the body of
+@code{pack}. Clearly both requirements cannot be satisfied.
+Faced with a circularity of this kind, you have three different options.
 
-which is not so convenient for the human reader.
+@table @asis
+@item Fix the program
+The most desirable option from the point of view of long-term maintenance
+is to rearrange the program so that the elaboration problems are avoided.
+One useful technique is to place the elaboration code into separate
+child packages. Another is to move some of the initialization code to
+explicitly called subprograms, where the program controls the order
+of initialization explicitly. Although this is the most desirable option,
+it may be impractical and involve too much modification, especially in
+the case of complex legacy code.
 
-We use Ada comments
-at the end of each line to explain what the assembler instructions
-actually do.  This is a useful convention.
+@item Perform dynamic checks
+If the compilations are done using the
+@option{-gnatE}
+(dynamic elaboration check) switch, then GNAT behaves in a quite different
+manner. Dynamic checks are generated for all calls that could possibly result
+in raising an exception. With this switch, the compiler does not generate
+implicit @code{Elaborate} or @code{Elaborate_All} pragmas. The behavior then is
+exactly as specified in the @cite{Ada Reference Manual}.
+The binder will generate
+an executable program that may or may not raise @code{Program_Error}, and then
+it is the programmer's job to ensure that it does not raise an exception. Note
+that it is important to compile all units with the switch, it cannot be used
+selectively.
 
-When writing Inline Assembler instructions, you need to precede each register
-and variable name with a percent sign.  Since the assembler already requires
-a percent sign at the beginning of a register name, you need two consecutive
-percent signs for such names in the Asm template string, thus @code{%%eax}.
-In the generated assembly code, one of the percent signs will be stripped off.
+@item Suppress checks
+The drawback of dynamic checks is that they generate a
+significant overhead at run time, both in space and time. If you
+are absolutely sure that your program cannot raise any elaboration
+exceptions, and you still want to use the dynamic elaboration model,
+then you can use the configuration pragma
+@code{Suppress (Elaboration_Check)} to suppress all such checks. For
+example this pragma could be placed in the @file{gnat.adc} file.
 
-Names such as @code{%0}, @code{%1}, @code{%2}, etc., denote input or output
-variables: operands you later define using @code{Input} or @code{Output}
-parameters to @code{Asm}.
-An output variable is illustrated in
-the third statement in the Asm template string:
-@smallexample
-movl %%eax, %0
-@end smallexample
-The intent is to store the contents of the eax register in a variable that can
-be accessed in Ada.  Simply writing @code{movl %%eax, Flags} would not
-necessarily work, since the compiler might optimize by using a register
-to hold Flags, and the expansion of the @code{movl} instruction would not be
-aware of this optimization.  The solution is not to store the result directly
-but rather to advise the compiler to choose the correct operand form;
-that is the purpose of the @code{%0} output variable.
+@item Suppress checks selectively
+When you know that certain calls or instantiations in elaboration code cannot
+possibly lead to an elaboration error, and the binder nevertheless complains
+about implicit @code{Elaborate} and @code{Elaborate_All} pragmas that lead to
+elaboration circularities, it is possible to remove those warnings locally and
+obtain a program that will bind. Clearly this can be unsafe, and it is the
+responsibility of the programmer to make sure that the resulting program has no
+elaboration anomalies. The pragma @code{Suppress (Elaboration_Check)} can be
+used with different granularity to suppress warnings and break elaboration
+circularities:
 
-Information about the output variable is supplied in the @code{Outputs}
-parameter to @code{Asm}:
-@smallexample
-Outputs => Unsigned_32'Asm_Output ("=g", Flags));
-@end smallexample
+@itemize @bullet
+@item
+Place the pragma that names the called subprogram in the declarative part
+that contains the call.
 
-The output is defined by the @code{Asm_Output} attribute of the target type;
-the general format is
-@smallexample
-Type'Asm_Output (constraint_string, variable_name)
-@end smallexample
+@item
+Place the pragma in the declarative part, without naming an entity. This
+disables warnings on all calls in the corresponding  declarative region.
 
-The constraint string directs the compiler how
-to store/access the associated variable.  In the example
-@smallexample
-Unsigned_32'Asm_Output ("=m", Flags);
-@end smallexample
-the @code{"m"} (memory) constraint tells the compiler that the variable
-@code{Flags} should be stored in a memory variable, thus preventing
-the optimizer from keeping it in a register.  In contrast,
-@smallexample
-Unsigned_32'Asm_Output ("=r", Flags);
-@end smallexample
-uses the @code{"r"} (register) constraint, telling the compiler to
-store the variable in a register.
+@item
+Place the pragma in the package spec that declares the called subprogram,
+and name the subprogram. This disables warnings on all elaboration calls to
+that subprogram.
 
-If the constraint is preceded by the equal character (@strong{=}), it tells
-the compiler that the variable will be used to store data into it.
+@item
+Place the pragma in the package spec that declares the called subprogram,
+without naming any entity. This disables warnings on all elaboration calls to
+all subprograms declared in this spec.
 
-In the @code{Get_Flags} example, we used the @code{"g"} (global) constraint,
-allowing the optimizer to choose whatever it deems best.
+@item Use Pragma Elaborate
+As previously described in section @xref{Treatment of Pragma Elaborate},
+GNAT in static mode assumes that a @code{pragma} Elaborate indicates correctly
+that no elaboration checks are required on calls to the designated unit.
+There may be cases in which the caller knows that no transitive calls
+can occur, so that a @code{pragma Elaborate} will be sufficient in a
+case where @code{pragma Elaborate_All} would cause a circularity.
+@end itemize
 
-There are a fairly large number of constraints, but the ones that are
-most useful (for the Intel x86 processor) are the following:
+@noindent
+These five cases are listed in order of decreasing safety, and therefore
+require increasing programmer care in their application. Consider the
+following program:
 
-@table @code
-@item =
-output constraint
-@item g
-global (i.e. can be stored anywhere)
-@item m
-in memory
-@item I
-a constant
-@item a
-use eax
-@item b
-use ebx
-@item c
-use ecx
-@item d
-use edx
-@item S
-use esi
-@item D
-use edi
-@item r
-use one of eax, ebx, ecx or edx
-@item q
-use one of eax, ebx, ecx, edx, esi or edi
-@end table
+@smallexample @c adanocomment
+package Pack1 is
+  function F1 return Integer;
+  X1 : Integer;
+end Pack1;
 
-The full set of constraints is described in the gcc and @emph{as}
-documentation; note that it is possible to combine certain constraints
-in one constraint string.
+package Pack2 is
+  function F2 return Integer;
+  function Pure (x : integer) return integer;
+  --  pragma Suppress (Elaboration_Check, On => Pure);  -- (3)
+  --  pragma Suppress (Elaboration_Check);              -- (4)
+end Pack2;
 
-You specify the association of an output variable with an assembler operand
-through the @code{%}@emph{n} notation, where @emph{n} is a non-negative
-integer.  Thus in
-@smallexample @c ada
-@group
-Asm ("pushfl"          & LF & HT & -- push flags on stack
-     "popl %%eax"      & LF & HT & -- load eax with flags
-     "movl %%eax, %0",             -- store flags in variable
-     Outputs => Unsigned_32'Asm_Output ("=g", Flags));
-@end group
-@end smallexample
-@noindent
-@code{%0} will be replaced in the expanded code by the appropriate operand,
-whatever
-the compiler decided for the @code{Flags} variable.
+with Pack2;
+package body Pack1 is
+  function F1 return Integer is
+  begin
+    return 100;
+  end F1;
+  Val : integer := Pack2.Pure (11);    --  Elab. call (1)
+begin
+  declare
+    --  pragma Suppress(Elaboration_Check, Pack2.F2);   -- (1)
+    --  pragma Suppress(Elaboration_Check);             -- (2)
+  begin
+    X1 := Pack2.F2 + 1;                --  Elab. call (2)
+  end;
+end Pack1;
 
-In general, you may have any number of output variables:
-@itemize @bullet
-@item
-Count the operands starting at 0; thus @code{%0}, @code{%1}, etc.
-@item
-Specify the @code{Outputs} parameter as a parenthesized comma-separated list
-of @code{Asm_Output} attributes
-@end itemize
+with Pack1;
+package body Pack2 is
+  function F2 return Integer is
+  begin
+     return Pack1.F1;
+  end F2;
+  function Pure (x : integer) return integer is
+  begin
+     return x ** 3 - 3 * x;
+  end;
+end Pack2;
 
-For example:
-@smallexample @c ada
+with Pack1, Ada.Text_IO;
+procedure Proc3 is
+begin
+  Ada.Text_IO.Put_Line(Pack1.X1'Img); -- 101
+end Proc3;
+@end smallexample
+In the absence of any pragmas, an attempt to bind this program produces
+the following diagnostics:
+@smallexample
 @group
-Asm ("movl %%eax, %0" & LF & HT &
-     "movl %%ebx, %1" & LF & HT &
-     "movl %%ecx, %2",
-     Outputs => (Unsigned_32'Asm_Output ("=g", Var_A),   --  %0 = Var_A
-                 Unsigned_32'Asm_Output ("=g", Var_B),   --  %1 = Var_B
-                 Unsigned_32'Asm_Output ("=g", Var_C))); --  %2 = Var_C
+@iftex
+@leftskip=.5cm
+@end iftex
+error: elaboration circularity detected
+info:    "pack1 (body)" must be elaborated before "pack1 (body)"
+info:       reason: Elaborate_All probably needed in unit "pack1 (body)"
+info:       recompile "pack1 (body)" with -gnatwl for full details
+info:          "pack1 (body)"
+info:             must be elaborated along with its spec:
+info:          "pack1 (spec)"
+info:             which is withed by:
+info:          "pack2 (body)"
+info:             which must be elaborated along with its spec:
+info:          "pack2 (spec)"
+info:             which is withed by:
+info:          "pack1 (body)"
 @end group
 @end smallexample
-@noindent
-where @code{Var_A}, @code{Var_B}, and @code{Var_C} are variables
-in the Ada program.
+The sources of the circularity are the two calls to @code{Pack2.Pure} and
+@code{Pack2.F2} in the body of @code{Pack1}. We can see that the call to
+F2 is safe, even though F2 calls F1, because the call appears after the
+elaboration of the body of F1. Therefore the pragma (1) is safe, and will
+remove the warning on the call. It is also possible to use pragma (2)
+because there are no other potentially unsafe calls in the block.
 
-As a variation on the @code{Get_Flags} example, we can use the constraints
-string to direct the compiler to store the eax register into the @code{Flags}
-variable, instead of including the store instruction explicitly in the
-@code{Asm} template string:
+@noindent
+The call to @code{Pure} is safe because this function does not depend on the
+state of @code{Pack2}. Therefore any call to this function is safe, and it
+is correct to place pragma (3) in the corresponding package spec.
 
-@smallexample @c ada
-@group
-with Interfaces; use Interfaces;
-with Ada.Text_IO; use Ada.Text_IO;
-with System.Machine_Code; use System.Machine_Code;
-procedure Get_Flags_2 is
-   Flags : Unsigned_32;
-   use ASCII;
-begin
-   Asm ("pushfl"      & LF & HT & -- push flags on stack
-        "popl %%eax",             -- save flags in eax
-        Outputs => Unsigned_32'Asm_Output ("=a", Flags));
-   Put_Line ("Flags register:" & Flags'Img);
-end Get_Flags_2;
-@end group
-@end smallexample
+@noindent
+Finally, we could place pragma (4) in the spec of @code{Pack2} to disable
+warnings on all calls to functions declared therein. Note that this is not
+necessarily safe, and requires more detailed examination of the subprogram
+bodies involved. In particular, a call to @code{F2} requires that @code{F1}
+be already elaborated.
+@end table
 
 @noindent
-The @code{"a"} constraint tells the compiler that the @code{Flags}
-variable will come from the eax register. Here is the resulting code:
+It is hard to generalize on which of these four approaches should be
+taken. Obviously if it is possible to fix the program so that the default
+treatment works, this is preferable, but this may not always be practical.
+It is certainly simple enough to use
+@option{-gnatE}
+but the danger in this case is that, even if the GNAT binder
+finds a correct elaboration order, it may not always do so,
+and certainly a binder from another Ada compiler might not. A
+combination of testing and analysis (for which the warnings generated
+with the
+@option{-gnatwl}
+switch can be useful) must be used to ensure that the program is free
+of errors. One switch that is useful in this testing is the
+@option{^-p (pessimistic elaboration order)^/PESSIMISTIC_ELABORATION_ORDER^}
+switch for
+@code{gnatbind}.
+Normally the binder tries to find an order that has the best chance
+of avoiding elaboration problems. However, if this switch is used, the binder
+plays a devil's advocate role, and tries to choose the order that
+has the best chance of failing. If your program works even with this
+switch, then it has a better chance of being error free, but this is still
+not a guarantee.
 
-@smallexample
-@group
-#APP
-   pushfl
-   popl %eax
-#NO_APP
-   movl %eax,-40(%ebp)
-@end group
-@end smallexample
+For an example of this approach in action, consider the C-tests (executable
+tests) from the ACVC suite. If these are compiled and run with the default
+treatment, then all but one of them succeed without generating any error
+diagnostics from the binder. However, there is one test that fails, and
+this is not surprising, because the whole point of this test is to ensure
+that the compiler can handle cases where it is impossible to determine
+a correct order statically, and it checks that an exception is indeed
+raised at run time.
+
+This one test must be compiled and run using the
+@option{-gnatE}
+switch, and then it passes. Alternatively, the entire suite can
+be run using this switch. It is never wrong to run with the dynamic
+elaboration switch if your code is correct, and we assume that the
+C-tests are indeed correct (it is less efficient, but efficiency is
+not a factor in running the ACVC tests.)
+
+@node Elaboration for Access-to-Subprogram Values
+@section Elaboration for Access-to-Subprogram Values
+@cindex Access-to-subprogram
 
 @noindent
-The compiler generated the store of eax into Flags after
-expanding the assembler code.
+Access-to-subprogram types (introduced in Ada 95) complicate
+the handling of elaboration. The trouble is that it becomes
+impossible to tell at compile time which procedure
+is being called. This means that it is not possible for the binder
+to analyze the elaboration requirements in this case.
 
-Actually, there was no need to pop the flags into the eax register;
-more simply, we could just pop the flags directly into the program variable:
+If at the point at which the access value is created
+(i.e., the evaluation of @code{P'Access} for a subprogram @code{P}),
+the body of the subprogram is
+known to have been elaborated, then the access value is safe, and its use
+does not require a check. This may be achieved by appropriate arrangement
+of the order of declarations if the subprogram is in the current unit,
+or, if the subprogram is in another unit, by using pragma
+@code{Pure}, @code{Preelaborate}, or @code{Elaborate_Body}
+on the referenced unit.
 
-@smallexample @c ada
-@group
-with Interfaces; use Interfaces;
-with Ada.Text_IO; use Ada.Text_IO;
-with System.Machine_Code; use System.Machine_Code;
-procedure Get_Flags_3 is
-   Flags : Unsigned_32;
-   use ASCII;
-begin
-   Asm ("pushfl"  & LF & HT & -- push flags on stack
-        "pop %0",             -- save flags in Flags
-        Outputs => Unsigned_32'Asm_Output ("=g", Flags));
-   Put_Line ("Flags register:" & Flags'Img);
-end Get_Flags_3;
-@end group
-@end smallexample
+If the referenced body is not known to have been elaborated at the point
+the access value is created, then any use of the access value must do a
+dynamic check, and this dynamic check will fail and raise a
+@code{Program_Error} exception if the body has not been elaborated yet.
+GNAT will generate the necessary checks, and in addition, if the
+@option{-gnatwl}
+switch is set, will generate warnings that such checks are required.
 
-@c ---------------------------------------------------------------------------
-@node Input Variables in Inline Assembler
-@section Input Variables in Inline Assembler
+The use of dynamic dispatching for tagged types similarly generates
+a requirement for dynamic checks, and premature calls to any primitive
+operation of a tagged type before the body of the operation has been
+elaborated, will result in the raising of @code{Program_Error}.
+
+@node Summary of Procedures for Elaboration Control
+@section Summary of Procedures for Elaboration Control
+@cindex Elaboration control
 
 @noindent
-The example in this section illustrates how to specify the source operands
-for assembly language statements.
-The program simply increments its input value by 1:
+First, compile your program with the default options, using none of
+the special elaboration control switches. If the binder successfully
+binds your program, then you can be confident that, apart from issues
+raised by the use of access-to-subprogram types and dynamic dispatching,
+the program is free of elaboration errors. If it is important that the
+program be portable, then use the
+@option{-gnatwl}
+switch to generate warnings about missing @code{Elaborate} or
+@code{Elaborate_All} pragmas, and supply the missing pragmas.
 
-@smallexample @c ada
-@group
-with Interfaces; use Interfaces;
-with Ada.Text_IO; use Ada.Text_IO;
-with System.Machine_Code; use System.Machine_Code;
-procedure Increment is
+If the program fails to bind using the default static elaboration
+handling, then you can fix the program to eliminate the binder
+message, or recompile the entire program with the
+@option{-gnatE} switch to generate dynamic elaboration checks,
+and, if you are sure there really are no elaboration problems,
+use a global pragma @code{Suppress (Elaboration_Check)}.
 
-   function Incr (Value : Unsigned_32) return Unsigned_32 is
-      Result : Unsigned_32;
-   begin
-      Asm ("incl %0",
-           Inputs  => Unsigned_32'Asm_Input ("a", Value),
-           Outputs => Unsigned_32'Asm_Output ("=a", Result));
-      return Result;
-   end Incr;
+@node Other Elaboration Order Considerations
+@section Other Elaboration Order Considerations
+@noindent
+This section has been entirely concerned with the issue of finding a valid
+elaboration order, as defined by the Ada Reference Manual. In a case
+where several elaboration orders are valid, the task is to find one
+of the possible valid elaboration orders (and the static model in GNAT
+will ensure that this is achieved).
 
-   Value : Unsigned_32;
+The purpose of the elaboration rules in the Ada Reference Manual is to
+make sure that no entity is accessed before it has been elaborated. For
+a subprogram, this means that the spec and body must have been elaborated
+before the subprogram is called. For an object, this means that the object
+must have been elaborated before its value is read or written. A violation
+of either of these two requirements is an access before elaboration order,
+and this section has been all about avoiding such errors.
 
-begin
-   Value := 5;
-   Put_Line ("Value before is" & Value'Img);
-   Value := Incr (Value);
-   Put_Line ("Value after is" & Value'Img);
-end Increment;
-@end group
-@end smallexample
+In the case where more than one order of elaboration is possible, in the
+sense that access before elaboration errors are avoided, then any one of
+the orders is ``correct'' in the sense that it meets the requirements of
+the Ada Reference Manual, and no such error occurs.
 
-The @code{Outputs} parameter to @code{Asm} specifies
-that the result will be in the eax register and that it is to be stored
-in the @code{Result} variable.
+However, it may be the case for a given program, that there are
+constraints on the order of elaboration that come not from consideration
+of avoiding elaboration errors, but rather from extra-lingual logic
+requirements. Consider this example:
 
-The @code{Inputs} parameter looks much like the @code{Outputs} parameter,
-but with an @code{Asm_Input} attribute.
-The @code{"="} constraint, indicating an output value, is not present.
+@smallexample @c ada
+with Init_Constants;
+package Constants is
+   X : Integer := 0;
+   Y : Integer := 0;
+end Constants;
 
-You can have multiple input variables, in the same way that you can have more
-than one output variable.
+package Init_Constants is
+   procedure P; -- require a body
+end Init_Constants;
 
-The parameter count (%0, %1) etc, now starts at the first input
-statement, and continues with the output statements.
-When both parameters use the same variable, the
-compiler will treat them as the same %n operand, which is the case here.
+with Constants;
+package body Init_Constants is
+   procedure P is begin null; end;
+begin
+   Constants.X := 3;
+   Constants.Y := 4;
+end Init_Constants;
 
-Just as the @code{Outputs} parameter causes the register to be stored into the
-target variable after execution of the assembler statements, so does the
-@code{Inputs} parameter cause its variable to be loaded into the register
-before execution of the assembler statements.
+with Constants;
+package Calc is
+   Z : Integer := Constants.X + Constants.Y;
+end Calc;
+
+with Calc;
+with Text_IO; use Text_IO;
+procedure Main is
+begin
+   Put_Line (Calc.Z'Img);
+end Main;
+@end smallexample
 
-Thus the effect of the @code{Asm} invocation is:
-@enumerate
-@item load the 32-bit value of @code{Value} into eax
-@item execute the @code{incl %eax} instruction
-@item store the contents of eax into the @code{Result} variable
-@end enumerate
+@noindent
+In this example, there is more than one valid order of elaboration. For
+example both the following are correct orders:
 
-The resulting assembler file (with @option{-O2} optimization) contains:
 @smallexample
-@group
-_increment__incr.1:
-   subl $4,%esp
-   movl 8(%esp),%eax
-#APP
-   incl %eax
-#NO_APP
-   movl %eax,%edx
-   movl %ecx,(%esp)
-   addl $4,%esp
-   ret
-@end group
-@end smallexample
+Init_Constants spec
+Constants spec
+Calc spec
+Init_Constants body
+Main body
 
-@c ---------------------------------------------------------------------------
-@node Inlining Inline Assembler Code
-@section Inlining Inline Assembler Code
+  and
 
-@noindent
-For a short subprogram such as the @code{Incr} function in the previous
-section, the overhead of the call and return (creating / deleting the stack
-frame) can be significant, compared to the amount of code in the subprogram
-body.  A solution is to apply Ada's @code{Inline} pragma to the subprogram,
-which directs the compiler to expand invocations of the subprogram at the
-point(s) of call, instead of setting up a stack frame for out-of-line calls.
-Here is the resulting program:
+Init_Constants spec
+Init_Constants body
+Constants spec
+Calc spec
+Main body
+@end smallexample
 
-@smallexample @c ada
-@group
-with Interfaces; use Interfaces;
-with Ada.Text_IO; use Ada.Text_IO;
-with System.Machine_Code; use System.Machine_Code;
-procedure Increment_2 is
+@noindent
+There is no language rule to prefer one or the other, both are correct
+from an order of elaboration point of view. But the programmatic effects
+of the two orders are very different. In the first, the elaboration routine
+of @code{Calc} initializes @code{Z} to zero, and then the main program
+runs with this value of zero. But in the second order, the elaboration
+routine of @code{Calc} runs after the body of Init_Constants has set
+@code{X} and @code{Y} and thus @code{Z} is set to 7 before @code{Main}
+runs.
 
-   function Incr (Value : Unsigned_32) return Unsigned_32 is
-      Result : Unsigned_32;
-   begin
-      Asm ("incl %0",
-           Inputs  => Unsigned_32'Asm_Input ("a", Value),
-           Outputs => Unsigned_32'Asm_Output ("=a", Result));
-      return Result;
-   end Incr;
-   pragma Inline (Increment);
+One could perhaps by applying pretty clever non-artificial intelligence
+to the situation guess that it is more likely that the second order of
+elaboration is the one desired, but there is no formal linguistic reason
+to prefer one over the other. In fact in this particular case, GNAT will
+prefer the second order, because of the rule that bodies are elaborated
+as soon as possible, but it's just luck that this is what was wanted
+(if indeed the second order was preferred).
 
-   Value : Unsigned_32;
+If the program cares about the order of elaboration routines in a case like
+this, it is important to specify the order required. In this particular
+case, that could have been achieved by adding to the spec of Calc:
 
-begin
-   Value := 5;
-   Put_Line ("Value before is" & Value'Img);
-   Value := Increment (Value);
-   Put_Line ("Value after is" & Value'Img);
-end Increment_2;
-@end group
+@smallexample @c ada
+pragma Elaborate_All (Constants);
 @end smallexample
 
-Compile the program with both optimization (@option{-O2}) and inlining
-enabled (@option{-gnatpn} instead of @option{-gnatp}).
+@noindent
+which requires that the body (if any) and spec of @code{Constants},
+as well as the body and spec of any unit @code{with}'ed by
+@code{Constants} be elaborated before @code{Calc} is elaborated.
 
-The @code{Incr} function is still compiled as usual, but at the
-point in @code{Increment} where our function used to be called:
+Clearly no automatic method can always guess which alternative you require,
+and if you are working with legacy code that had constraints of this kind
+which were not properly specified by adding @code{Elaborate} or
+@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
+instead of as early as possible. In the example above, it would have forced
+the choice of the first elaboration order. If you get different results
+when using this switch, and particularly if one set of results is right,
+and one is wrong as far as you are concerned, it shows that you have some
+missing @code{Elaborate} pragmas. For the example above, we have the
+following output:
 
 @smallexample
-@group
-pushl %edi
-call _increment__incr.1
-@end group
+gnatmake -f -q main
+main
+ 7
+gnatmake -f -q main -bargs -p
+main
+ 0
 @end smallexample
 
 @noindent
-the code for the function body directly appears:
+It is of course quite unlikely that both these results are correct, so
+it is up to you in a case like this to investigate the source of the
+difference, by looking at the two elaboration orders that are chosen,
+and figuring out which is correct, and then adding the necessary
+@code{Elaborate} or @code{Elaborate_All} pragmas to ensure the desired order.
+
 
-@smallexample
-@group
-movl %esi,%eax
-#APP
-   incl %eax
-#NO_APP
-   movl %eax,%edx
-@end group
-@end smallexample
+
+@c *******************************
+@node Conditional Compilation
+@appendix Conditional Compilation
+@c *******************************
+@cindex Conditional compilation
 
 @noindent
-thus saving the overhead of stack frame setup and an out-of-line call.
+It is often necessary to arrange for a single source program
+to serve multiple purposes, where it is compiled in different
+ways to achieve these different goals. Some examples of the
+need for this feature are
 
-@c ---------------------------------------------------------------------------
-@node Other Asm Functionality
-@section Other @code{Asm} Functionality
+@itemize @bullet
+@item  Adapting a program to a different hardware environment
+@item  Adapting a program to a different target architecture
+@item  Turning debugging features on and off
+@item  Arranging for a program to compile with different compilers
+@end itemize
 
 @noindent
-This section describes two important parameters to the @code{Asm}
-procedure: @code{Clobber}, which identifies register usage;
-and @code{Volatile}, which inhibits unwanted optimizations.
+In C, or C++, the typical approach would be to use the preprocessor
+that is defined as part of the language. The Ada language does not
+contain such a feature. This is not an oversight, but rather a very
+deliberate design decision, based on the experience that overuse of
+the preprocessing features in C and C++ can result in programs that
+are extremely difficult to maintain. For example, if we have ten
+switches that can be on or off, this means that there are a thousand
+separate programs, any one of which might not even be syntactically
+correct, and even if syntactically correct, the resulting program
+might not work correctly. Testing all combinations can quickly become
+impossible.
+
+Nevertheless, the need to tailor programs certainly exists, and in
+this Appendix we will discuss how this can
+be achieved using Ada in general, and GNAT in particular.
 
 @menu
-* The Clobber Parameter::
-* The Volatile Parameter::
+* Use of Boolean Constants::
+* Debugging - A Special Case::
+* Conditionalizing Declarations::
+* Use of Alternative Implementations::
+* Preprocessing::
 @end menu
 
-@c ---------------------------------------------------------------------------
-@node The Clobber Parameter
-@subsection The @code{Clobber} Parameter
+@node Use of Boolean Constants
+@section Use of Boolean Constants
 
 @noindent
-One of the dangers of intermixing assembly language and a compiled language
-such as Ada is that the compiler needs to be aware of which registers are
-being used by the assembly code.  In some cases, such as the earlier examples,
-the constraint string is sufficient to indicate register usage (e.g.,
-@code{"a"} for
-the eax register).  But more generally, the compiler needs an explicit
-identification of the registers that are used by the Inline Assembly
-statements.
+In the case where the difference is simply which code
+sequence is executed, the cleanest solution is to use Boolean
+constants to control which code is executed.
 
-Using a register that the compiler doesn't know about
-could be a side effect of an instruction (like @code{mull}
-storing its result in both eax and edx).
-It can also arise from explicit register usage in your
-assembly code; for example:
-@smallexample
+@smallexample @c ada
 @group
-Asm ("movl %0, %%ebx" & LF & HT &
-     "movl %%ebx, %1",
-     Inputs  => Unsigned_32'Asm_Input  ("g", Var_In),
-     Outputs => Unsigned_32'Asm_Output ("=g", Var_Out));
+FP_Initialize_Required : constant Boolean := True;
+@dots{}
+if FP_Initialize_Required then
+@dots{}
+end if;
 @end group
 @end smallexample
+
 @noindent
-where the compiler (since it does not analyze the @code{Asm} template string)
-does not know you are using the ebx register.
+Not only will the code inside the @code{if} statement not be executed if
+the constant Boolean is @code{False}, but it will also be completely
+deleted from the program.
+However, the code is only deleted after the @code{if} statement
+has been checked for syntactic and semantic correctness.
+(In contrast, with preprocessors the code is deleted before the
+compiler ever gets to see it, so it is not checked until the switch
+is turned on.)
+@cindex Preprocessors (contrasted with conditional compilation)
 
-In such cases you need to supply the @code{Clobber} parameter to @code{Asm},
-to identify the registers that will be used by your assembly code:
+Typically the Boolean constants will be in a separate package,
+something like:
 
-@smallexample
+@smallexample @c ada
 @group
-Asm ("movl %0, %%ebx" & LF & HT &
-     "movl %%ebx, %1",
-     Inputs  => Unsigned_32'Asm_Input  ("g", Var_In),
-     Outputs => Unsigned_32'Asm_Output ("=g", Var_Out),
-     Clobber => "ebx");
+package Config is
+   FP_Initialize_Required : constant Boolean := True;
+   Reset_Available        : constant Boolean := False;
+   @dots{}
+end Config;
 @end group
 @end smallexample
 
-The Clobber parameter is a static string expression specifying the
-register(s) you are using.  Note that register names are @emph{not} prefixed
-by a percent sign. Also, if more than one register is used then their names
-are separated by commas; e.g., @code{"eax, ebx"}
+@noindent
+The @code{Config} package exists in multiple forms for the various targets,
+with an appropriate script selecting the version of @code{Config} needed.
+Then any other unit requiring conditional compilation can do a @code{with}
+of @code{Config} to make the constants visible.
 
-The @code{Clobber} parameter has several additional uses:
-@enumerate
-@item Use ``register'' name @code{cc} to indicate that flags might have changed
-@item Use ``register'' name @code{memory} if you changed a memory location
-@end enumerate
 
-@c ---------------------------------------------------------------------------
-@node The Volatile Parameter
-@subsection The @code{Volatile} Parameter
-@cindex Volatile parameter
+@node Debugging - A Special Case
+@section Debugging - A Special Case
 
 @noindent
-Compiler optimizations in the presence of Inline Assembler may sometimes have
-unwanted effects.  For example, when an @code{Asm} invocation with an input
-variable is inside a loop, the compiler might move the loading of the input
-variable outside the loop, regarding it as a one-time initialization.
+A common use of conditional code is to execute statements (for example
+dynamic checks, or output of intermediate results) under control of a
+debug switch, so that the debugging behavior can be turned on and off.
+This can be done using a Boolean constant to control whether the code
+is active:
 
-If this effect is not desired, you can disable such optimizations by setting
-the @code{Volatile} parameter to @code{True}; for example:
+@smallexample @c ada
+@group
+if Debugging then
+   Put_Line ("got to the first stage!");
+end if;
+@end group
+@end smallexample
+
+@noindent
+or
 
 @smallexample @c ada
 @group
-Asm ("movl %0, %%ebx" & LF & HT &
-     "movl %%ebx, %1",
-     Inputs   => Unsigned_32'Asm_Input  ("g", Var_In),
-     Outputs  => Unsigned_32'Asm_Output ("=g", Var_Out),
-     Clobber  => "ebx",
-     Volatile => True);
+if Debugging and then Temperature > 999.0 then
+   raise Temperature_Crazy;
+end if;
 @end group
 @end smallexample
 
-By default, @code{Volatile} is set to @code{False} unless there is no
-@code{Outputs} parameter.
+@noindent
+Since this is a common case, there are special features to deal with
+this in a convenient manner. For the case of tests, Ada 2005 has added
+a pragma @code{Assert} that can be used for such tests. This pragma is modeled
+@cindex pragma @code{Assert}
+on the @code{Assert} pragma that has always been available in GNAT, so this
+feature may be used with GNAT even if you are not using Ada 2005 features.
+The use of pragma @code{Assert} is described in the
+@cite{GNAT Reference Manual}, but as an example, the last test could be written:
 
-Although setting @code{Volatile} to @code{True} prevents unwanted
-optimizations, it will also disable other optimizations that might be
-important for efficiency. In general, you should set @code{Volatile}
-to @code{True} only if the compiler's optimizations have created
-problems.
+@smallexample @c ada
+pragma Assert (Temperature <= 999.0, "Temperature Crazy");
+@end smallexample
 
-@c ---------------------------------------------------------------------------
-@node A Complete Example
-@section A Complete Example
+@noindent
+or simply
+
+@smallexample @c ada
+pragma Assert (Temperature <= 999.0);
+@end smallexample
 
 @noindent
-This section contains a complete program illustrating a realistic usage
-of GNAT's Inline Assembler capabilities.  It comprises a main procedure
-@code{Check_CPU} and a package @code{Intel_CPU}.
-The package declares a collection of functions that detect the properties
-of the 32-bit x86 processor that is running the program.
-The main procedure invokes these functions and displays the information.
+In both cases, if assertions are active and the temperature is excessive,
+the exception @code{Assert_Failure} will be raised, with the given string in
+the first case or a string indicating the location of the pragma in the second
+case used as the exception message.
 
-The Intel_CPU package could be enhanced by adding functions to
-detect the type of x386 co-processor, the processor caching options and
-special operations such as the SIMD extensions.
+You can turn assertions on and off by using the @code{Assertion_Policy}
+pragma.
+@cindex pragma @code{Assertion_Policy}
+This is an Ada 2005 pragma which is implemented in all modes by
+GNAT, but only in the latest versions of GNAT which include Ada 2005
+capability. Alternatively, you can use the @option{-gnata} switch
+@cindex @option{-gnata} switch
+to enable assertions from the command line (this is recognized by all versions
+of GNAT).
 
-Although the Intel_CPU package has been written for 32-bit Intel
-compatible CPUs, it is OS neutral. It has been tested on DOS,
-Windows/NT and GNU/Linux.
+For the example above with the @code{Put_Line}, the GNAT-specific pragma
+@code{Debug} can be used:
+@cindex pragma @code{Debug}
 
-@menu
-* Check_CPU Procedure::
-* Intel_CPU Package Specification::
-* Intel_CPU Package Body::
-@end menu
+@smallexample @c ada
+pragma Debug (Put_Line ("got to the first stage!"));
+@end smallexample
 
-@c ---------------------------------------------------------------------------
-@node Check_CPU Procedure
-@subsection @code{Check_CPU} Procedure
-@cindex Check_CPU procedure
+@noindent
+If debug pragmas are enabled, the argument, which must be of the form of
+a procedure call, is executed (in this case, @code{Put_Line} will be called).
+Only one call can be present, but of course a special debugging procedure
+containing any code you like can be included in the program and then
+called in a pragma @code{Debug} argument as needed.
 
-@smallexample @c adanocomment
----------------------------------------------------------------------
---                                                                 --
---  Uses the Intel_CPU package to identify the CPU the program is  --
---  running on, and some of the features it supports.              --
---                                                                 --
----------------------------------------------------------------------
+One advantage of pragma @code{Debug} over the @code{if Debugging then}
+construct is that pragma @code{Debug} can appear in declarative contexts,
+such as at the very beginning of a procedure, before local declarations have
+been elaborated.
 
-with Intel_CPU;                     --  Intel CPU detection functions
-with Ada.Text_IO;                   --  Standard text I/O
-with Ada.Command_Line;              --  To set the exit status
+Debug pragmas are enabled using either the @option{-gnata} switch that also
+controls assertions, or with a separate Debug_Policy pragma.
+@cindex pragma @code{Debug_Policy}
+The latter pragma is new in the Ada 2005 versions of GNAT (but it can be used
+in Ada 95 and Ada 83 programs as well), and is analogous to
+pragma @code{Assertion_Policy} to control assertions.
 
-procedure Check_CPU is
+@code{Assertion_Policy} and @code{Debug_Policy} are configuration pragmas,
+and thus they can appear in @file{gnat.adc} if you are not using a
+project file, or in the file designated to contain configuration pragmas
+in a project file.
+They then apply to all subsequent compilations. In practice the use of
+the @option{-gnata} switch is often the most convenient method of controlling
+the status of these pragmas.
 
-   Type_Found : Boolean := False;
-   --  Flag to indicate that processor was identified
+Note that a pragma is not a statement, so in contexts where a statement
+sequence is required, you can't just write a pragma on its own. You have
+to add a @code{null} statement.
 
-   Features   : Intel_CPU.Processor_Features;
-   --  The processor features
+@smallexample @c ada
+@group
+if @dots{} then
+   @dots{} -- some statements
+else
+   pragma Assert (Num_Cases < 10);
+   null;
+end if;
+@end group
+@end smallexample
 
-   Signature  : Intel_CPU.Processor_Signature;
-   --  The processor type signature
 
-begin
+@node Conditionalizing Declarations
+@section Conditionalizing Declarations
 
-   -----------------------------------
-   --  Display the program banner.  --
-   -----------------------------------
-
-   Ada.Text_IO.Put_Line (Ada.Command_Line.Command_Name &
-                         ": check Intel CPU version and features, v1.0");
-   Ada.Text_IO.Put_Line ("distribute freely, but no warranty whatsoever");
-   Ada.Text_IO.New_Line;
-
-   -----------------------------------------------------------------------
-   --  We can safely start with the assumption that we are on at least  --
-   --  a x386 processor. If the CPUID instruction is present, then we   --
-   --  have a later processor type.                                     --
-   -----------------------------------------------------------------------
-
-   if Intel_CPU.Has_CPUID = False then
-
-      --  No CPUID instruction, so we assume this is indeed a x386
-      --  processor. We can still check if it has a FP co-processor.
-      if Intel_CPU.Has_FPU then
-         Ada.Text_IO.Put_Line
-           ("x386-type processor with a FP co-processor");
-      else
-         Ada.Text_IO.Put_Line
-           ("x386-type processor without a FP co-processor");
-      end if;  --  check for FPU
-
-      --  Program done
-      Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success);
-      return;
-
-   end if;  --  check for CPUID
-
-   -----------------------------------------------------------------------
-   --  If CPUID is supported, check if this is a true Intel processor,  --
-   --  if it is not, display a warning.                                 --
-   -----------------------------------------------------------------------
-
-   if Intel_CPU.Vendor_ID /= Intel_CPU.Intel_Processor then
-      Ada.Text_IO.Put_Line ("*** This is a Intel compatible processor");
-      Ada.Text_IO.Put_Line ("*** Some information may be incorrect");
-   end if;  --  check if Intel
-
-   ----------------------------------------------------------------------
-   --  With the CPUID instruction present, we can assume at least a    --
-   --  x486 processor. If the CPUID support level is < 1 then we have  --
-   --  to leave it at that.                                            --
-   ----------------------------------------------------------------------
-
-   if Intel_CPU.CPUID_Level < 1 then
-
-      --  Ok, this is a x486 processor. we still can get the Vendor ID
-      Ada.Text_IO.Put_Line ("x486-type processor");
-      Ada.Text_IO.Put_Line ("Vendor ID is " & Intel_CPU.Vendor_ID);
-
-      --  We can also check if there is a FPU present
-      if Intel_CPU.Has_FPU then
-         Ada.Text_IO.Put_Line ("Floating-Point support");
-      else
-         Ada.Text_IO.Put_Line ("No Floating-Point support");
-      end if;  --  check for FPU
-
-      --  Program done
-      Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success);
-      return;
-
-   end if;  --  check CPUID level
-
-   ---------------------------------------------------------------------
-   --  With a CPUID level of 1 we can use the processor signature to  --
-   --  determine it's exact type.                                     --
-   ---------------------------------------------------------------------
-
-   Signature := Intel_CPU.Signature;
-
-   ----------------------------------------------------------------------
-   --  Ok, now we go into a lot of messy comparisons to get the        --
-   --  processor type. For clarity, no attememt to try to optimize the --
-   --  comparisons has been made. Note that since Intel_CPU does not   --
-   --  support getting cache info, we cannot distinguish between P5    --
-   --  and Celeron types yet.                                          --
-   ----------------------------------------------------------------------
-
-   --  x486SL
-   if Signature.Processor_Type = 2#00#   and
-     Signature.Family          = 2#0100# and
-     Signature.Model           = 2#0100# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line ("x486SL processor");
-   end if;
+@noindent
+In some cases, it may be necessary to conditionalize declarations to meet
+different requirements. For example we might want a bit string whose length
+is set to meet some hardware message requirement.
 
-   --  x486DX2 Write-Back
-   if Signature.Processor_Type = 2#00#   and
-     Signature.Family          = 2#0100# and
-     Signature.Model           = 2#0111# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line ("Write-Back Enhanced x486DX2 processor");
-   end if;
+In some cases, it may be possible to do this using declare blocks controlled
+by conditional constants:
 
-   --  x486DX4
-   if Signature.Processor_Type = 2#00#   and
-     Signature.Family          = 2#0100# and
-     Signature.Model           = 2#1000# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line ("x486DX4 processor");
-   end if;
+@smallexample @c ada
+@group
+if Small_Machine then
+   declare
+      X : Bit_String (1 .. 10);
+   begin
+      @dots{}
+   end;
+else
+   declare
+      X : Large_Bit_String (1 .. 1000);
+   begin
+      @dots{}
+   end;
+end if;
+@end group
+@end smallexample
 
-   --  x486DX4 Overdrive
-   if Signature.Processor_Type = 2#01#   and
-     Signature.Family          = 2#0100# and
-     Signature.Model           = 2#1000# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line ("x486DX4 OverDrive processor");
-   end if;
+@noindent
+Note that in this approach, both declarations are analyzed by the
+compiler so this can only be used where both declarations are legal,
+even though one of them will not be used.
 
-   --  Pentium (60, 66)
-   if Signature.Processor_Type = 2#00#   and
-     Signature.Family          = 2#0101# and
-     Signature.Model           = 2#0001# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line ("Pentium processor (60, 66)");
-   end if;
+Another approach is to define integer constants, e.g. @code{Bits_Per_Word}, or
+Boolean constants, e.g. @code{Little_Endian}, and then write declarations
+that are parameterized by these constants. For example
 
-   --  Pentium (75, 90, 100, 120, 133, 150, 166, 200)
-   if Signature.Processor_Type = 2#00#   and
-     Signature.Family          = 2#0101# and
-     Signature.Model           = 2#0010# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line
-        ("Pentium processor (75, 90, 100, 120, 133, 150, 166, 200)");
-   end if;
+@smallexample @c ada
+@group
+for Rec use
+  Field1 at 0 range Boolean'Pos (Little_Endian) * 10 .. Bits_Per_Word;
+end record;
+@end group
+@end smallexample
 
-   --  Pentium OverDrive (60, 66)
-   if Signature.Processor_Type = 2#01#   and
-     Signature.Family          = 2#0101# and
-     Signature.Model           = 2#0001# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line ("Pentium OverDrive processor (60, 66)");
-   end if;
+@noindent
+If @code{Bits_Per_Word} is set to 32, this generates either
 
-   --  Pentium OverDrive (75, 90, 100, 120, 133, 150, 166, 200)
-   if Signature.Processor_Type = 2#01#   and
-     Signature.Family          = 2#0101# and
-     Signature.Model           = 2#0010# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line
-        ("Pentium OverDrive cpu (75, 90, 100, 120, 133, 150, 166, 200)");
-   end if;
+@smallexample @c ada
+@group
+for Rec use
+  Field1 at 0 range 0 .. 32;
+end record;
+@end group
+@end smallexample
 
-   --  Pentium OverDrive processor for x486 processor-based systems
-   if Signature.Processor_Type = 2#01#   and
-     Signature.Family          = 2#0101# and
-     Signature.Model           = 2#0011# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line
-        ("Pentium OverDrive processor for x486 processor-based systems");
-   end if;
+@noindent
+for the big endian case, or
 
-   --  Pentium processor with MMX technology (166, 200)
-   if Signature.Processor_Type = 2#00#   and
-     Signature.Family          = 2#0101# and
-     Signature.Model           = 2#0100# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line
-        ("Pentium processor with MMX technology (166, 200)");
-   end if;
+@smallexample @c ada
+@group
+for Rec use record
+  Field1 at 0 range 10 .. 32;
+end record;
+@end group
+@end smallexample
 
-   --  Pentium OverDrive with MMX for Pentium (75, 90, 100, 120, 133)
-   if Signature.Processor_Type = 2#01#   and
-     Signature.Family          = 2#0101# and
-     Signature.Model           = 2#0100# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line
-        ("Pentium OverDrive processor with MMX " &
-         "technology for Pentium processor (75, 90, 100, 120, 133)");
-   end if;
+@noindent
+for the little endian case. Since a powerful subset of Ada expression
+notation is usable for creating static constants, clever use of this
+feature can often solve quite difficult problems in conditionalizing
+compilation (note incidentally that in Ada 95, the little endian
+constant was introduced as @code{System.Default_Bit_Order}, so you do not
+need to define this one yourself).
 
-   --  Pentium Pro processor
-   if Signature.Processor_Type = 2#00#   and
-     Signature.Family          = 2#0110# and
-     Signature.Model           = 2#0001# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line ("Pentium Pro processor");
-   end if;
 
-   --  Pentium II processor, model 3
-   if Signature.Processor_Type = 2#00#   and
-     Signature.Family          = 2#0110# and
-     Signature.Model           = 2#0011# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line ("Pentium II processor, model 3");
-   end if;
+@node Use of Alternative Implementations
+@section Use of Alternative Implementations
 
-   --  Pentium II processor, model 5 or Celeron processor
-   if Signature.Processor_Type = 2#00#   and
-     Signature.Family          = 2#0110# and
-     Signature.Model           = 2#0101# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line
-        ("Pentium II processor, model 5 or Celeron processor");
-   end if;
+@noindent
+In some cases, none of the approaches described above are adequate. This
+can occur for example if the set of declarations required is radically
+different for two different configurations.
 
-   --  Pentium Pro OverDrive processor
-   if Signature.Processor_Type = 2#01#   and
-     Signature.Family          = 2#0110# and
-     Signature.Model           = 2#0011# then
-      Type_Found := True;
-      Ada.Text_IO.Put_Line ("Pentium Pro OverDrive processor");
-   end if;
+In this situation, the official Ada way of dealing with conditionalizing
+such code is to write separate units for the different cases. As long as
+this does not result in excessive duplication of code, this can be done
+without creating maintenance problems. The approach is to share common
+code as far as possible, and then isolate the code and declarations
+that are different. Subunits are often a convenient method for breaking
+out a piece of a unit that is to be conditionalized, with separate files
+for different versions of the subunit for different targets, where the
+build script selects the right one to give to the compiler.
+@cindex Subunits (and conditional compilation)
 
-   --  If no type recognized, we have an unknown. Display what
-   --  we _do_ know
-   if Type_Found = False then
-      Ada.Text_IO.Put_Line ("Unknown processor");
-   end if;
+As an example, consider a situation where a new feature in Ada 2005
+allows something to be done in a really nice way. But your code must be able
+to compile with an Ada 95 compiler. Conceptually you want to say:
 
-   -----------------------------------------
-   --  Display processor stepping level.  --
-   -----------------------------------------
+@smallexample @c ada
+@group
+if Ada_2005 then
+   @dots{} neat Ada 2005 code
+else
+   @dots{} not quite as neat Ada 95 code
+end if;
+@end group
+@end smallexample
 
-   Ada.Text_IO.Put_Line ("Stepping level:" & Signature.Stepping'Img);
+@noindent
+where @code{Ada_2005} is a Boolean constant.
 
-   ---------------------------------
-   --  Display vendor ID string.  --
-   ---------------------------------
+But this won't work when @code{Ada_2005} is set to @code{False},
+since the @code{then} clause will be illegal for an Ada 95 compiler.
+(Recall that although such unreachable code would eventually be deleted
+by the compiler, it still needs to be legal.  If it uses features
+introduced in Ada 2005, it will be illegal in Ada 95.)
 
-   Ada.Text_IO.Put_Line ("Vendor ID: " & Intel_CPU.Vendor_ID);
+So instead we write
 
-   ------------------------------------
-   --  Get the processors features.  --
-   ------------------------------------
+@smallexample @c ada
+procedure Insert is separate;
+@end smallexample
 
-   Features := Intel_CPU.Features;
+@noindent
+Then we have two files for the subunit @code{Insert}, with the two sets of
+code.
+If the package containing this is called @code{File_Queries}, then we might
+have two files
 
-   -----------------------------
-   --  Check for a FPU unit.  --
-   -----------------------------
+@itemize @bullet
+@item    @file{file_queries-insert-2005.adb}
+@item    @file{file_queries-insert-95.adb}
+@end itemize
 
-   if Features.FPU = True then
-      Ada.Text_IO.Put_Line ("Floating-Point unit available");
-   else
-      Ada.Text_IO.Put_Line ("no Floating-Point unit");
-   end if;  --  check for FPU
+@noindent
+and the build script renames the appropriate file to
 
-   --------------------------------
-   --  List processor features.  --
-   --------------------------------
+@smallexample
+file_queries-insert.adb
+@end smallexample
 
-   Ada.Text_IO.Put_Line ("Supported features: ");
+@noindent
+and then carries out the compilation.
 
-   --  Virtual Mode Extension
-   if Features.VME = True then
-      Ada.Text_IO.Put_Line ("    VME    - Virtual Mode Extension");
-   end if;
+This can also be done with project files' naming schemes. For example:
 
-   --  Debugging Extension
-   if Features.DE = True then
-      Ada.Text_IO.Put_Line ("    DE     - Debugging Extension");
-   end if;
+@smallexample @c project
+For Body ("File_Queries.Insert") use "file_queries-insert-2005.ada";
+@end smallexample
 
-   --  Page Size Extension
-   if Features.PSE = True then
-      Ada.Text_IO.Put_Line ("    PSE    - Page Size Extension");
-   end if;
+@noindent
+Note also that with project files it is desirable to use a different extension
+than @file{ads} / @file{adb} for alternative versions. Otherwise a naming
+conflict may arise through another commonly used feature: to declare as part
+of the project a set of directories containing all the sources obeying the
+default naming scheme.
 
-   --  Time Stamp Counter
-   if Features.TSC = True then
-      Ada.Text_IO.Put_Line ("    TSC    - Time Stamp Counter");
-   end if;
+The use of alternative units is certainly feasible in all situations,
+and for example the Ada part of the GNAT run-time is conditionalized
+based on the target architecture using this approach. As a specific example,
+consider the implementation of the AST feature in VMS. There is one
+spec:
 
-   --  Model Specific Registers
-   if Features.MSR = True then
-      Ada.Text_IO.Put_Line ("    MSR    - Model Specific Registers");
-   end if;
+@smallexample
+s-asthan.ads
+@end smallexample
 
-   --  Physical Address Extension
-   if Features.PAE = True then
-      Ada.Text_IO.Put_Line ("    PAE    - Physical Address Extension");
-   end if;
+@noindent
+which is the same for all architectures, and three bodies:
 
-   --  Machine Check Extension
-   if Features.MCE = True then
-      Ada.Text_IO.Put_Line ("    MCE    - Machine Check Extension");
-   end if;
+@table @file
+@item    s-asthan.adb
+used for all non-VMS operating systems
+@item    s-asthan-vms-alpha.adb
+used for VMS on the Alpha
+@item    s-asthan-vms-ia64.adb
+used for VMS on the ia64
+@end table
 
-   --  CMPXCHG8 instruction supported
-   if Features.CX8 = True then
-      Ada.Text_IO.Put_Line ("    CX8    - CMPXCHG8 instruction");
-   end if;
+@noindent
+The dummy version @file{s-asthan.adb} simply raises exceptions noting that
+this operating system feature is not available, and the two remaining
+versions interface with the corresponding versions of VMS to provide
+VMS-compatible AST handling. The GNAT build script knows the architecture
+and operating system, and automatically selects the right version,
+renaming it if necessary to @file{s-asthan.adb} before the run-time build.
+
+Another style for arranging alternative implementations is through Ada's
+access-to-subprogram facility.
+In case some functionality is to be conditionally included,
+you can declare an access-to-procedure variable @code{Ref} that is initialized
+to designate a ``do nothing'' procedure, and then invoke @code{Ref.all}
+when appropriate.
+In some library package, set @code{Ref} to @code{Proc'Access} for some
+procedure @code{Proc} that performs the relevant processing.
+The initialization only occurs if the library package is included in the
+program.
+The same idea can also be implemented using tagged types and dispatching
+calls.
 
-   --  on-chip APIC hardware support
-   if Features.APIC = True then
-      Ada.Text_IO.Put_Line ("    APIC   - on-chip APIC hardware support");
-   end if;
 
-   --  Fast System Call
-   if Features.SEP = True then
-      Ada.Text_IO.Put_Line ("    SEP    - Fast System Call");
-   end if;
+@node Preprocessing
+@section Preprocessing
+@cindex Preprocessing
 
-   --  Memory Type Range Registers
-   if Features.MTRR = True then
-      Ada.Text_IO.Put_Line ("    MTTR   - Memory Type Range Registers");
-   end if;
+@noindent
+Although it is quite possible to conditionalize code without the use of
+C-style preprocessing, as described earlier in this section, it is
+nevertheless convenient in some cases to use the C approach. Moreover,
+older Ada compilers have often provided some preprocessing capability,
+so legacy code may depend on this approach, even though it is not
+standard.
 
-   --  Page Global Enable
-   if Features.PGE = True then
-      Ada.Text_IO.Put_Line ("    PGE    - Page Global Enable");
-   end if;
+To accommodate such use, GNAT provides a preprocessor (modeled to a large
+extent on the various preprocessors that have been used
+with legacy code on other compilers, to enable easier transition).
 
-   --  Machine Check Architecture
-   if Features.MCA = True then
-      Ada.Text_IO.Put_Line ("    MCA    - Machine Check Architecture");
-   end if;
+The preprocessor may be used in two separate modes. It can be used quite
+separately from the compiler, to generate a separate output source file
+that is then fed to the compiler as a separate step. This is the
+@code{gnatprep} utility, whose use is fully described in
+@ref{Preprocessing Using gnatprep}.
+@cindex @code{gnatprep}
 
-   --  Conditional Move Instruction Supported
-   if Features.CMOV = True then
-      Ada.Text_IO.Put_Line
-        ("    CMOV   - Conditional Move Instruction Supported");
-   end if;
+The preprocessing language allows such constructs as
 
-   --  Page Attribute Table
-   if Features.PAT = True then
-      Ada.Text_IO.Put_Line ("    PAT    - Page Attribute Table");
-   end if;
+@smallexample
+@group
+#if DEBUG or PRIORITY > 4 then
+   bunch of declarations
+#else
+   completely different bunch of declarations
+#end if;
+@end group
+@end smallexample
 
-   --  36-bit Page Size Extension
-   if Features.PSE_36 = True then
-      Ada.Text_IO.Put_Line ("    PSE_36 - 36-bit Page Size Extension");
-   end if;
+@noindent
+The values of the symbols @code{DEBUG} and @code{PRIORITY} can be
+defined either on the command line or in a separate file.
 
-   --  MMX technology supported
-   if Features.MMX = True then
-      Ada.Text_IO.Put_Line ("    MMX    - MMX technology supported");
-   end if;
+The other way of running the preprocessor is even closer to the C style and
+often more convenient. In this approach the preprocessing is integrated into
+the compilation process. The compiler is fed the preprocessor input which
+includes @code{#if} lines etc, and then the compiler carries out the
+preprocessing internally and processes the resulting output.
+For more details on this approach, see @ref{Integrated Preprocessing}.
 
-   --  Fast FP Save and Restore
-   if Features.FXSR = True then
-      Ada.Text_IO.Put_Line ("    FXSR   - Fast FP Save and Restore");
-   end if;
 
-   ---------------------
-   --  Program done.  --
-   ---------------------
+@c *******************************
+@node Inline Assembler
+@appendix Inline Assembler
+@c *******************************
 
-   Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success);
+@noindent
+If you need to write low-level software that interacts directly
+with the hardware, Ada provides two ways to incorporate assembly
+language code into your program.  First, you can import and invoke
+external routines written in assembly language, an Ada feature fully
+supported by GNAT@.  However, for small sections of code it may be simpler
+or more efficient to include assembly language statements directly
+in your Ada source program, using the facilities of the implementation-defined
+package @code{System.Machine_Code}, which incorporates the gcc
+Inline Assembler.  The Inline Assembler approach offers a number of advantages,
+including the following:
 
-exception
+@itemize @bullet
+@item No need to use non-Ada tools
+@item Consistent interface over different targets
+@item Automatic usage of the proper calling conventions
+@item Access to Ada constants and variables
+@item Definition of intrinsic routines
+@item Possibility of inlining a subprogram comprising assembler code
+@item Code optimizer can take Inline Assembler code into account
+@end itemize
 
-   when others =>
-      Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
-      raise;
+This chapter presents a series of examples to show you how to use
+the Inline Assembler.  Although it focuses on the Intel x86,
+the general approach applies also to other processors.
+It is assumed that you are familiar with Ada
+and with assembly language programming.
 
-end Check_CPU;
-@end smallexample
+@menu
+* Basic Assembler Syntax::
+* A Simple Example of Inline Assembler::
+* Output Variables in Inline Assembler::
+* Input Variables in Inline Assembler::
+* Inlining Inline Assembler Code::
+* Other Asm Functionality::
+@end menu
 
 @c ---------------------------------------------------------------------------
-@node Intel_CPU Package Specification
-@subsection @code{Intel_CPU} Package Specification
-@cindex Intel_CPU package specification
+@node Basic Assembler Syntax
+@section Basic Assembler Syntax
 
-@smallexample @c adanocomment
--------------------------------------------------------------------------
---                                                                     --
---  file: intel_cpu.ads                                                --
---                                                                     --
---           *********************************************             --
---           * WARNING: for 32-bit Intel processors only *             --
---           *********************************************             --
---                                                                     --
---  This package contains a number of subprograms that are useful in   --
---  determining the Intel x86 CPU (and the features it supports) on    --
---  which the program is running.                                      --
---                                                                     --
---  The package is based upon the information given in the Intel       --
---  Application Note AP-485: "Intel Processor Identification and the   --
---  CPUID Instruction" as of April 1998. This application note can be  --
---  found on www.intel.com.                                            --
---                                                                     --
---  It currently deals with 32-bit processors only, will not detect    --
---  features added after april 1998, and does not guarantee proper     --
---  results on Intel-compatible processors.                            --
---                                                                     --
---  Cache info and x386 fpu type detection are not supported.          --
---                                                                     --
---  This package does not use any privileged instructions, so should   --
---  work on any OS running on a 32-bit Intel processor.                --
---                                                                     --
--------------------------------------------------------------------------
-
-with Interfaces;             use Interfaces;
---  for using unsigned types
-
-with System.Machine_Code;    use System.Machine_Code;
---  for using inline assembler code
-
-with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
---  for inserting control characters
-
-package Intel_CPU is
-
-   ----------------------
-   --  Processor bits  --
-   ----------------------
-
-   subtype Num_Bits is Natural range 0 .. 31;
-   --  the number of processor bits (32)
-
-   --------------------------
-   --  Processor register  --
-   --------------------------
-
-   --  define a processor register type for easy access to
-   --  the individual bits
-
-   type Processor_Register is array (Num_Bits) of Boolean;
-   pragma Pack (Processor_Register);
-   for Processor_Register'Size use 32;
-
-   -------------------------
-   --  Unsigned register  --
-   -------------------------
-
-   --  define a processor register type for easy access to
-   --  the individual bytes
-
-   type Unsigned_Register is
-      record
-         L1 : Unsigned_8;
-         H1 : Unsigned_8;
-         L2 : Unsigned_8;
-         H2 : Unsigned_8;
-      end record;
+@noindent
+The assembler used by GNAT and gcc is based not on the Intel assembly
+language, but rather on a language that descends from the AT&T Unix
+assembler @emph{as} (and which is often referred to as ``AT&T syntax'').
+The following table summarizes the main features of @emph{as} syntax
+and points out the differences from the Intel conventions.
+See the gcc @emph{as} and @emph{gas} (an @emph{as} macro
+pre-processor) documentation for further information.
 
-   for Unsigned_Register use
-      record
-         L1 at 0 range  0 ..  7;
-         H1 at 0 range  8 .. 15;
-         L2 at 0 range 16 .. 23;
-         H2 at 0 range 24 .. 31;
-      end record;
+@table @asis
+@item Register names
+gcc / @emph{as}: Prefix with ``%''; for example @code{%eax}
+@*
+Intel: No extra punctuation; for example @code{eax}
 
-   for Unsigned_Register'Size use 32;
+@item Immediate operand
+gcc / @emph{as}: Prefix with ``$''; for example @code{$4}
+@*
+Intel: No extra punctuation; for example @code{4}
 
-   ---------------------------------
-   --  Intel processor vendor ID  --
-   ---------------------------------
+@item Address
+gcc / @emph{as}: Prefix with ``$''; for example @code{$loc}
+@*
+Intel: No extra punctuation; for example @code{loc}
 
-   Intel_Processor : constant String (1 .. 12) := "GenuineIntel";
-   --  indicates an Intel manufactured processor
+@item Memory contents
+gcc / @emph{as}: No extra punctuation; for example @code{loc}
+@*
+Intel: Square brackets; for example @code{[loc]}
 
-   ------------------------------------
-   --  Processor signature register  --
-   ------------------------------------
+@item Register contents
+gcc / @emph{as}: Parentheses; for example @code{(%eax)}
+@*
+Intel: Square brackets; for example @code{[eax]}
 
-   --  a register type to hold the processor signature
+@item Hexadecimal numbers
+gcc / @emph{as}: Leading ``0x'' (C language syntax); for example @code{0xA0}
+@*
+Intel: Trailing ``h''; for example @code{A0h}
 
-   type Processor_Signature is
-      record
-         Stepping       : Natural range 0 .. 15;
-         Model          : Natural range 0 .. 15;
-         Family         : Natural range 0 .. 15;
-         Processor_Type : Natural range 0 .. 3;
-         Reserved       : Natural range 0 .. 262143;
-      end record;
+@item Operand size
+gcc / @emph{as}: Explicit in op code; for example @code{movw} to move
+a 16-bit word
+@*
+Intel: Implicit, deduced by assembler; for example @code{mov}
 
-   for Processor_Signature use
-      record
-         Stepping       at 0 range  0 ..  3;
-         Model          at 0 range  4 ..  7;
-         Family         at 0 range  8 .. 11;
-         Processor_Type at 0 range 12 .. 13;
-         Reserved       at 0 range 14 .. 31;
-      end record;
+@item Instruction repetition
+gcc / @emph{as}: Split into two lines; for example
+@*
+@code{rep}
+@*
+@code{stosl}
+@*
+Intel: Keep on one line; for example @code{rep stosl}
 
-   for Processor_Signature'Size use 32;
+@item Order of operands
+gcc / @emph{as}: Source first; for example @code{movw $4, %eax}
+@*
+Intel: Destination first; for example @code{mov eax, 4}
+@end table
 
-   -----------------------------------
-   --  Processor features register  --
-   -----------------------------------
+@c ---------------------------------------------------------------------------
+@node A Simple Example of Inline Assembler
+@section A Simple Example of Inline Assembler
 
-   --  a processor register to hold the processor feature flags
+@noindent
+The following example will generate a single assembly language statement,
+@code{nop}, which does nothing.  Despite its lack of run-time effect,
+the example will be useful in illustrating the basics of
+the Inline Assembler facility.
 
-   type Processor_Features is
-      record
-         FPU    : Boolean;                --  floating point unit on chip
-         VME    : Boolean;                --  virtual mode extension
-         DE     : Boolean;                --  debugging extension
-         PSE    : Boolean;                --  page size extension
-         TSC    : Boolean;                --  time stamp counter
-         MSR    : Boolean;                --  model specific registers
-         PAE    : Boolean;                --  physical address extension
-         MCE    : Boolean;                --  machine check extension
-         CX8    : Boolean;                --  cmpxchg8 instruction
-         APIC   : Boolean;                --  on-chip apic hardware
-         Res_1  : Boolean;                --  reserved for extensions
-         SEP    : Boolean;                --  fast system call
-         MTRR   : Boolean;                --  memory type range registers
-         PGE    : Boolean;                --  page global enable
-         MCA    : Boolean;                --  machine check architecture
-         CMOV   : Boolean;                --  conditional move supported
-         PAT    : Boolean;                --  page attribute table
-         PSE_36 : Boolean;                --  36-bit page size extension
-         Res_2  : Natural range 0 .. 31;  --  reserved for extensions
-         MMX    : Boolean;                --  MMX technology supported
-         FXSR   : Boolean;                --  fast FP save and restore
-         Res_3  : Natural range 0 .. 127; --  reserved for extensions
-      end record;
+@smallexample @c ada
+@group
+with System.Machine_Code; use System.Machine_Code;
+procedure Nothing is
+begin
+   Asm ("nop");
+end Nothing;
+@end group
+@end smallexample
 
-   for Processor_Features use
-      record
-         FPU    at 0 range  0 ..  0;
-         VME    at 0 range  1 ..  1;
-         DE     at 0 range  2 ..  2;
-         PSE    at 0 range  3 ..  3;
-         TSC    at 0 range  4 ..  4;
-         MSR    at 0 range  5 ..  5;
-         PAE    at 0 range  6 ..  6;
-         MCE    at 0 range  7 ..  7;
-         CX8    at 0 range  8 ..  8;
-         APIC   at 0 range  9 ..  9;
-         Res_1  at 0 range 10 .. 10;
-         SEP    at 0 range 11 .. 11;
-         MTRR   at 0 range 12 .. 12;
-         PGE    at 0 range 13 .. 13;
-         MCA    at 0 range 14 .. 14;
-         CMOV   at 0 range 15 .. 15;
-         PAT    at 0 range 16 .. 16;
-         PSE_36 at 0 range 17 .. 17;
-         Res_2  at 0 range 18 .. 22;
-         MMX    at 0 range 23 .. 23;
-         FXSR   at 0 range 24 .. 24;
-         Res_3  at 0 range 25 .. 31;
-      end record;
+@code{Asm} is a procedure declared in package @code{System.Machine_Code};
+here it takes one parameter, a @emph{template string} that must be a static
+expression and that will form the generated instruction.
+@code{Asm} may be regarded as a compile-time procedure that parses
+the template string and additional parameters (none here),
+from which it generates a sequence of assembly language instructions.
 
-   for Processor_Features'Size use 32;
+The examples in this chapter will illustrate several of the forms
+for invoking @code{Asm}; a complete specification of the syntax
+is found in the @cite{GNAT Reference Manual}.
 
-   -------------------
-   --  Subprograms  --
-   -------------------
+Under the standard GNAT conventions, the @code{Nothing} procedure
+should be in a file named @file{nothing.adb}.
+You can build the executable in the usual way:
+@smallexample
+gnatmake nothing
+@end smallexample
+However, the interesting aspect of this example is not its run-time behavior
+but rather the generated assembly code.
+To see this output, invoke the compiler as follows:
+@smallexample
+   gcc -c -S -fomit-frame-pointer -gnatp @file{nothing.adb}
+@end smallexample
+where the options are:
 
-   function Has_FPU return Boolean;
-   --  return True if a FPU is found
-   --  use only if CPUID is not supported
+@table @code
+@item -c
+compile only (no bind or link)
+@item -S
+generate assembler listing
+@item -fomit-frame-pointer
+do not set up separate stack frames
+@item -gnatp
+do not add runtime checks
+@end table
 
-   function Has_CPUID return Boolean;
-   --  return True if the processor supports the CPUID instruction
+This gives a human-readable assembler version of the code. The resulting
+file will have the same name as the Ada source file, but with a @code{.s}
+extension. In our example, the file @file{nothing.s} has the following
+contents:
 
-   function CPUID_Level return Natural;
-   --  return the CPUID support level (0, 1 or 2)
-   --  can only be called if the CPUID instruction is supported
+@smallexample
+@group
+.file "nothing.adb"
+gcc2_compiled.:
+___gnu_compiled_ada:
+.text
+   .align 4
+.globl __ada_nothing
+__ada_nothing:
+#APP
+   nop
+#NO_APP
+   jmp L1
+   .align 2,0x90
+L1:
+   ret
+@end group
+@end smallexample
 
-   function Vendor_ID return String;
-   --  return the processor vendor identification string
-   --  can only be called if the CPUID instruction is supported
+The assembly code you included is clearly indicated by
+the compiler, between the @code{#APP} and @code{#NO_APP}
+delimiters. The character before the 'APP' and 'NOAPP'
+can differ on different targets. For example, GNU/Linux uses '#APP' while
+on NT you will see '/APP'.
 
-   function Signature return Processor_Signature;
-   --  return the processor signature
-   --  can only be called if the CPUID instruction is supported
+If you make a mistake in your assembler code (such as using the
+wrong size modifier, or using a wrong operand for the instruction) GNAT
+will report this error in a temporary file, which will be deleted when
+the compilation is finished.  Generating an assembler file will help
+in such cases, since you can assemble this file separately using the
+@emph{as} assembler that comes with gcc.
 
-   function Features return Processor_Features;
-   --  return the processors features
-   --  can only be called if the CPUID instruction is supported
+Assembling the file using the command
 
-private
+@smallexample
+as @file{nothing.s}
+@end smallexample
+@noindent
+will give you error messages whose lines correspond to the assembler
+input file, so you can easily find and correct any mistakes you made.
+If there are no errors, @emph{as} will generate an object file
+@file{nothing.out}.
 
-   ------------------------
-   --  EFLAGS bit names  --
-   ------------------------
+@c ---------------------------------------------------------------------------
+@node Output Variables in Inline Assembler
+@section Output Variables in Inline Assembler
 
-   ID_Flag : constant Num_Bits := 21;
-   --  ID flag bit
+@noindent
+The examples in this section, showing how to access the processor flags,
+illustrate how to specify the destination operands for assembly language
+statements.
 
-end Intel_CPU;
+@smallexample @c ada
+@group
+with Interfaces; use Interfaces;
+with Ada.Text_IO; use Ada.Text_IO;
+with System.Machine_Code; use System.Machine_Code;
+procedure Get_Flags is
+   Flags : Unsigned_32;
+   use ASCII;
+begin
+   Asm ("pushfl"          & LF & HT & -- push flags on stack
+        "popl %%eax"      & LF & HT & -- load eax with flags
+        "movl %%eax, %0",             -- store flags in variable
+        Outputs => Unsigned_32'Asm_Output ("=g", Flags));
+   Put_Line ("Flags register:" & Flags'Img);
+end Get_Flags;
+@end group
 @end smallexample
 
-@c ---------------------------------------------------------------------------
-@node Intel_CPU Package Body
-@subsection @code{Intel_CPU} Package Body
-@cindex Intel_CPU package body
-
-@smallexample @c adanocomment
-package body Intel_CPU is
+In order to have a nicely aligned assembly listing, we have separated
+multiple assembler statements in the Asm template string with linefeed
+(ASCII.LF) and horizontal tab (ASCII.HT) characters.
+The resulting section of the assembly output file is:
 
-   ---------------------------
-   --  Detect FPU presence  --
-   ---------------------------
+@smallexample
+@group
+#APP
+   pushfl
+   popl %eax
+   movl %eax, -40(%ebp)
+#NO_APP
+@end group
+@end smallexample
 
-   --  There is a FPU present if we can set values to the FPU Status
-   --  and Control Words.
+It would have been legal to write the Asm invocation as:
 
-   function Has_FPU return Boolean is
+@smallexample
+Asm ("pushfl popl %%eax movl %%eax, %0")
+@end smallexample
 
-      Register : Unsigned_16;
-      --  processor register to store a word
+but in the generated assembler file, this would come out as:
 
-   begin
+@smallexample
+#APP
+   pushfl popl %eax movl %eax, -40(%ebp)
+#NO_APP
+@end smallexample
 
-      --  check if we can change the status word
-      Asm (
+which is not so convenient for the human reader.
 
-           --  the assembler code
-           "finit"              & LF & HT &    --  reset status word
-           "movw $0x5A5A, %%ax" & LF & HT &    --  set value status word
-           "fnstsw %0"          & LF & HT &    --  save status word
-           "movw %%ax, %0",                    --  store status word
+We use Ada comments
+at the end of each line to explain what the assembler instructions
+actually do.  This is a useful convention.
 
-           --  output stored in Register
-           --  register must be a memory location
-           Outputs => Unsigned_16'Asm_output ("=m", Register),
+When writing Inline Assembler instructions, you need to precede each register
+and variable name with a percent sign.  Since the assembler already requires
+a percent sign at the beginning of a register name, you need two consecutive
+percent signs for such names in the Asm template string, thus @code{%%eax}.
+In the generated assembly code, one of the percent signs will be stripped off.
 
-           --  tell compiler that we used eax
-           Clobber => "eax");
+Names such as @code{%0}, @code{%1}, @code{%2}, etc., denote input or output
+variables: operands you later define using @code{Input} or @code{Output}
+parameters to @code{Asm}.
+An output variable is illustrated in
+the third statement in the Asm template string:
+@smallexample
+movl %%eax, %0
+@end smallexample
+The intent is to store the contents of the eax register in a variable that can
+be accessed in Ada.  Simply writing @code{movl %%eax, Flags} would not
+necessarily work, since the compiler might optimize by using a register
+to hold Flags, and the expansion of the @code{movl} instruction would not be
+aware of this optimization.  The solution is not to store the result directly
+but rather to advise the compiler to choose the correct operand form;
+that is the purpose of the @code{%0} output variable.
 
-      --  if the status word is zero, there is no FPU
-      if Register = 0 then
-         return False;   --  no status word
-      end if;  --  check status word value
+Information about the output variable is supplied in the @code{Outputs}
+parameter to @code{Asm}:
+@smallexample
+Outputs => Unsigned_32'Asm_Output ("=g", Flags));
+@end smallexample
 
-      --  check if we can get the control word
-      Asm (
+The output is defined by the @code{Asm_Output} attribute of the target type;
+the general format is
+@smallexample
+Type'Asm_Output (constraint_string, variable_name)
+@end smallexample
 
-           --  the assembler code
-           "fnstcw %0",   --  save the control word
+The constraint string directs the compiler how
+to store/access the associated variable.  In the example
+@smallexample
+Unsigned_32'Asm_Output ("=m", Flags);
+@end smallexample
+the @code{"m"} (memory) constraint tells the compiler that the variable
+@code{Flags} should be stored in a memory variable, thus preventing
+the optimizer from keeping it in a register.  In contrast,
+@smallexample
+Unsigned_32'Asm_Output ("=r", Flags);
+@end smallexample
+uses the @code{"r"} (register) constraint, telling the compiler to
+store the variable in a register.
 
-           --  output into Register
-           --  register must be a memory location
-           Outputs => Unsigned_16'Asm_output ("=m", Register));
+If the constraint is preceded by the equal character (@strong{=}), it tells
+the compiler that the variable will be used to store data into it.
 
-      --  check the relevant bits
-      if (Register and 16#103F#) /= 16#003F# then
-         return False;   --  no control word
-      end if;  --  check control word value
+In the @code{Get_Flags} example, we used the @code{"g"} (global) constraint,
+allowing the optimizer to choose whatever it deems best.
 
-      --  FPU found
-      return True;
+There are a fairly large number of constraints, but the ones that are
+most useful (for the Intel x86 processor) are the following:
 
-   end Has_FPU;
+@table @code
+@item =
+output constraint
+@item g
+global (i.e. can be stored anywhere)
+@item m
+in memory
+@item I
+a constant
+@item a
+use eax
+@item b
+use ebx
+@item c
+use ecx
+@item d
+use edx
+@item S
+use esi
+@item D
+use edi
+@item r
+use one of eax, ebx, ecx or edx
+@item q
+use one of eax, ebx, ecx, edx, esi or edi
+@end table
 
-   --------------------------------
-   --  Detect CPUID instruction  --
-   --------------------------------
+The full set of constraints is described in the gcc and @emph{as}
+documentation; note that it is possible to combine certain constraints
+in one constraint string.
 
-   --  The processor supports the CPUID instruction if it is possible
-   --  to change the value of ID flag bit in the EFLAGS register.
+You specify the association of an output variable with an assembler operand
+through the @code{%}@emph{n} notation, where @emph{n} is a non-negative
+integer.  Thus in
+@smallexample @c ada
+@group
+Asm ("pushfl"          & LF & HT & -- push flags on stack
+     "popl %%eax"      & LF & HT & -- load eax with flags
+     "movl %%eax, %0",             -- store flags in variable
+     Outputs => Unsigned_32'Asm_Output ("=g", Flags));
+@end group
+@end smallexample
+@noindent
+@code{%0} will be replaced in the expanded code by the appropriate operand,
+whatever
+the compiler decided for the @code{Flags} variable.
 
-   function Has_CPUID return Boolean is
+In general, you may have any number of output variables:
+@itemize @bullet
+@item
+Count the operands starting at 0; thus @code{%0}, @code{%1}, etc.
+@item
+Specify the @code{Outputs} parameter as a parenthesized comma-separated list
+of @code{Asm_Output} attributes
+@end itemize
 
-      Original_Flags, Modified_Flags : Processor_Register;
-      --  EFLAG contents before and after changing the ID flag
+For example:
+@smallexample @c ada
+@group
+Asm ("movl %%eax, %0" & LF & HT &
+     "movl %%ebx, %1" & LF & HT &
+     "movl %%ecx, %2",
+     Outputs => (Unsigned_32'Asm_Output ("=g", Var_A),   --  %0 = Var_A
+                 Unsigned_32'Asm_Output ("=g", Var_B),   --  %1 = Var_B
+                 Unsigned_32'Asm_Output ("=g", Var_C))); --  %2 = Var_C
+@end group
+@end smallexample
+@noindent
+where @code{Var_A}, @code{Var_B}, and @code{Var_C} are variables
+in the Ada program.
 
-   begin
+As a variation on the @code{Get_Flags} example, we can use the constraints
+string to direct the compiler to store the eax register into the @code{Flags}
+variable, instead of including the store instruction explicitly in the
+@code{Asm} template string:
 
-      --  try flipping the ID flag in the EFLAGS register
-      Asm (
+@smallexample @c ada
+@group
+with Interfaces; use Interfaces;
+with Ada.Text_IO; use Ada.Text_IO;
+with System.Machine_Code; use System.Machine_Code;
+procedure Get_Flags_2 is
+   Flags : Unsigned_32;
+   use ASCII;
+begin
+   Asm ("pushfl"      & LF & HT & -- push flags on stack
+        "popl %%eax",             -- save flags in eax
+        Outputs => Unsigned_32'Asm_Output ("=a", Flags));
+   Put_Line ("Flags register:" & Flags'Img);
+end Get_Flags_2;
+@end group
+@end smallexample
 
-           --  the assembler code
-           "pushfl"               & LF & HT &     --  push EFLAGS on stack
-           "pop %%eax"            & LF & HT &     --  pop EFLAGS into eax
-           "movl %%eax, %0"       & LF & HT &     --  save EFLAGS content
-           "xor $0x200000, %%eax" & LF & HT &     --  flip ID flag
-           "push %%eax"           & LF & HT &     --  push EFLAGS on stack
-           "popfl"                & LF & HT &     --  load EFLAGS register
-           "pushfl"               & LF & HT &     --  push EFLAGS on stack
-           "pop %1",                              --  save EFLAGS content
+@noindent
+The @code{"a"} constraint tells the compiler that the @code{Flags}
+variable will come from the eax register. Here is the resulting code:
 
-           --  output values, may be anything
-           --  Original_Flags is %0
-           --  Modified_Flags is %1
-           Outputs =>
-              (Processor_Register'Asm_output ("=g", Original_Flags),
-               Processor_Register'Asm_output ("=g", Modified_Flags)),
+@smallexample
+@group
+#APP
+   pushfl
+   popl %eax
+#NO_APP
+   movl %eax,-40(%ebp)
+@end group
+@end smallexample
 
-           --  tell compiler eax is destroyed
-           Clobber => "eax");
+@noindent
+The compiler generated the store of eax into Flags after
+expanding the assembler code.
 
-      --  check if CPUID is supported
-      if Original_Flags(ID_Flag) /= Modified_Flags(ID_Flag) then
-         return True;   --  ID flag was modified
-      else
-         return False;  --  ID flag unchanged
-      end if;  --  check for CPUID
+Actually, there was no need to pop the flags into the eax register;
+more simply, we could just pop the flags directly into the program variable:
 
-   end Has_CPUID;
+@smallexample @c ada
+@group
+with Interfaces; use Interfaces;
+with Ada.Text_IO; use Ada.Text_IO;
+with System.Machine_Code; use System.Machine_Code;
+procedure Get_Flags_3 is
+   Flags : Unsigned_32;
+   use ASCII;
+begin
+   Asm ("pushfl"  & LF & HT & -- push flags on stack
+        "pop %0",             -- save flags in Flags
+        Outputs => Unsigned_32'Asm_Output ("=g", Flags));
+   Put_Line ("Flags register:" & Flags'Img);
+end Get_Flags_3;
+@end group
+@end smallexample
 
-   -------------------------------
-   --  Get CPUID support level  --
-   -------------------------------
+@c ---------------------------------------------------------------------------
+@node Input Variables in Inline Assembler
+@section Input Variables in Inline Assembler
 
-   function CPUID_Level return Natural is
+@noindent
+The example in this section illustrates how to specify the source operands
+for assembly language statements.
+The program simply increments its input value by 1:
 
-      Level : Unsigned_32;
-      --  returned support level
+@smallexample @c ada
+@group
+with Interfaces; use Interfaces;
+with Ada.Text_IO; use Ada.Text_IO;
+with System.Machine_Code; use System.Machine_Code;
+procedure Increment is
 
+   function Incr (Value : Unsigned_32) return Unsigned_32 is
+      Result : Unsigned_32;
    begin
+      Asm ("incl %0",
+           Inputs  => Unsigned_32'Asm_Input ("a", Value),
+           Outputs => Unsigned_32'Asm_Output ("=a", Result));
+      return Result;
+   end Incr;
 
-      --  execute CPUID, storing the results in the Level register
-      Asm (
+   Value : Unsigned_32;
 
-           --  the assembler code
-           "cpuid",    --  execute CPUID
+begin
+   Value := 5;
+   Put_Line ("Value before is" & Value'Img);
+   Value := Incr (Value);
+   Put_Line ("Value after is" & Value'Img);
+end Increment;
+@end group
+@end smallexample
 
-           --  zero is stored in eax
-           --  returning the support level in eax
-           Inputs => Unsigned_32'Asm_input ("a", 0),
+The @code{Outputs} parameter to @code{Asm} specifies
+that the result will be in the eax register and that it is to be stored
+in the @code{Result} variable.
 
-           --  eax is stored in Level
-           Outputs => Unsigned_32'Asm_output ("=a", Level),
+The @code{Inputs} parameter looks much like the @code{Outputs} parameter,
+but with an @code{Asm_Input} attribute.
+The @code{"="} constraint, indicating an output value, is not present.
 
-           --  tell compiler ebx, ecx and edx registers are destroyed
-           Clobber => "ebx, ecx, edx");
+You can have multiple input variables, in the same way that you can have more
+than one output variable.
 
-      --  return the support level
-      return Natural (Level);
+The parameter count (%0, %1) etc, now starts at the first input
+statement, and continues with the output statements.
+When both parameters use the same variable, the
+compiler will treat them as the same %n operand, which is the case here.
 
-   end CPUID_Level;
+Just as the @code{Outputs} parameter causes the register to be stored into the
+target variable after execution of the assembler statements, so does the
+@code{Inputs} parameter cause its variable to be loaded into the register
+before execution of the assembler statements.
 
-   --------------------------------
-   --  Get CPU Vendor ID String  --
-   --------------------------------
+Thus the effect of the @code{Asm} invocation is:
+@enumerate
+@item load the 32-bit value of @code{Value} into eax
+@item execute the @code{incl %eax} instruction
+@item store the contents of eax into the @code{Result} variable
+@end enumerate
 
-   --  The vendor ID string is returned in the ebx, ecx and edx register
-   --  after executing the CPUID instruction with eax set to zero.
-   --  In case of a true Intel processor the string returned is
-   --  "GenuineIntel"
+The resulting assembler file (with @option{-O2} optimization) contains:
+@smallexample
+@group
+_increment__incr.1:
+   subl $4,%esp
+   movl 8(%esp),%eax
+#APP
+   incl %eax
+#NO_APP
+   movl %eax,%edx
+   movl %ecx,(%esp)
+   addl $4,%esp
+   ret
+@end group
+@end smallexample
 
-   function Vendor_ID return String is
+@c ---------------------------------------------------------------------------
+@node Inlining Inline Assembler Code
+@section Inlining Inline Assembler Code
 
-      Ebx, Ecx, Edx : Unsigned_Register;
-      --  registers containing the vendor ID string
+@noindent
+For a short subprogram such as the @code{Incr} function in the previous
+section, the overhead of the call and return (creating / deleting the stack
+frame) can be significant, compared to the amount of code in the subprogram
+body.  A solution is to apply Ada's @code{Inline} pragma to the subprogram,
+which directs the compiler to expand invocations of the subprogram at the
+point(s) of call, instead of setting up a stack frame for out-of-line calls.
+Here is the resulting program:
 
-      Vendor_ID : String (1 .. 12);
-      -- the vendor ID string
+@smallexample @c ada
+@group
+with Interfaces; use Interfaces;
+with Ada.Text_IO; use Ada.Text_IO;
+with System.Machine_Code; use System.Machine_Code;
+procedure Increment_2 is
 
+   function Incr (Value : Unsigned_32) return Unsigned_32 is
+      Result : Unsigned_32;
    begin
+      Asm ("incl %0",
+           Inputs  => Unsigned_32'Asm_Input ("a", Value),
+           Outputs => Unsigned_32'Asm_Output ("=a", Result));
+      return Result;
+   end Incr;
+   pragma Inline (Increment);
 
-      --  execute CPUID, storing the results in the processor registers
-      Asm (
-
-           --  the assembler code
-           "cpuid",    --  execute CPUID
-
-           --  zero stored in eax
-           --  vendor ID string returned in ebx, ecx and edx
-           Inputs => Unsigned_32'Asm_input ("a", 0),
-
-           --  ebx is stored in Ebx
-           --  ecx is stored in Ecx
-           --  edx is stored in Edx
-           Outputs => (Unsigned_Register'Asm_output ("=b", Ebx),
-                       Unsigned_Register'Asm_output ("=c", Ecx),
-                       Unsigned_Register'Asm_output ("=d", Edx)));
-
-      --  now build the vendor ID string
-      Vendor_ID( 1) := Character'Val (Ebx.L1);
-      Vendor_ID( 2) := Character'Val (Ebx.H1);
-      Vendor_ID( 3) := Character'Val (Ebx.L2);
-      Vendor_ID( 4) := Character'Val (Ebx.H2);
-      Vendor_ID( 5) := Character'Val (Edx.L1);
-      Vendor_ID( 6) := Character'Val (Edx.H1);
-      Vendor_ID( 7) := Character'Val (Edx.L2);
-      Vendor_ID( 8) := Character'Val (Edx.H2);
-      Vendor_ID( 9) := Character'Val (Ecx.L1);
-      Vendor_ID(10) := Character'Val (Ecx.H1);
-      Vendor_ID(11) := Character'Val (Ecx.L2);
-      Vendor_ID(12) := Character'Val (Ecx.H2);
-
-      --  return string
-      return Vendor_ID;
-
-   end Vendor_ID;
+   Value : Unsigned_32;
 
-   -------------------------------
-   --  Get processor signature  --
-   -------------------------------
+begin
+   Value := 5;
+   Put_Line ("Value before is" & Value'Img);
+   Value := Increment (Value);
+   Put_Line ("Value after is" & Value'Img);
+end Increment_2;
+@end group
+@end smallexample
 
-   function Signature return Processor_Signature is
+Compile the program with both optimization (@option{-O2}) and inlining
+enabled (@option{-gnatpn} instead of @option{-gnatp}).
 
-      Result : Processor_Signature;
-      --  processor signature returned
+The @code{Incr} function is still compiled as usual, but at the
+point in @code{Increment} where our function used to be called:
 
-   begin
+@smallexample
+@group
+pushl %edi
+call _increment__incr.1
+@end group
+@end smallexample
 
-      --  execute CPUID, storing the results in the Result variable
-      Asm (
+@noindent
+the code for the function body directly appears:
 
-           --  the assembler code
-           "cpuid",    --  execute CPUID
+@smallexample
+@group
+movl %esi,%eax
+#APP
+   incl %eax
+#NO_APP
+   movl %eax,%edx
+@end group
+@end smallexample
 
-           --  one is stored in eax
-           --  processor signature returned in eax
-           Inputs => Unsigned_32'Asm_input ("a", 1),
+@noindent
+thus saving the overhead of stack frame setup and an out-of-line call.
 
-           --  eax is stored in Result
-           Outputs => Processor_Signature'Asm_output ("=a", Result),
+@c ---------------------------------------------------------------------------
+@node Other Asm Functionality
+@section Other @code{Asm} Functionality
 
-           --  tell compiler that ebx, ecx and edx are also destroyed
-           Clobber => "ebx, ecx, edx");
+@noindent
+This section describes two important parameters to the @code{Asm}
+procedure: @code{Clobber}, which identifies register usage;
+and @code{Volatile}, which inhibits unwanted optimizations.
 
-      --  return processor signature
-      return Result;
+@menu
+* The Clobber Parameter::
+* The Volatile Parameter::
+@end menu
 
-   end Signature;
+@c ---------------------------------------------------------------------------
+@node The Clobber Parameter
+@subsection The @code{Clobber} Parameter
 
-   ------------------------------
-   --  Get processor features  --
-   ------------------------------
+@noindent
+One of the dangers of intermixing assembly language and a compiled language
+such as Ada is that the compiler needs to be aware of which registers are
+being used by the assembly code.  In some cases, such as the earlier examples,
+the constraint string is sufficient to indicate register usage (e.g.,
+@code{"a"} for
+the eax register).  But more generally, the compiler needs an explicit
+identification of the registers that are used by the Inline Assembly
+statements.
 
-   function Features return Processor_Features is
+Using a register that the compiler doesn't know about
+could be a side effect of an instruction (like @code{mull}
+storing its result in both eax and edx).
+It can also arise from explicit register usage in your
+assembly code; for example:
+@smallexample
+@group
+Asm ("movl %0, %%ebx" & LF & HT &
+     "movl %%ebx, %1",
+     Inputs  => Unsigned_32'Asm_Input  ("g", Var_In),
+     Outputs => Unsigned_32'Asm_Output ("=g", Var_Out));
+@end group
+@end smallexample
+@noindent
+where the compiler (since it does not analyze the @code{Asm} template string)
+does not know you are using the ebx register.
 
-      Result : Processor_Features;
-      --  processor features returned
+In such cases you need to supply the @code{Clobber} parameter to @code{Asm},
+to identify the registers that will be used by your assembly code:
 
-   begin
+@smallexample
+@group
+Asm ("movl %0, %%ebx" & LF & HT &
+     "movl %%ebx, %1",
+     Inputs  => Unsigned_32'Asm_Input  ("g", Var_In),
+     Outputs => Unsigned_32'Asm_Output ("=g", Var_Out),
+     Clobber => "ebx");
+@end group
+@end smallexample
 
-      --  execute CPUID, storing the results in the Result variable
-      Asm (
+The Clobber parameter is a static string expression specifying the
+register(s) you are using.  Note that register names are @emph{not} prefixed
+by a percent sign. Also, if more than one register is used then their names
+are separated by commas; e.g., @code{"eax, ebx"}
 
-           --  the assembler code
-           "cpuid",    --  execute CPUID
+The @code{Clobber} parameter has several additional uses:
+@enumerate
+@item Use ``register'' name @code{cc} to indicate that flags might have changed
+@item Use ``register'' name @code{memory} if you changed a memory location
+@end enumerate
 
-           --  one stored in eax
-           --  processor features returned in edx
-           Inputs => Unsigned_32'Asm_input ("a", 1),
+@c ---------------------------------------------------------------------------
+@node The Volatile Parameter
+@subsection The @code{Volatile} Parameter
+@cindex Volatile parameter
 
-           --  edx is stored in Result
-           Outputs => Processor_Features'Asm_output ("=d", Result),
+@noindent
+Compiler optimizations in the presence of Inline Assembler may sometimes have
+unwanted effects.  For example, when an @code{Asm} invocation with an input
+variable is inside a loop, the compiler might move the loading of the input
+variable outside the loop, regarding it as a one-time initialization.
 
-           --  tell compiler that ebx and ecx are also destroyed
-           Clobber => "ebx, ecx");
+If this effect is not desired, you can disable such optimizations by setting
+the @code{Volatile} parameter to @code{True}; for example:
 
-      --  return processor signature
-      return Result;
+@smallexample @c ada
+@group
+Asm ("movl %0, %%ebx" & LF & HT &
+     "movl %%ebx, %1",
+     Inputs   => Unsigned_32'Asm_Input  ("g", Var_In),
+     Outputs  => Unsigned_32'Asm_Output ("=g", Var_Out),
+     Clobber  => "ebx",
+     Volatile => True);
+@end group
+@end smallexample
 
-   end Features;
+By default, @code{Volatile} is set to @code{False} unless there is no
+@code{Outputs} parameter.
 
-end Intel_CPU;
-@end smallexample
+Although setting @code{Volatile} to @code{True} prevents unwanted
+optimizations, it will also disable other optimizations that might be
+important for efficiency. In general, you should set @code{Volatile}
+to @code{True} only if the compiler's optimizations have created
+problems.
 @c END OF INLINE ASSEMBLER CHAPTER
 @c ===============================
 
-
-
 @c ***********************************
 @c * Compatibility and Porting Guide *
 @c ***********************************
@@ -25491,26 +28792,34 @@ end Intel_CPU;
 
 @noindent
 This chapter describes the compatibility issues that may arise between
-GNAT and other Ada 83 and Ada 95 compilation systems, and shows how GNAT
-can expedite porting
+GNAT and other Ada compilation systems (including those for Ada 83),
+and shows how GNAT can expedite porting
 applications developed in other Ada environments.
 
 @menu
 * Compatibility with Ada 83::
+* Compatibility between Ada 95 and Ada 2005::
 * Implementation-dependent characteristics::
-* Compatibility with DEC Ada 83::
-* Compatibility with Other Ada 95 Systems::
+* Compatibility with Other Ada Systems::
 * Representation Clauses::
+@ifclear vms
+@c Brief section is only in non-VMS version
+@c Full chapter is in VMS version
+* Compatibility with HP Ada 83::
+@end ifclear
+@ifset vms
+* Transitioning to 64-Bit GNAT for OpenVMS::
+@end ifset
 @end menu
 
 @node Compatibility with Ada 83
 @section Compatibility with Ada 83
-@cindex Compatibility (between Ada 83 and Ada 95)
+@cindex Compatibility (between Ada 83 and Ada 95 / Ada 2005)
 
 @noindent
-Ada 95 is designed to be highly upwards compatible with Ada 83.  In
-particular, the design intention is that the difficulties associated
-with moving from Ada 83 to Ada 95 should be no greater than those
+Ada 95 and Ada 2005 are highly upwards compatible with Ada 83.  In
+particular, the design intention was that the difficulties associated
+with moving from Ada 83 to Ada 95 or Ada 2005 should be no greater than those
 that occur when moving from one Ada 83 system to another.
 
 However, there are a number of points at which there are minor
@@ -25530,21 +28839,25 @@ following subsections treat the most likely issues to be encountered.
 @node Legal Ada 83 programs that are illegal in Ada 95
 @subsection Legal Ada 83 programs that are illegal in Ada 95
 
-@table @asis
+Some legal Ada 83 programs are illegal (i.e. they will fail to compile) in
+Ada 95 and thus also in Ada 2005:
+
+@table @emph
 @item Character literals
 Some uses of character literals are ambiguous.  Since Ada 95 has introduced
 @code{Wide_Character} as a new predefined character type, some uses of
 character literals that were legal in Ada 83 are illegal in Ada 95.
 For example:
 @smallexample @c ada
-   for Char in 'A' .. 'Z' loop ... end loop;
+   for Char in 'A' .. 'Z' loop @dots{} end loop;
 @end smallexample
+
 @noindent
 The problem is that @code{'A'} and @code{'Z'} could be from either
 @code{Character} or @code{Wide_Character}.  The simplest correction
 is to make the type explicit; e.g.:
 @smallexample @c ada
-   for Char in Character range 'A' .. 'Z' loop ... end loop;
+   for Char in Character range 'A' .. 'Z' loop @dots{} end loop;
 @end smallexample
 
 @item New reserved words
@@ -25564,7 +28877,7 @@ the item nearer to the declaration of the entity to which it refers.
 A particular case is that representation pragmas
 @ifset vms
 (including the
-extended DEC Ada 83 compatibility pragmas such as @code{Export_Procedure})
+extended HP Ada 83 compatibility pragmas such as @code{Export_Procedure})
 @end ifset
 cannot be applied to a subprogram body.  If necessary, a separate subprogram
 declaration must be introduced to which the pragma can be applied.
@@ -25614,7 +28927,7 @@ the fix is usually simply to add the @code{(<>)} to the generic declaration.
 @node More deterministic semantics
 @subsection More deterministic semantics
 
-@table @asis
+@table @emph
 @item Conversions
 Conversions from real types to integer types round away from 0.  In Ada 83
 the conversion Integer(2.5) could deliver either 2 or 3 as its value.  This
@@ -25641,8 +28954,8 @@ possible in Ada 83.  Fortunately this is extremely rare, but the one
 situation that you should be alert to is the change in the predefined type
 @code{Character} from 7-bit ASCII to 8-bit Latin-1.
 
-@table @asis
-@item range of @code{Character}
+@table @emph
+@item Range of type @code{Character}
 The range of @code{Standard.Character} is now the full 256 characters
 of Latin-1, whereas in most Ada 83 implementations it was restricted
 to 128 characters. Although some of the effects of
@@ -25666,28 +28979,85 @@ covers only the restricted range.
 
 @node Other language compatibility issues
 @subsection Other language compatibility issues
-@table @asis
-@item @option{-gnat83 switch}
+
+@table @emph
+@item @option{-gnat83} switch
 All implementations of GNAT provide a switch that causes GNAT to operate
 in Ada 83 mode.  In this mode, some but not all compatibility problems
 of the type described above are handled automatically.  For example, the
-new Ada 95 reserved words are treated simply as identifiers as in Ada 83.
+new reserved words introduced in Ada 95 and Ada 2005 are treated simply
+as identifiers as in Ada 83.
 However,
 in practice, it is usually advisable to make the necessary modifications
 to the program to remove the need for using this switch.
-See @ref{Compiling Ada 83 Programs}.
+See @ref{Compiling Different Versions of Ada}.
 
 @item Support for removed Ada 83 pragmas and attributes
-A number of pragmas and attributes from Ada 83 have been removed from Ada 95,
-generally because they have been replaced by other mechanisms.  Ada 95
+A number of pragmas and attributes from Ada 83 were removed from Ada 95,
+generally because they were replaced by other mechanisms.  Ada 95 and Ada 2005
 compilers are allowed, but not required, to implement these missing
-elements.  In contrast with some other Ada 95 compilers, GNAT implements all
+elements.  In contrast with some other compilers, GNAT implements all
 such pragmas and attributes, eliminating this compatibility concern.  These
 include @code{pragma Interface} and the floating point type attributes
 (@code{Emax}, @code{Mantissa}, etc.), among other items.
 @end table
 
 
+@node Compatibility between Ada 95 and Ada 2005
+@section Compatibility between Ada 95 and Ada 2005
+@cindex Compatibility between Ada 95 and Ada 2005
+
+@noindent
+Although Ada 2005 was designed to be upwards compatible with Ada 95, there are
+a number of incompatibilities. Several are enumerated below;
+for a complete description please see the
+Annotated Ada 2005 Reference Manual, or section 9.1.1 in
+@cite{Rationale for Ada 2005}.
+
+@table @emph
+@item New reserved words.
+The words @code{interface}, @code{overriding} and @code{synchronized} are
+reserved in Ada 2005.
+A pre-Ada 2005 program that uses any of these as an identifier will be
+illegal.
+
+@item New declarations in predefined packages.
+A number of packages in the predefined environment contain new declarations:
+@code{Ada.Exceptions}, @code{Ada.Real_Time}, @code{Ada.Strings},
+@code{Ada.Strings.Fixed}, @code{Ada.Strings.Bounded},
+@code{Ada.Strings.Unbounded}, @code{Ada.Strings.Wide_Fixed},
+@code{Ada.Strings.Wide_Bounded}, @code{Ada.Strings.Wide_Unbounded},
+@code{Ada.Tags}, @code{Ada.Text_IO}, and @code{Interfaces.C}.
+If an Ada 95 program does a @code{with} and @code{use} of any of these
+packages, the new declarations may cause name clashes.
+
+@item Access parameters.
+A nondispatching subprogram with an access parameter cannot be renamed
+as a dispatching operation.  This was permitted in Ada 95.
+
+@item Access types, discriminants, and constraints.
+Rule changes in this area have led to some incompatibilities; for example,
+constrained subtypes of some access types are not permitted in Ada 2005.
+
+@item Aggregates for limited types.
+The allowance of aggregates for limited types in Ada 2005 raises the
+possibility of ambiguities in legal Ada 95 programs, since additional types
+now need to be considered in expression resolution.
+
+@item Fixed-point multiplication and division.
+Certain expressions involving ``*'' or ``/'' for a fixed-point type, which
+were legal in Ada 95 and invoked the predefined versions of these operations,
+are now ambiguous.
+The ambiguity may be resolved either by applying a type conversion to the
+expression, or by explicitly invoking the operation from package
+@code{Standard}.
+
+@item Return-by-reference types.
+The Ada 95 return-by-reference mechanism has been removed.  Instead, the user
+can declare a function returning a value from an anonymous access type.
+@end table
+
+
 @node Implementation-dependent characteristics
 @section Implementation-dependent characteristics
 @noindent
@@ -25708,7 +29078,6 @@ transition from certain Ada 83 compilers.
 * Target-specific aspects::
 @end menu
 
-
 @node Implementation-defined pragmas
 @subsection Implementation-defined pragmas
 
@@ -25719,7 +29088,7 @@ are described in the GNAT Reference Manual, and these include several that
 are specifically intended to correspond to other vendors' Ada 83 pragmas.
 For migrating from VADS, the pragma @code{Use_VADS_Size} may be useful.
 For
-compatibility with DEC Ada 83, GNAT supplies the pragmas
+compatibility with HP Ada 83, GNAT supplies the pragmas
 @code{Extend_System}, @code{Ident}, @code{Inline_Generic},
 @code{Interface_Name}, @code{Passive}, @code{Suppress_All},
 and @code{Volatile}.
@@ -25738,7 +29107,7 @@ implementation.  All GNAT-defined attributes are described in the
 @cite{GNAT Reference Manual}, and these include several that are specifically
 intended
 to correspond to other vendors' Ada 83 attributes.  For migrating from VADS,
-the attribute @code{VADS_Size} may be useful.  For compatibility with DEC
+the attribute @code{VADS_Size} may be useful.  For compatibility with HP
 Ada 83, GNAT supplies the attributes @code{Bit}, @code{Machine_Size} and
 @code{Type_Class}.
 
@@ -25747,7 +29116,7 @@ Ada 83, GNAT supplies the attributes @code{Bit}, @code{Machine_Size} and
 @noindent
 Vendors may supply libraries to supplement the standard Ada API.  If Ada 83
 code uses vendor-specific libraries then there are several ways to manage
-this in Ada 95:
+this in Ada 95 or Ada 2005:
 @enumerate
 @item
 If the source code for the libraries (specifications and bodies) are
@@ -25757,7 +29126,7 @@ application.
 If the source code for the specifications but not the bodies are
 available, then you can reimplement the bodies.
 @item
-Some new Ada 95 features obviate the need for library support.  For
+Some features introduced by Ada 95 obviate the need for library support.  For
 example most Ada 83 vendors supplied a package for unsigned integers.  The
 Ada 95 modular type feature is the preferred way to handle this need, so
 instead of migrating or reimplementing the unsigned integer package it may
@@ -25773,7 +29142,8 @@ Program_Error being raised due to an ``Access Before Elaboration'': an attempt
 to invoke a subprogram its body has been elaborated, or to instantiate a
 generic before the generic body has been elaborated.  By default GNAT
 attempts to choose a safe order (one that will not encounter access before
-elaboration problems) by implicitly inserting Elaborate_All pragmas where
+elaboration problems) by implicitly inserting @code{Elaborate} or
+@code{Elaborate_All} pragmas where
 needed.  However, this can lead to the creation of elaboration circularities
 and a resulting rejection of the program by gnatbind.  This issue is
 thoroughly described in @ref{Elaboration Order Handling in GNAT}.
@@ -25801,24 +29171,27 @@ representations, interfacing with assembler code, and similar issues.  If
 such an Ada 83 application is being ported to different target hardware (for
 example where the byte endianness has changed) then you will need to
 carefully examine the program logic; the porting effort will heavily depend
-on the robustness of the original design.  Moreover, Ada 95 is sometimes
+on the robustness of the original design.  Moreover, Ada 95 (and thus
+Ada 2005) are sometimes
 incompatible with typical Ada 83 compiler practices regarding implicit
 packing, the meaning of the Size attribute, and the size of access values.
 GNAT's approach to these issues is described in @ref{Representation Clauses}.
 
-
-@node Compatibility with Other Ada 95 Systems
-@section Compatibility with Other Ada 95 Systems
+@node Compatibility with Other Ada Systems
+@section Compatibility with Other Ada Systems
 
 @noindent
-Providing that programs avoid the use of implementation dependent and
-implementation defined features of Ada 95, as documented in the Ada 95
-reference manual, there should be a high degree of portability between
-GNAT and other Ada 95 systems.  The following are specific items which
-have proved troublesome in moving GNAT programs to other Ada 95
+If programs avoid the use of implementation dependent and
+implementation defined features, as documented in the @cite{Ada
+Reference Manual}, there should be a high degree of portability between
+GNAT and other Ada systems.  The following are specific items which
+have proved troublesome in moving Ada 95 programs from GNAT to other Ada 95
 compilers, but do not affect porting code to GNAT@.
+(As of @value{NOW}, GNAT is the only compiler available for Ada 2005;
+the following issues may or may not arise for Ada 2005 programs
+when other compilers appear.)
 
-@table @asis
+@table @emph
 @item Ada 83 Pragmas and Attributes
 Ada 95 compilers are allowed, but not required, to implement the missing
 Ada 83 pragmas and attributes that are no longer defined in Ada 95.
@@ -25826,7 +29199,7 @@ GNAT implements all such pragmas and attributes, eliminating this as
 a compatibility concern, but some other Ada 95 compilers reject these
 pragmas and attributes.
 
-@item Special-needs Annexes
+@item Specialized Needs Annexes
 GNAT implements the full set of special needs annexes.  At the
 current time, it is the only Ada 95 compiler to do so.  This means that
 programs making use of these features may not be portable to other Ada
@@ -25844,21 +29217,21 @@ far beyond this minimal set, as described in the next section.
 @noindent
 The Ada 83 reference manual was quite vague in describing both the minimal
 required implementation of representation clauses, and also their precise
-effects.  The Ada 95 reference manual is much more explicit, but the minimal
-set of capabilities required in Ada 95 is quite limited.
+effects.  Ada 95 (and thus also Ada 2005) are much more explicit, but the
+minimal set of capabilities required is still quite limited.
 
-GNAT implements the full required set of capabilities described in the
-Ada 95 reference manual, but also goes much beyond this, and in particular
+GNAT implements the full required set of capabilities in
+Ada 95 and Ada 2005, but also goes much further, and in particular
 an effort has been made to be compatible with existing Ada 83 usage to the
 greatest extent possible.
 
 A few cases exist in which Ada 83 compiler behavior is incompatible with
-requirements in the Ada 95 reference manual.  These are instances of
+the requirements in Ada 95 (and thus also Ada 2005).  These are instances of
 intentional or accidental dependence on specific implementation dependent
 characteristics of these Ada 83 compilers.  The following is a list of
-the cases most likely to arise in existing legacy Ada 83 code.
+the cases most likely to arise in existing Ada 83 code.
 
-@table @asis
+@table @emph
 @item Implicit Packing
 Some Ada 83 compilers allowed a Size specification to cause implicit
 packing of an array or record.  This could cause expensive implicit
@@ -25866,17 +29239,17 @@ conversions for change of representation in the presence of derived
 types, and the Ada design intends to avoid this possibility.
 Subsequent AI's were issued to make it clear that such implicit
 change of representation in response to a Size clause is inadvisable,
-and this recommendation is represented explicitly in the Ada 95 RM
-as implementation advice that is followed by GNAT@.
+and this recommendation is represented explicitly in the Ada 95 (and Ada 2005)
+Reference Manuals as implementation advice that is followed by GNAT@.
 The problem will show up as an error
 message rejecting the size clause.  The fix is simply to provide
 the explicit pragma @code{Pack}, or for more fine tuned control, provide
 a Component_Size clause.
 
 @item Meaning of Size Attribute
-The Size attribute in Ada 95 for discrete types is defined as being the
-minimal number of bits required to hold values of the type.  For example,
-on a 32-bit machine, the size of Natural will typically be 31 and not
+The Size attribute in Ada 95 (and Ada 2005) for discrete types is defined as
+the minimal number of bits required to hold values of the type.  For example,
+on a 32-bit machine, the size of @code{Natural} will typically be 31 and not
 32 (since no sign bit is required).  Some Ada 83 compilers gave 31, and
 some 32 in this situation.  This problem will usually show up as a compile
 time error, but not always.  It is a good idea to check all uses of the
@@ -25919,48 +29292,51 @@ is to use a component size clause for the element size in an array,
 or a record representation clause for an access field in a record.
 @end table
 
-@node Compatibility with DEC Ada 83
-@section Compatibility with DEC Ada 83
+@ifclear vms
+@c This brief section is only in the non-VMS version
+@c The complete chapter on HP Ada is in the VMS version
+@node Compatibility with HP Ada 83
+@section Compatibility with HP Ada 83
 
 @noindent
 The VMS version of GNAT fully implements all the pragmas and attributes
-provided by DEC Ada 83, as well as providing the standard DEC Ada 83
+provided by HP Ada 83, as well as providing the standard HP Ada 83
 libraries, including Starlet.  In addition, data layouts and parameter
 passing conventions are highly compatible.  This means that porting
-existing DEC Ada 83 code to GNAT in VMS systems should be easier than
+existing HP Ada 83 code to GNAT in VMS systems should be easier than
 most other porting efforts.  The following are some of the most
-significant differences between GNAT and DEC Ada 83.
+significant differences between GNAT and HP Ada 83.
 
-@table @asis
+@table @emph
 @item Default floating-point representation
-In GNAT, the default floating-point format is IEEE, whereas in DEC Ada 83,
+In GNAT, the default floating-point format is IEEE, whereas in HP Ada 83,
 it is VMS format.  GNAT does implement the necessary pragmas
 (Long_Float, Float_Representation) for changing this default.
 
 @item System
 The package System in GNAT exactly corresponds to the definition in the
 Ada 95 reference manual, which means that it excludes many of the
-DEC Ada 83 extensions.  However, a separate package Aux_DEC is provided
+HP Ada 83 extensions.  However, a separate package Aux_DEC is provided
 that contains the additional definitions, and a special pragma,
 Extend_System allows this package to be treated transparently as an
 extension of package System.
 
 @item To_Address
 The definitions provided by Aux_DEC are exactly compatible with those
-in the DEC Ada 83 version of System, with one exception.
-DEC Ada provides the following declarations:
+in the HP Ada 83 version of System, with one exception.
+HP Ada provides the following declarations:
 
 @smallexample @c ada
 TO_ADDRESS (INTEGER)
 TO_ADDRESS (UNSIGNED_LONGWORD)
-TO_ADDRESS (universal_integer)
+TO_ADDRESS (@i{universal_integer})
 @end smallexample
 
 @noindent
-The version of TO_ADDRESS taking a universal integer argument is in fact
+The version of TO_ADDRESS taking a @i{universal integer} argument is in fact
 an extension to Ada 83 not strictly compatible with the reference manual.
 In GNAT, we are constrained to be exactly compatible with the standard,
-and this means we cannot provide this capability.  In DEC Ada 83, the
+and this means we cannot provide this capability.  In HP Ada 83, the
 point of this definition is to deal with a call like:
 
 @smallexample @c ada
@@ -25970,11 +29346,11 @@ TO_ADDRESS (16#12777#);
 @noindent
 Normally, according to the Ada 83 standard, one would expect this to be
 ambiguous, since it matches both the INTEGER and UNSIGNED_LONGWORD forms
-of TO_ADDRESS@.  However, in DEC Ada 83, there is no ambiguity, since the
-definition using universal_integer takes precedence.
+of TO_ADDRESS@.  However, in HP Ada 83, there is no ambiguity, since the
+definition using @i{universal_integer} takes precedence.
 
-In GNAT, since the version with universal_integer cannot be supplied, it is
-not possible to be 100% compatible.  Since there are many programs using
+In GNAT, since the version with @i{universal_integer} cannot be supplied, it
+is not possible to be 100% compatible.  Since there are many programs using
 numeric constants for the argument to TO_ADDRESS, the decision in GNAT was
 to change the name of the function in the UNSIGNED_LONGWORD case, so the
 declarations provided in the GNAT version of AUX_Dec are:
@@ -25998,17 +29374,423 @@ does not provide a specified value for the Task_Id of the environment task,
 which in GNAT is treated like any other declared task.
 @end table
 
+@noindent
 For full details on these and other less significant compatibility issues,
-see appendix E of the Digital publication entitled @cite{DEC Ada, Technical
-Overview and Comparison on DIGITAL Platforms}.
+see appendix E of the HP publication entitled @cite{HP Ada, Technical
+Overview and Comparison on HP Platforms}.
 
-For GNAT running on other than VMS systems, all the DEC Ada 83 pragmas and
+For GNAT running on other than VMS systems, all the HP Ada 83 pragmas and
 attributes are recognized, although only a subset of them can sensibly
-be implemented.  The description of pragmas in this reference manual
+be implemented.  The description of pragmas in the
+@cite{GNAT Reference Manual}
 indicates whether or not they are applicable to non-VMS systems.
+@end ifclear
+
+@ifset vms
+@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::
+* Migration of 32 bit code::
+* Taking advantage of 64 bit addressing::
+* Technical details::
+@end menu
+
+@node Introduction to transitioning
+@subsection Introduction
+
+@noindent
+64-bit @value{EDITION} for Open VMS has been designed to meet
+three main goals:
+
+@enumerate
+@item
+Providing a full conforming implementation of Ada 95 and Ada 2005
+
+@item
+Allowing maximum backward compatibility, thus easing migration of existing
+Ada source code
+
+@item
+Supplying a path for exploiting the full 64-bit address range
+@end enumerate
+
+@noindent
+Ada's strong typing semantics has made it
+impractical to have different 32-bit and 64-bit modes. As soon as
+one object could possibly be outside the 32-bit address space, this
+would make it necessary for the @code{System.Address} type to be 64 bits.
+In particular, this would cause inconsistencies if 32-bit code is
+called from 64-bit code that raises an exception.
+
+This issue has been resolved by always using 64-bit addressing
+at the system level, but allowing for automatic conversions between
+32-bit and 64-bit addresses where required. Thus users who
+do not currently require 64-bit addressing capabilities, can
+recompile their code with only minimal changes (and indeed
+if the code is written in portable Ada, with no assumptions about
+the size of the @code{Address} type, then no changes at all are necessary).
+At the same time,
+this approach provides a simple, gradual upgrade path to future
+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.
+
+@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 64-bit address space,
+@ref{Taking advantage of 64 bit addressing},
+will consider further changes that may be required.
+Such code will be referred to below as @emph{64-bit code}.
+
+@node Migration of 32 bit code
+@subsection Migration of 32-bit code
+
+@menu
+* Address types::
+* Access types::
+* Unchecked conversions::
+* Predefined constants::
+* Interfacing with C::
+* Experience with source compatibility::
+@end menu
+
+@node Address types
+@subsubsection Address types
+
+@noindent
+To solve the problem of mixing 64-bit and 32-bit addressing,
+while maintaining maximum backward compatibility, the following
+approach has been taken:
+
+@itemize @bullet
+@item
+@code{System.Address} always has a size of 64 bits
+
+@item
+@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 parameter passing conventions,
+even imported
+and exported subprograms that have 32-bit address parameters are
+compatible with those that have 64-bit address parameters.
+(See @ref{Making code 64 bit clean} for details.)
+
+The areas that may need attention are those where record types have
+been defined that contain components of the type @code{System.Address}, and
+where objects of this type are passed to code expecting a record layout with
+32-bit addresses.
+
+Different compilers on different platforms cannot be
+expected to represent the same type in the same way,
+since alignment constraints
+and other system-dependent properties affect the compiler's decision.
+For that reason, Ada code
+generally uses representation clauses to specify the expected
+layout where required.
+
+If such a representation clause uses 32 bits for a component having
+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
+leave the size as 32 bits and change the type to @code{System.Short_Address}.
+Since @code{Short_Address} is a subtype of @code{Address}, no changes are
+required in any code setting or accessing the field; the compiler will
+automatically perform any needed conversions between address
+formats.
+
+@node Access types
+@subsubsection Access types
+
+@noindent
+By default, objects designated by access values are always
+allocated in the 32-bit
+address space. Thus legacy code will never contain
+any objects that are not addressable with 32-bit addresses, and
+the compiler will never raise exceptions as result of mixing
+32-bit and 64-bit addresses.
+
+However, the access values themselves are represented in 64 bits, for optimum
+performance and future compatibility with 64-bit code. As was
+the case with @code{System.Address}, the compiler will give an error message
+if an object or record component has a representation clause that
+requires the access value to fit in 32 bits. In such a situation,
+an explicit size clause for the access type, specifying 32 bits,
+will have the desired effect.
+
+General access types (declared with @code{access all}) can never be
+32 bits, as values of such types must be able to refer to any object
+of the  designated type,
+including objects residing outside the 32-bit address range.
+Existing Ada 83 code will not contain such type definitions,
+however, since general access types were introduced in Ada 95.
+
+@node Unchecked conversions
+@subsubsection Unchecked conversions
+
+@noindent
+In the case of an @code{Unchecked_Conversion} where the source type is a
+64-bit access type or the type @code{System.Address}, and the target
+type is a 32-bit type, the compiler will generate a warning.
+Even though the generated code will still perform the required
+conversions, it is highly recommended in these cases to use
+respectively a 32-bit access type or @code{System.Short_Address}
+as the source type.
+
+@node Predefined constants
+@subsubsection Predefined constants
+
+@noindent
+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
+If you need to refer to the specific
+memory size of a 32-bit implementation, instead of the
+actual memory size, use @code{System.Short_Memory_Size}
+rather than @code{System.Memory_Size}.
+Similarly, references to @code{System.Address_Size} may need
+to be replaced by @code{System.Short_Address'Size}.
+The program @command{gnatfind} may be useful for locating
+references to the above constants, so that you can verify that they
+are still correct.
+
+@node Interfacing with C
+@subsubsection Interfacing with C
+
+@noindent
+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 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
+file @file{jibdef.ads}
+where a representation clause for a record type specified
+32 bits for a component of type @code{Address}.
+All of these errors were detected by the compiler.
+The repair was obvious and immediate; to simply replace @code{Address} by
+@code{Short_Address}.
+
+In the case of STARLET, there were several record types that should
+have had representation clauses but did not.  In these record types
+there was an implicit assumption that an @code{Address} value occupied
+32 bits.
+These compiled without error, but their usage resulted in run-time error
+returns from STARLET system calls.
+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
+@subsection Taking advantage of 64-bit addressing
+
+@menu
+* Making code 64 bit clean::
+* Allocating memory from the 64 bit storage pool::
+* Restrictions on use of 64 bit objects::
+* Using 64 bit storage pools by default::
+* General access types::
+* STARLET and other predefined libraries::
+@end menu
+
+@node Making code 64 bit clean
+@subsubsection Making code 64-bit clean
+
+@noindent
+In order to prevent problems that may occur when (parts of) a
+system start using memory outside the 32-bit address range,
+we recommend some additional guidelines:
+
+@itemize @bullet
+@item
+For imported subprograms that take parameters of the
+type @code{System.Address}, ensure that these subprograms can
+indeed handle 64-bit addresses. If not, or when in doubt,
+change the subprogram declaration to specify
+@code{System.Short_Address} instead.
+
+@item
+Resolve all warnings related to size mismatches in
+unchecked conversions. Failing to do so causes
+erroneous execution if the source object is outside
+the 32-bit address space.
 
+@item
+(optional) Explicitly use the 32-bit storage pool
+for access types used in a 32-bit context, or use
+generic access types where possible
+(@pxref{Restrictions on use of 64 bit objects}).
+@end itemize
+
+@noindent
+If these rules are followed, the compiler will automatically insert
+any necessary checks to ensure that no addresses or access values
+passed to 32-bit code ever refer to objects outside the 32-bit
+address range.
+Any attempt to do this will raise @code{Constraint_Error}.
+
+@node Allocating memory from the 64 bit storage pool
+@subsubsection Allocating memory from the 64-bit storage pool
+
+@noindent
+For any access type @code{T} that potentially requires memory allocations
+beyond the 32-bit address space,
+use the following representation clause:
+
+@smallexample @c ada
+   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
+
+@noindent
+Taking the address of an object allocated from a 64-bit storage pool,
+and then passing this address to a subprogram expecting
+@code{System.Short_Address},
+or assigning it to a variable of type @code{Short_Address}, will cause
+@code{Constraint_Error} to be raised. In case the code is not 64-bit clean
+(@pxref{Making code 64 bit clean}), or checks are suppressed,
+no exception is raised and execution
+will become erroneous.
+
+@node Using 64 bit storage pools by default
+@subsubsection Using 64-bit storage pools by default
+
+@noindent
+In some cases it may be desirable to have the compiler allocate
+from 64-bit storage pools by default. This may be the case for
+libraries that are 64-bit clean, but may be used in both 32-bit
+and 64-bit contexts. For these cases the following configuration
+pragma may be specified:
+
+@smallexample @c ada
+  pragma Pool_64_Default;
+@end smallexample
+
+@noindent
+Any code compiled in the context of this pragma will by default
+use the @code{System.Pool_64} storage pool. This default may be overridden
+for a specific access type @code{T} by the representation clause:
+
+@smallexample @c ada
+   for T'Storage_Pool use System.Pool_32;
+@end smallexample
+
+@noindent
+Any object whose address may be passed to a subprogram with a
+@code{Short_Address} argument, or assigned to a variable of type
+@code{Short_Address}, needs to be allocated from this pool.
+
+@node General access types
+@subsubsection General access types
+
+@noindent
+Objects designated by access values from a
+general access type (declared with @code{access all}) are never allocated
+from a 64-bit storage pool. Code that uses general access types will
+accept objects allocated in either 32-bit or 64-bit address spaces,
+but never allocate objects outside the 32-bit address space.
+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
+
+@noindent
+All code that comes as part of GNAT is 64-bit clean, but the
+restrictions given in @ref{Restrictions on use of 64 bit objects},
+still apply. Look at the package
+specifications to see in which contexts objects allocated
+in 64-bit address space are acceptable.
 
+@node Technical details
+@subsection Technical details
 
+@noindent
+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 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,
+have been hidden by declaring these
+@code{abstract}, a feature introduced in Ada 95 that helps avoid the potential
+ambiguities that would otherwise result from overloading.
+(Note that, although @code{Address} is a visible integer type,
+good programming practice dictates against exploiting the type's
+integer properties such as literals, since this will compromise
+code portability.)
+
+Defining @code{Address} as a visible integer type helps achieve
+maximum compatibility for existing Ada code,
+without sacrificing the capabilities of the 64-bit architecture.
+@end ifset
+
+@c ************************************************
 @ifset unw
 @node Microsoft Windows Topics
 @appendix Microsoft Windows Topics
@@ -26030,9 +29812,12 @@ platforms (NT, 2000, and XP Professional).
 * Introduction to Dynamic Link Libraries (DLLs)::
 * Using DLLs with GNAT::
 * Building DLLs with GNAT::
+* Building DLLs with GNAT Project files::
+* Building DLLs with gnatdll::
 * GNAT and Windows Resources::
 * Debugging a DLL::
-* GNAT and COM/DCOM Objects::
+* Setting Stack Size from gnatlink::
+* Setting Heap Size from gnatlink::
 @end menu
 
 @node Using GNAT on Windows
@@ -26040,7 +29825,7 @@ platforms (NT, 2000, and XP Professional).
 
 @noindent
 One of the strengths of the GNAT technology is that its tool set
-(@code{gcc}, @code{gnatbind}, @code{gnatlink}, @code{gnatmake}, the
+(@command{gcc}, @command{gnatbind}, @command{gnatlink}, @command{gnatmake}, the
 @code{gdb} debugger, etc.) is used in the same way regardless of the
 platform.
 
@@ -26153,14 +29938,14 @@ $ gnatmake winprog -largs -mwindows
 
 @noindent
 It is possible to control where temporary files gets created by setting
-the TMP environment variable. The file will be created:
+the @env{TMP} environment variable. The file will be created:
 
 @itemize
-@item Under the directory pointed to by the TMP environment variable if
+@item Under the directory pointed to by the @env{TMP} environment variable if
 this directory exists.
 
-@item Under c:\temp, if the TMP environment variable is not set (or not
-pointing to a directory) and if this directory exists.
+@item Under @file{c:\temp}, if the @env{TMP} environment variable is not
+set (or not pointing to a directory) and if this directory exists.
 
 @item Under the current working directory otherwise.
 @end itemize
@@ -26181,7 +29966,7 @@ application that contains a mix of Ada and C/C++, the choice of your
 Windows C/C++ development environment conditions your overall
 interoperability strategy.
 
-If you use @code{gcc} to compile the non-Ada part of your application,
+If you use @command{gcc} to compile the non-Ada part of your application,
 there are no Windows-specific restrictions that affect the overall
 interoperability with your Ada code. If you plan to use
 Microsoft tools (e.g. Microsoft Visual C/C++), you should be aware of
@@ -26229,6 +30014,7 @@ environment to build your executable.
 @menu
 * C Calling Convention::
 * Stdcall Calling Convention::
+* Win32 Calling Convention::
 * DLL Calling Convention::
 @end menu
 
@@ -26249,6 +30035,9 @@ are available for Windows:
 @code{Stdcall} (Microsoft defined)
 
 @item
+@code{Win32} (GNAT specific)
+
+@item
 @code{DLL} (GNAT specific)
 @end itemize
 
@@ -26257,7 +30046,7 @@ are available for Windows:
 
 @noindent
 This is the default calling convention used when interfacing to C/C++
-routines compiled with either @code{gcc} or Microsoft Visual C++.
+routines compiled with either @command{gcc} or Microsoft Visual C++.
 
 In the @code{C} calling convention subprogram parameters are pushed on the
 stack by the caller from right to left. The caller itself is in charge of
@@ -26291,8 +30080,8 @@ is missing, as in the above example, this parameter is set to be the
 
 When importing a variable defined in C, you should always use the @code{C}
 calling convention unless the object containing the variable is part of a
-DLL (in which case you should use the @code{DLL} calling convention,
-@pxref{DLL Calling Convention}).
+DLL (in which case you should use the @code{Stdcall} calling
+convention, @pxref{Stdcall Calling Convention}).
 
 @node Stdcall Calling Convention
 @subsection @code{Stdcall} Calling Convention
@@ -26356,25 +30145,19 @@ pragma Import (Stdcall, Get_Val, Link_Name => "retrieve_val");
 @end smallexample
 
 @noindent
-then the imported routine is @code{retrieve_val@@4}, that is, there is no
-trailing underscore but the appropriate @code{@@}@code{@i{nn}} is always
-added at the end of the @code{Link_Name} by the compiler.
+then the imported routine is @code{retrieve_val}, that is, there is no
+decoration at all. No leading underscore and no Stdcall suffix
+@code{@@}@code{@i{nn}}.
 
 @noindent
-Note, that in some special cases a DLL's entry point name lacks a trailing
-@code{@@}@code{@i{nn}} while the exported name generated for a call has it.
-The @code{gnatdll} tool, which creates the import library for the DLL, is able
-to handle those cases (see the description of the switches in
-@pxref{Using gnatdll} section).
-
-@node DLL Calling Convention
-@subsection @code{DLL} Calling Convention
+This is especially important as in some special cases a DLL's entry
+point name lacks a trailing @code{@@}@code{@i{nn}} while the exported
+name generated for a call has it.
 
 @noindent
-This convention, which is GNAT-specific, must be used when you want to
-import in Ada a variables defined in a DLL. For functions and procedures
-this convention is equivalent to the @code{Stdcall} convention. As an
-example, if a DLL contains a variable defined as:
+It is also possible to import variables defined in a DLL by using an
+import pragma for a variable. As an example, if a DLL contains a
+variable defined as:
 
 @smallexample
 int my_var;
@@ -26386,13 +30169,27 @@ then, to access this variable from Ada you should write:
 @smallexample @c ada
 @group
 My_Var : Interfaces.C.int;
-pragma Import (DLL, My_Var);
+pragma Import (Stdcall, My_Var);
 @end group
 @end smallexample
 
-The remarks concerning the @code{External_Name} and @code{Link_Name}
-parameters given in the previous sections equally apply to the @code{DLL}
-calling convention.
+@noindent
+Note that to ease building cross-platform bindings this convention
+will be handled as a @code{C} calling convention on non Windows platforms.
+
+@node Win32 Calling Convention
+@subsection @code{Win32} Calling Convention
+
+@noindent
+This convention, which is GNAT-specific is fully equivalent to the
+@code{Stdcall} calling convention described above.
+
+@node DLL Calling Convention
+@subsection @code{DLL} Calling Convention
+
+@noindent
+This convention, which is GNAT-specific is fully equivalent to the
+@code{Stdcall} calling convention described above.
 
 @node Introduction to Dynamic Link Libraries (DLLs)
 @section Introduction to Dynamic Link Libraries (DLLs)
@@ -26410,13 +30207,14 @@ slower since, as you will understand below, such calls are indirect.
 
 To illustrate the remainder of this section, suppose that an application
 wants to use the services of a DLL @file{API.dll}. To use the services
-provided by @file{API.dll} you must statically link against an import
-library which contains a jump table with an entry for each routine and
-variable exported by the DLL. In the Microsoft world this import library is
-called @file{API.lib}. When using GNAT this import library is called either
+provided by @file{API.dll} you must statically link against the DLL or
+an import library which contains a jump table with an entry for each
+routine and variable exported by the DLL. In the Microsoft world this
+import library is called @file{API.lib}. When using GNAT this import
+library is called either @file{libAPI.dll.a}, @file{libapi.dll.a},
 @file{libAPI.a} or @file{libapi.a} (names are case insensitive).
 
-After you have statically linked your application with the import library
+After you have linked your application with the DLL or the import library
 and you run your application, here is what happens:
 
 @enumerate
@@ -26444,9 +30242,10 @@ routines and routines in the application using the DLL.
 @end itemize
 
 @item
-The entries in the @file{libAPI.a} or @file{API.lib} jump table which is
-part of your application are initialized with the addresses of the routines
-and variables in @file{API.dll}.
+The entries in the jump table (from the import library @file{libAPI.dll.a}
+or @file{API.lib} or automatically created when linking against a DLL)
+which is part of your application are initialized with the addresses
+of the routines and variables in @file{API.dll}.
 
 @item
 If present in @file{API.dll}, routines @code{DllMain} or
@@ -26471,8 +30270,8 @@ still be relocated.
 As a side note, an interesting difference between Microsoft DLLs and
 Unix shared libraries, is the fact that on most Unix systems all public
 routines are exported by default in a Unix shared library, while under
-Windows the exported routines must be listed explicitly in a definition
-file (@pxref{The Definition File}).
+Windows it is possible (but not required) to list exported routines in
+a definition file (@pxref{The Definition File}).
 
 @node Using DLLs with GNAT
 @section Using DLLs with GNAT
@@ -26493,11 +30292,12 @@ The Ada spec for the routines and/or variables you want to access in
 header files provided with the DLL.
 
 @item
-The import library (@file{libAPI.a} or @file{API.lib}). As previously
+The import library (@file{libAPI.dll.a} or @file{API.lib}). As previously
 mentioned an import library is a statically linked library containing the
 import table which will be filled at load time to point to the actual
 @file{API.dll} routines. Sometimes you don't have an import library for the
-DLL you want to use. The following sections will explain how to build one.
+DLL you want to use. The following sections will explain how to build
+one. Note that this is optional.
 
 @item
 The actual DLL, @file{API.dll}.
@@ -26513,9 +30313,10 @@ $ gnatmake my_ada_app -largs -lAPI
 @end smallexample
 
 @noindent
-The argument @option{-largs -lAPI} at the end of the @code{gnatmake} command
+The argument @option{-largs -lAPI} at the end of the @command{gnatmake} command
 tells the GNAT linker to look first for a library named @file{API.lib}
-(Microsoft-style name) and if not found for a library named @file{libAPI.a}
+(Microsoft-style name) and if not found for a libraries named
+@file{libAPI.dll.a}, @file{API.dll.a} or @file{libAPI.a}.
 (GNAT-style name). Note that if the Ada package spec for @file{API.dll}
 contains the following pragma
 
@@ -26524,8 +30325,8 @@ pragma Linker_Options ("-lAPI");
 @end smallexample
 
 @noindent
-you do not have to add @option{-largs -lAPI} at the end of the @code{gnatmake}
-command.
+you do not have to add @option{-largs -lAPI} at the end of the
+@command{gnatmake} command.
 
 If any one of the items above is missing you will have to create it
 yourself. The following sections explain how to do so using as an
@@ -26574,9 +30375,9 @@ end API;
 @end smallexample
 
 @noindent
-Note that a variable is @strong{always imported with a DLL convention}. A
-function can have @code{C}, @code{Stdcall} or @code{DLL} convention. For
-subprograms, the @code{DLL} convention is a synonym of @code{Stdcall}
+Note that a variable is
+@strong{always imported with a Stdcall convention}. A function
+can have @code{C} or @code{Stdcall} convention.
 (@pxref{Windows Calling Conventions}).
 
 @node Creating an Import Library
@@ -26591,8 +30392,11 @@ subprograms, the @code{DLL} convention is a synonym of @code{Stdcall}
 
 @noindent
 If a Microsoft-style import library @file{API.lib} or a GNAT-style
-import library @file{libAPI.a} is available with @file{API.dll} you
-can skip this section. Otherwise read on.
+import library @file{libAPI.dll.a} or @file{libAPI.a} is available
+with @file{API.dll} you can skip this section. You can also skip this
+section if @file{API.dll} or @file{libAPI.dll} is built with GNU tools
+as in this case it is possible to link directly against the
+DLL. Otherwise read on.
 
 @node The Definition File
 @subsubsection The Definition File
@@ -26614,7 +30418,7 @@ suffix) has the following structure:
 EXPORTS
    @i{symbol1}
    @i{symbol2}
-   ...
+   @dots{}
 @end cartouche
 @end group
 @end smallexample
@@ -26673,7 +30477,8 @@ $ dll2def API.dll > API.def
 to standard output the list of entry points in the DLL. Note that if
 some routines in the DLL have the @code{Stdcall} convention
 (@pxref{Windows Calling Conventions}) with stripped @code{@@}@i{nn}
-suffix then you'll have to edit @file{api.def} to add it.
+suffix then you'll have to edit @file{api.def} to add it, and specify
+@option{-k} to @command{gnatdll} when creating the import library.
 
 @noindent
 Here are some hints to find the right @code{@@}@i{nn} suffix.
@@ -26695,7 +30500,7 @@ definition file and add the right suffix.
 @end enumerate
 
 @item
-Build the import library @code{libAPI.a}, using @code{gnatdll}
+Build the import library @code{libAPI.dll.a}, using @code{gnatdll}
 (@pxref{Using gnatdll}) as follows:
 
 @smallexample
@@ -26756,6 +30561,81 @@ See the Microsoft documentation for further details about the usage of
 @section Building DLLs with GNAT
 @cindex DLLs, building
 
+@noindent
+This section explain how to build DLLs using the GNAT built-in DLL
+support. With the following procedure it is straight forward to build
+and use DLLs with GNAT.
+
+@enumerate
+
+@item building object files
+
+The first step is to build all objects files that are to be included
+into the DLL. This is done by using the standard @command{gnatmake} tool.
+
+@item building the DLL
+
+To build the DLL you must use @command{gcc}'s @option{-shared}
+option. It is quite simple to use this method:
+
+@smallexample
+$ gcc -shared -o api.dll obj1.o obj2.o @dots{}
+@end smallexample
+
+It is important to note that in this case all symbols found in the
+object files are automatically exported. It is possible to restrict
+the set of symbols to export by passing to @command{gcc} a definition
+file, @pxref{The Definition File}. For example:
+
+@smallexample
+$ gcc -shared -o api.dll api.def obj1.o obj2.o @dots{}
+@end smallexample
+
+If you use a definition file you must export the elaboration procedures
+for every package that required one. Elaboration procedures are named
+using the package name followed by "_E".
+
+@item preparing DLL to be used
+
+For the DLL to be used by client programs the bodies must be hidden
+from it and the .ali set with read-only attribute. This is very important
+otherwise GNAT will recompile all packages and will not actually use
+the code in the DLL. For example:
+
+@smallexample
+$ mkdir apilib
+$ copy *.ads *.ali api.dll apilib
+$ attrib +R apilib\*.ali
+@end smallexample
+
+@end enumerate
+
+At this point it is possible to use the DLL by directly linking
+against it. Note that you must use the GNAT shared runtime when using
+GNAT shared libraries. This is achieved by using @option{-shared} binder's
+option.
+
+@smallexample
+$ gnatmake main -Iapilib -bargs -shared -largs -Lapilib -lAPI
+@end smallexample
+
+@node Building DLLs with GNAT Project files
+@section Building DLLs with GNAT Project files
+@cindex DLLs, building
+
+@noindent
+There is nothing specific to Windows in the build process.
+@pxref{Library Projects}.
+
+@noindent
+Due to a system limitation, it is not possible under Windows to create threads
+when inside the @code{DllMain} routine which is used for auto-initialization
+of shared libraries, so it is not possible to have library level tasks in SALs.
+
+@node Building DLLs with gnatdll
+@section Building DLLs with gnatdll
+@cindex DLLs, building
+
 @menu
 * Limitations When Using Ada DLLs from Ada::
 * Exporting Ada Entities::
@@ -26767,8 +30647,13 @@ See the Microsoft documentation for further details about the usage of
 @end menu
 
 @noindent
-This section explains how to build DLLs containing Ada code. These DLLs
-will be referred to as Ada DLLs in the remainder of this section.
+Note that it is preferred to use the built-in GNAT DLL support
+(@pxref{Building DLLs with GNAT}) or GNAT Project files
+(@pxref{Building DLLs with GNAT Project files}) to build DLLs.
+
+This section explains how to build DLLs containing Ada code using
+@code{gnatdll}. These DLLs will be referred to as Ada DLLs in the
+remainder of this section.
 
 The steps required to build an Ada DLL that is to be used by Ada as well as
 non-Ada applications are as follows:
@@ -26782,14 +30667,14 @@ skip this step if you plan to use the Ada DLL only from Ada applications.
 
 @item
 Your Ada code must export an initialization routine which calls the routine
-@code{adainit} generated by @code{gnatbind} to perform the elaboration of
+@code{adainit} generated by @command{gnatbind} to perform the elaboration of
 the Ada code in the DLL (@pxref{Ada DLLs and Elaboration}). The initialization
 routine exported by the Ada DLL must be invoked by the clients of the DLL
 to initialize the DLL.
 
 @item
 When useful, the DLL should also export a finalization routine which calls
-routine @code{adafinal} generated by @code{gnatbind} to perform the
+routine @code{adafinal} generated by @command{gnatbind} to perform the
 finalization of the Ada code in the DLL (@pxref{Ada DLLs and Finalization}).
 The finalization routine exported by the Ada DLL must be invoked by the
 clients of the DLL when the DLL services are no further needed.
@@ -26808,9 +30693,11 @@ library (@pxref{Using gnatdll}).
 @end enumerate
 
 @noindent
-Note that a relocatable DLL stripped using the @code{strip} binutils
-tool will not be relocatable anymore. To build a DLL without debug
-information pass @code{-largs -s} to @code{gnatdll}.
+Note that a relocatable DLL stripped using the @code{strip}
+binutils tool will not be relocatable anymore. To build a DLL without
+debug information pass @code{-largs -s} to @code{gnatdll}. This
+restriction does not apply to a DLL built using a Library Project.
+@pxref{Library Projects}.
 
 @node Limitations When Using Ada DLLs from Ada
 @subsection Limitations When Using Ada DLLs from Ada
@@ -26840,10 +30727,9 @@ Windows object handles, etc.
 Building a DLL is a way to encapsulate a set of services usable from any
 application. As a result, the Ada entities exported by a DLL should be
 exported with the @code{C} or @code{Stdcall} calling conventions to avoid
-any Ada name mangling. Please note that the @code{Stdcall} convention
-should only be used for subprograms, not for variables. As an example here
-is an Ada package @code{API}, spec and body, exporting two procedures, a
-function, and a variable:
+any Ada name mangling. As an example here is an Ada package
+@code{API}, spec and body, exporting two procedures, a function, and a
+variable:
 
 @smallexample @c ada
 @group
@@ -26933,7 +30819,7 @@ package body API is
       return Fact;
    end Factorial;
 
-   ...
+   @dots{}
    --  The remainder of this package body is unchanged.
 end API;
 @end cartouche
@@ -27024,7 +30910,7 @@ example consider a DLL comprising the following package @code{API}:
 @cartouche
 package API is
    Count : Integer := 0;
-   ...
+   @dots{}
    --  Remainder of the package omitted.
 end API;
 @end cartouche
@@ -27130,7 +31016,7 @@ advise the reader to build relocatable DLL.
 @item -b @var{address}
 @cindex @option{-b} (@code{gnatdll})
 Set the relocatable DLL base address. By default the address is
-@var{0x11000000}.
+@code{0x11000000}.
 
 @item -bargs @var{opts}
 @cindex @option{-bargs} (@code{gnatdll})
@@ -27142,7 +31028,7 @@ Binder options. Pass @var{opts} to the binder.
 @code{gnatdll} to do anything. The name of the generated import library is
 obtained algorithmically from @var{dllfile} as shown in the following
 example: if @var{dllfile} is @code{xyz.dll}, the import library name is
-@code{libxyz.a}. The name of the definition file to use (if not specified
+@code{libxyz.dll.a}. The name of the definition file to use (if not specified
 by option @option{-e}) is obtained algorithmically from @var{dllfile}
 as shown in the following example:
 if @var{dllfile} is @code{xyz.dll}, the definition
@@ -27173,10 +31059,11 @@ object files needed to build the DLL.
 @item -k
 @cindex @option{-k} (@code{gnatdll})
 Removes the @code{@@}@i{nn} suffix from the import library's exported
-names. You must specified this option if you want to use a
-@code{Stdcall} function in a DLL for which the @code{@@}@i{nn} suffix
-has been removed. This is the case for most of the Windows NT DLL for
-example. This option has no effect when @option{-n} option is specified.
+names, but keeps them for the link names. You must specify this
+option if you want to use a @code{Stdcall} function in a DLL for which
+the @code{@@}@i{nn} suffix has been removed. This is the case for most
+of the Windows NT DLL for example. This option has no effect when
+@option{-n} option is specified.
 
 @item -l @var{file}
 @cindex @option{-l} (@code{gnatdll})
@@ -27213,7 +31100,7 @@ $ gnatdll -d api.dll api.ali
 @end smallexample
 
 @noindent
-The above command creates two files: @file{libapi.a} (the import
+The above command creates two files: @file{libapi.dll.a} (the import
 library) and @file{api.dll} (the actual DLL). If you want to create
 only the DLL, just type:
 
@@ -27257,9 +31144,9 @@ $ gnatlink api -o api.jnk -mdll -Wl,--base-file,api.base
 @end smallexample
 
 @noindent
-In addition to the base file, the @code{gnatlink} command generates an
+In addition to the base file, the @command{gnatlink} command generates an
 output file @file{api.jnk} which can be discarded. The @option{-mdll} switch
-asks @code{gnatlink} to generate the routines @code{DllMain} and
+asks @command{gnatlink} to generate the routines @code{DllMain} and
 @code{DllMainCRTStartup} that are called by the Windows loader when the DLL
 is loaded into memory.
 
@@ -27278,8 +31165,8 @@ $ dlltool --dllname api.dll --def api.def --base-file api.base \
 
 @item
 @code{gnatdll} builds the base file using the new export table. Note that
-@code{gnatbind} must be called once again since the binder generated file
-has been deleted during the previous call to @code{gnatlink}.
+@command{gnatbind} must be called once again since the binder generated file
+has been deleted during the previous call to @command{gnatlink}.
 
 @smallexample
 @group
@@ -27291,7 +31178,7 @@ $ gnatlink api -o api.jnk api.exp -mdll
 
 @item
 @code{gnatdll} builds the new export table using the new base file and
-generates the DLL import library @file{libAPI.a}.
+generates the DLL import library @file{libAPI.dll.a}.
 
 @smallexample
 @group
@@ -27448,7 +31335,7 @@ $ windres -i myres.rc -o myres.o
 @end smallexample
 
 @noindent
-By default @code{windres} will run @code{gcc} to preprocess the @file{.rc}
+By default @code{windres} will run @command{gcc} to preprocess the @file{.rc}
 file. You can specify an alternate preprocessor (usually named
 @file{cpp.exe}) using the @code{windres} @option{--preprocessor}
 parameter. A list of all possible options may be obtained by entering
@@ -27471,7 +31358,7 @@ $ windres -i myres.res -o myres.o
 @noindent
 To include the resource file in your program just add the
 GNAT-compatible object file for the resource(s) to the linker
-arguments. With @code{gnatmake} this is done by using the @option{-largs}
+arguments. With @command{gnatmake} this is done by using the @option{-largs}
 option:
 
 @smallexample
@@ -27533,11 +31420,10 @@ switch). Here are the step-by-step instructions for debugging it:
 $ gdb -nw ada_main
 @end smallexample
 
-@item Break on the main procedure and run the program.
+@item Start the program and stop at the beginning of the main procedure
 
 @smallexample
-(gdb) break ada_main
-(gdb) run
+(gdb) start
 @end smallexample
 
 @noindent
@@ -27550,7 +31436,7 @@ possible to set a breakpoint in the DLL.
 
 @smallexample
 (gdb) break ada_dll
-(gdb) run
+(gdb) cont
 @end smallexample
 
 @end enumerate
@@ -27560,6 +31446,47 @@ At this stage a breakpoint is set inside the DLL. From there on
 you can use the standard approach to debug the whole program
 (@pxref{Running and Debugging Ada Programs}).
 
+@ignore
+@c This used to work, probably because the DLLs were non-relocatable
+@c keep this section around until the problem is sorted out.
+
+To break on the @code{DllMain} routine it is not possible to follow
+the procedure above. At the time the program stop on @code{ada_main}
+the @code{DllMain} routine as already been called. Either you can use
+the procedure below @pxref{Debugging the DLL Directly} or this procedure:
+
+@enumerate 1
+@item Launch @code{GDB} on the main program.
+
+@smallexample
+$ gdb ada_main
+@end smallexample
+
+@item Load DLL symbols
+
+@smallexample
+(gdb) add-sym api.dll
+@end smallexample
+
+@item Set a breakpoint inside the DLL
+
+@smallexample
+(gdb) break ada_dll.adb:45
+@end smallexample
+
+Note that at this point it is not possible to break using the routine symbol
+directly as the program is not yet running. The solution is to break
+on the proper line (break in @file{ada_dll.adb} line 45).
+
+@item Start the program
+
+@smallexample
+(gdb) run
+@end smallexample
+
+@end enumerate
+@end ignore
+
 @node Program Built with Foreign Tools and DLL Built with GCC/GNAT
 @subsection Program Built with Foreign Tools and DLL Built with GCC/GNAT
 
@@ -27592,30 +31519,58 @@ been built with debugging information (see GNAT -g option).
 
 @enumerate 1
 @item
-Launch the debugger on the DLL.
+Find out the executable starting address
 
 @smallexample
-$ gdb -nw test.dll
+$ objdump --file-header main.exe
 @end smallexample
 
-@item Set a breakpoint on a DLL subroutine.
+The starting address is reported on the last line. For example:
 
 @smallexample
-(gdb) break ada_dll
+main.exe:     file format pei-i386
+architecture: i386, flags 0x0000010a:
+EXEC_P, HAS_DEBUG, D_PAGED
+start address 0x00401010
 @end smallexample
 
 @item
-Specify the executable file to @code{GDB}.
+Launch the debugger on the executable.
 
 @smallexample
-(gdb) exec-file main.exe
+$ gdb main.exe
 @end smallexample
 
 @item
-Run the program.
+Set a breakpoint at the starting address, and launch the program.
 
 @smallexample
-(gdb) run
+$ (gdb) break *0x00401010
+$ (gdb) run
+@end smallexample
+
+The program will stop at the given address.
+
+@item
+Set a breakpoint on a DLL subroutine.
+
+@smallexample
+(gdb) break ada_dll.adb:45
+@end smallexample
+
+Or if you want to break using a symbol on the DLL, you need first to
+select the Ada language (language used by the DLL).
+
+@smallexample
+(gdb) set language ada
+(gdb) break ada_dll
+@end smallexample
+
+@item
+Continue the program.
+
+@smallexample
+(gdb) cont
 @end smallexample
 
 @noindent
@@ -27653,7 +31608,7 @@ that the process PID for @file{main.exe} is 208.
 @item Launch gdb.
 
 @smallexample
-$ gdb -nw
+$ gdb
 @end smallexample
 
 @item Attach to the running process to be debugged.
@@ -27677,7 +31632,7 @@ $ gdb -nw
 @item Continue process execution.
 
 @smallexample
-(gdb) continue
+(gdb) cont
 @end smallexample
 
 @end enumerate
@@ -27688,16 +31643,78 @@ the breakpoint we have set. From there you can use the standard
 approach to debug a program as described in
 (@pxref{Running and Debugging Ada Programs}).
 
-@node GNAT and COM/DCOM Objects
-@section GNAT and COM/DCOM Objects
-@findex COM
-@findex DCOM
+@node Setting Stack Size from gnatlink
+@section Setting Stack Size from @command{gnatlink}
 
 @noindent
-This section is temporarily left blank.
+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
+Storage_Size or with the @command{gnatbind -d} command.
 
-@end ifset
+Since older versions of Windows (2000, NT4, etc.) do not allow setting the
+reserve size of individual tasks, the link-time stack size applies to all
+tasks, and pragma Storage_Size has no effect.
+In particular, Stack Overflow checks are made against this
+link-time specified size.
+
+This setting can be done with
+@command{gnatlink} using either:
+
+@itemize @bullet
+
+@item using @option{-Xlinker} linker option
+
+@smallexample
+$ gnatlink hello -Xlinker --stack=0x10000,0x1000
+@end smallexample
+
+This sets the stack reserve size to 0x10000 bytes and the stack commit
+size to 0x1000 bytes.
+
+@item using @option{-Wl} linker option
+
+@smallexample
+$ gnatlink hello -Wl,--stack=0x1000000
+@end smallexample
+
+This sets the stack reserve size to 0x1000000 bytes. Note that with
+@option{-Wl} option it is not possible to set the stack commit size
+because the coma is a separator for this option.
+
+@end itemize
+
+@node Setting Heap Size from gnatlink
+@section Setting Heap Size from @command{gnatlink}
+
+@noindent
+Under Windows systems, it is possible to specify the program heap size from
+@command{gnatlink} using either:
+
+@itemize @bullet
+
+@item using @option{-Xlinker} linker option
+
+@smallexample
+$ gnatlink hello -Xlinker --heap=0x10000,0x1000
+@end smallexample
 
+This sets the heap reserve size to 0x10000 bytes and the heap commit
+size to 0x1000 bytes.
+
+@item using @option{-Wl} linker option
+
+@smallexample
+$ gnatlink hello -Wl,--heap=0x1000000
+@end smallexample
+
+This sets the heap reserve size to 0x1000000 bytes. Note that with
+@option{-Wl} option it is not possible to set the heap commit size
+because the coma is a separator for this option.
+
+@end itemize
+
+@end ifset
 
 @c **********************************
 @c * GNU Free Documentation License *