OSDN Git Service

* parser.c (cp_parser_class_specifier): Set class location to that
[pf3gnuchains/gcc-fork.git] / gcc / ada / gnat_ugn.texi
index c8b8310..ab52d63 100644 (file)
@@ -1,4 +1,4 @@
-f\input texinfo   @c -*-texinfo-*-
+\input texinfo   @c -*-texinfo-*-
 @c %**start of header
 
 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
@@ -390,8 +390,8 @@ GNAT Project Manager
 
 The Cross-Referencing Tools gnatxref and gnatfind
 
-* gnatxref Switches::
-* gnatfind Switches::
+* Switches for gnatxref::
+* Switches for gnatfind::
 * Project Files for gnatxref and gnatfind::
 * Regular Expressions in gnatfind and gnatxref::
 * Examples of gnatxref Usage::
@@ -492,6 +492,7 @@ Verifying Properties Using gnatcheck
 * Project-Wide Checks::
 * Rule exemption::
 * Predefined Rules::
+* Example of gnatcheck Usage::
 
 Sample Bodies Using gnatstub
 
@@ -4572,8 +4573,9 @@ first in the string.
 
 @item
 The switches
-@option{^-gnatz^/DISTRIBUTION_STUBS^}, @option{-gnatzc}, and @option{-gnatzr}
-may not be combined with any other switches.
+^^@option{/DISTRIBUTION_STUBS=},^
+@option{-gnatzc} and @option{-gnatzr} may not be combined with any other
+switches, and only one of them may appear in the command line.
 
 @ifclear vms
 @item
@@ -4595,6 +4597,10 @@ as warning mode modifiers (see description of @option{-gnatw}).
 Once a ``V'' appears in the string (that is a use of the @option{-gnatV}
 switch), then all further characters in the switch are interpreted
 as validity checking options (@pxref{Validity Checking}).
+
+@item
+Option ``em'', ``ec'', ``ep'', ``l='' and ``R'' must be the last options in
+a combined list of options.
 @end ifclear
 @end itemize
 
@@ -9326,7 +9332,21 @@ This switch cannot be used when using a project file.
 @ifclear vms
 @item -eL
 @cindex @option{-eL} (@command{gnatmake})
+@cindex symbolic links
 Follow all symbolic links when processing project files.
+This should be used if your project uses symbolic links for files or
+directories, but is not needed in other cases.
+
+@cindex naming scheme
+This also assumes that no directory matches the naming scheme for files (for
+instance that you do not have a directory called "sources.ads" when using the
+default GNAT naming scheme).
+
+When you do not have to use this switch (ie by default), gnatmake is able to
+save a lot of system calls (several per source file and object file), which
+can result in a significant speed up to load and manipulate a project file,
+especially when using source files from a remote system.
+
 @end ifclear
 
 @item ^-eS^/STANDARD_OUTPUT_FOR_COMMANDS^
@@ -12700,6 +12720,8 @@ case insensitive. The following package names are legal:
 @item
 @code{Cross_Reference}
 @item
+@code{Check}
+@item
 @code{Eliminate}
 @item
 @code{Pretty_Printer}
@@ -14907,6 +14929,10 @@ package @code{Gnatstub} for command STUB
 package @code{Linker} for command LINK (invoking @code{^gnatlink^gnatlink^})
 
 @item
+package @code{Check} for command CHECK
+(invoking @code{^gnatcheck^gnatcheck^})
+
+@item
 package @code{Metrics} for command METRIC
 (invoking @code{^gnatmetric^gnatmetric^})
 
@@ -15363,15 +15389,15 @@ 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::
+* Switches for gnatxref::
+* Switches for gnatfind::
 * Project Files for gnatxref and gnatfind::
 * Regular Expressions in gnatfind and gnatxref::
 * Examples of gnatxref Usage::
 * Examples of gnatfind Usage::
 @end menu
 
-@node gnatxref Switches
+@node Switches for gnatxref
 @section @code{gnatxref} Switches
 
 @noindent
@@ -15502,7 +15528,7 @@ appear after the file names. They need not be separated by spaces, thus
 you can say @samp{gnatxref ^-ag^/ALL_FILES/IGNORE_LOCALS^} instead of
 @samp{gnatxref ^-a -g^/ALL_FILES /IGNORE_LOCALS^}.
 
-@node gnatfind Switches
+@node Switches for gnatfind
 @section @code{gnatfind} Switches
 
 @noindent
@@ -20717,6 +20743,7 @@ supplied.
 * Project-Wide Checks::
 * Rule exemption::
 * Predefined Rules::
+* Example of gnatcheck Usage::
 @end menu
 
 @node Format of the Report File
@@ -20874,14 +20901,13 @@ lines and end-of-line comments). There can be several rule options on a
 single line (separated by a space).
 
 A coding standard file may reference other coding standard files by including
-other @option{-from=@var{rule_option_filename}}
+more @option{-from=@var{rule_option_filename}}
 options, each such option being replaced with the content of the
 corresponding coding standard file during processing. In case a
 cycle is detected (that is, @file{@var{rule_file_1}} reads rule options
 from @file{@var{rule_file_2}}, and @file{@var{rule_file_2}} reads
 (directly or indirectly) rule options from @file{@var{rule_file_1}}),
-the processing of coding standard files is interrupted and a part of their
-content is ignored.
+processing fails with an error message.
 
 
 @node Adding the Results of Compiler Checks to gnatcheck Output
@@ -21015,7 +21041,7 @@ exemption control annotations is as follows:
 @group
 pragma Annotate (gnatcheck, @i{exemption_control}, @i{Rule_Name}, [@i{justification}]);
 
-@i{exemption_control} ::= "Exempt_On" | "Exempt_Off"
+@i{exemption_control} ::= Exempt_On | Exempt_Off
 
 @i{Rule_Name}         ::= string_literal
 
@@ -21039,9 +21065,9 @@ A source code section where an exemption is active for a given rule is
 delimited by an @code{exempt_on} and @code{exempt_off} annotation pair:
 
 @smallexample @c ada
-pragma Annotate (gnatcheck, "Exempt_On", Rule_Name, "justification");
+pragma Annotate (gnatcheck, Exempt_On, Rule_Name, "justification");
 -- source code section
-pragma Annotate (gnatcheck, "Exempt_Off", Rule_Name);
+pragma Annotate (gnatcheck, Exempt_Off, Rule_Name);
 @end smallexample
 
 
@@ -22915,6 +22941,185 @@ Only variable declarations, and not constant declarations, are checked.
 
 This rule has no parameters.
 
+@node Example of gnatcheck Usage
+@section Example of @command{gnatcheck} Usage
+
+@noindent
+Here is a simple example. Suppose that in the current directory we have a
+project file named @file{gnatcheck_example.gpr} with the following content:
+
+@smallexample @c projectfile
+project Gnatcheck_Example is
+
+   for Source_Dirs use ("src");
+   for Object_Dir use "obj";
+   for Main use ("main.adb");
+
+   package Check is
+      for Default_Switches ("ada") use ("-rules", "-from=coding_standard");
+   end Check;
+
+end Gnatcheck_Example;
+@end smallexample
+
+@noindent
+And the file named @file{coding_standard} is also located in the current
+directory and has the following content:
+
+@smallexample
+-----------------------------------------------------
+-- This is a sample gnatcheck coding standard file --
+-----------------------------------------------------
+
+--  First, turning on rules, that are directly implemented in gnatcheck
++RAbstract_Type_Declarations
++RAnonymous_Arrays
++RLocal_Packages
++RFloat_Equality_Checks
++REXIT_Statements_With_No_Loop_Name
+
+--  Then, activating compiler checks of interest:
++RStyle_Checks:e
+--  This style check checks if a unit name is present on END keyword that
+--  is the end of the unit declaration
+@end smallexample
+
+@noindent
+And the subdirectory @file{src} contains the following Ada sources:
+
+@file{pack.ads}:
+
+@smallexample @c ada
+package Pack is
+   type T is abstract tagged private;
+   procedure P (X : T) is abstract;
+
+   package Inner is
+      type My_Float is digits 8;
+      function Is_Equal (L, R : My_Float) return Boolean;
+   end Inner;
+private
+   type T is abstract tagged null record;
+end;
+@end smallexample
+
+@noindent
+@file{pack.adb}:
+
+@smallexample @c ada
+package body Pack is
+   package body Inner is
+      function Is_Equal (L, R : My_Float) return Boolean is
+      begin
+         return L = R;
+      end;
+   end Inner;
+end Pack;
+@end smallexample
+
+@noindent
+and @file{main.adb}
+
+@smallexample @c ada
+with Pack; use Pack;
+procedure Main is
+
+   pragma Annotate
+     (gnatcheck, Exempt_On, "Anonymous_Arrays", "this one is fine");
+   Float_Array : array (1 .. 10) of Inner.My_Float;
+   pragma Annotate (gnatcheck, Exempt_Off, "Anonymous_Arrays");
+
+   Another_Float_Array : array (1 .. 10) of Inner.My_Float;
+
+   use Inner;
+
+   B : Boolean := False;
+
+begin
+   for J in Float_Array'Range loop
+      if Is_Equal (Float_Array (J), Another_Float_Array (J)) then
+         B := True;
+         exit;
+      end if;
+   end loop;
+end Main;
+@end smallexample
+
+@noindent
+And suppose we call @command{gnatcheck} from the current directory using
+the @command{gnat} driver:
+
+@smallexample
+   gnat check -Pgnatcheck_example.gpr
+@end smallexample
+
+@noindent
+As a result, @command{gnatcheck} is called to check all the files from the
+project @file{gnatcheck_example.gpr} using the coding standard defined by
+the file @file{coding_standard}. As the result, the @command{gnatcheck}
+report file named @file{gnatcheck.out} will be created in the current
+directory, and it will have the following content:
+
+@smallexample
+RULE CHECKING REPORT
+
+1. OVERVIEW
+
+Date and time of execution: 2009.10.28 14:17
+Tool version: GNATCHECK (built with ASIS 2.0.R for GNAT Pro 6.3.0w (20091016))
+Command line:
+
+gnatcheck -files=.../GNAT-TEMP-000004.TMP -cargs -gnatec=.../GNAT-TEMP-000003.TMP -rules -from=coding_standard
+
+Coding standard (applied rules):
+   Abstract_Type_Declarations
+   Anonymous_Arrays
+   EXIT_Statements_With_No_Loop_Name
+   Float_Equality_Checks
+   Local_Packages
+
+   Compiler style checks: -gnatye
+
+Number of coding standard violations: 6
+Number of exempted coding standard violations: 1
+
+2. DETECTED RULE VIOLATIONS
+
+2.1. NON-EXEMPTED VIOLATIONS
+
+Source files with non-exempted violations
+   pack.ads
+   pack.adb
+   main.adb
+
+List of violations grouped by files, and ordered by increasing source location:
+
+pack.ads:2:4: declaration of abstract type
+pack.ads:5:4: declaration of local package
+pack.ads:10:30: declaration of abstract type
+pack.ads:11:1: (style) "end Pack" required
+pack.adb:5:19: use of equality operation for float values
+pack.adb:6:7: (style) "end Is_Equal" required
+main.adb:9:26: anonymous array type
+main.adb:19:10: exit statement with no loop name
+
+2.2. EXEMPTED VIOLATIONS
+
+Source files with exempted violations
+   main.adb
+
+List of violations grouped by files, and ordered by increasing source location:
+
+main.adb:6:18: anonymous array type
+   (this one is fine)
+
+2.3. SOURCE FILES WITH NO VIOLATION
+
+   No files without violations
+
+END OF REPORT
+@end smallexample
+
 
 @c *********************************
 @node Creating Sample Bodies Using gnatstub