Commit b0760739 by Arnaud Charlet

[multiple changes]

2010-06-17  Ben Brosgol  <brosgol@adacore.com>

	* gnat_ugn.texi: Update gnatcheck doc.

2010-06-17  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch3.adb (Build_Incomplete_Type_Declaration): If there is an
	incomplete view of the type that is not tagged, and the full type is a
	tagged extension, create class_wide type now, and warn that the
	incomplete view should be tagged as well.

From-SVN: r160913
parent aa9ea6a1
2010-06-17 Ben Brosgol <brosgol@adacore.com>
* gnat_ugn.texi: Update gnatcheck doc.
2010-06-17 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Build_Incomplete_Type_Declaration): If there is an
incomplete view of the type that is not tagged, and the full type is a
tagged extension, create class_wide type now, and warn that the
incomplete view should be tagged as well.
2010-06-17 Vincent Celier <celier@adacore.com> 2010-06-17 Vincent Celier <celier@adacore.com>
* gnatcmd.adb (Non_VMS_Usage): Do not issue usage for gnat sync. * gnatcmd.adb (Non_VMS_Usage): Do not issue usage for gnat sync.
......
...@@ -21141,1808 +21141,13 @@ release. ...@@ -21141,1808 +21141,13 @@ release.
@end ignore @end ignore
@noindent @noindent
The following subsections document the rules implemented in The predefined rules implemented in @command{gnatcheck}
@command{gnatcheck}. are described in a companion document,
The subsection title is the same as the rule identifier, which may be @cite{GNATcheck Reference Manual -- Predefined Rules}.
used as a parameter of the @option{+R} or @option{-R} options. The rule identifier is
used as a parameter of @command{gnatcheck}'s @option{+R} or @option{-R}
switches.
@menu
* Abstract_Type_Declarations::
* Anonymous_Arrays::
* Anonymous_Subtypes::
* Blocks::
* Boolean_Relational_Operators::
@ignore
* Ceiling_Violations::
@end ignore
* Complex_Inlined_Subprograms::
* Controlled_Type_Declarations::
* Declarations_In_Blocks::
* Deep_Inheritance_Hierarchies::
* Deeply_Nested_Generics::
* Deeply_Nested_Inlining::
@ignore
* Deeply_Nested_Local_Inlining::
@end ignore
* Default_Parameters::
* Direct_Calls_To_Primitives::
* Discriminated_Records::
* Enumeration_Ranges_In_CASE_Statements::
* Exceptions_As_Control_Flow::
* Exits_From_Conditional_Loops::
* EXIT_Statements_With_No_Loop_Name::
* Expanded_Loop_Exit_Names::
* Explicit_Full_Discrete_Ranges::
* Float_Equality_Checks::
* Forbidden_Attributes::
* 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
* Metrics::
* Misnamed_Controlling_Parameters::
* 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::
* Separate_Numeric_Error_Handlers::
@ignore
* Recursion::
* Side_Effect_Functions::
@end ignore
* Slices::
* Too_Many_Parents::
* Unassigned_OUT_Parameters::
* Uncommented_BEGIN_In_Package_Bodies::
* Unconditional_Exits::
* Unconstrained_Array_Returns::
* Universal_Ranges::
* Unnamed_Blocks_And_Loops::
@ignore
* Unused_Subprograms::
@end ignore
* USE_PACKAGE_Clauses::
* Visible_Components::
* Volatile_Objects_Without_Address_Clauses::
@end menu
@node Abstract_Type_Declarations
@subsection @code{Abstract_Type_Declarations}
@cindex @code{Abstract_Type_Declarations} rule (for @command{gnatcheck})
@noindent
Flag all declarations of abstract types. For an abstract private
type, both the private and full type declarations are flagged.
This rule has no parameters.
@node Anonymous_Arrays
@subsection @code{Anonymous_Arrays}
@cindex @code{Anonymous_Arrays} rule (for @command{gnatcheck})
@noindent
Flag all anonymous array type definitions (by Ada semantics these can only
occur in object declarations).
This rule has no parameters.
@node Anonymous_Subtypes
@subsection @code{Anonymous_Subtypes}
@cindex @code{Anonymous_Subtypes} rule (for @command{gnatcheck})
@noindent
Flag all uses of anonymous subtypes (except cases when subtype indication
is a part of a record component definition, and this subtype indication
depends on a discriminant). 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.
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
for I in 1 .. N loop
@dots{}
end loop;
@end smallexample
@noindent
Declaring an explicit subtype solves the problem:
@smallexample @c ada
subtype S is Integer range 1..N;
@dots{}
for I in S loop
@dots{}
end loop;
@end smallexample
@noindent
This rule has no parameters.
@node Blocks
@subsection @code{Blocks}
@cindex @code{Blocks} rule (for @command{gnatcheck})
@noindent
Flag each block statement.
This rule has no parameters.
@node Boolean_Relational_Operators
@subsection @code{Boolean_Relational_Operators}
@cindex @code{Boolean_Relational_Operators} rule (for @command{gnatcheck})
@noindent
Flag each call to a predefined relational operator (``<'', ``>'', ``<='',
``>='', ``='' and ``/='') for the predefined Boolean type.
(This rule is useful in enforcing the SPARK language restrictions.)
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.
This rule has no parameters.
@ignore
@node Ceiling_Violations
@subsection @code{Ceiling5_Violations} (under construction, GLOBAL)
@cindex @code{Ceiling_Violations} rule (for @command{gnatcheck})
@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
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
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
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
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.
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
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.
@node Complex_Inlined_Subprograms
@subsection @code{Complex_Inlined_Subprograms}
@cindex @code{Complex_Inlined_Subprograms} rule (for @command{gnatcheck})
@noindent
Flags a subprogram (or generic subprogram) if
pragma Inline is applied to the subprogram and at least one of the following
conditions is met:
@itemize @bullet
@item
it contains at least one complex declaration such as a subprogram body,
package, task, protected declaration, or a generic instantiation
(except instantiation of @code{Ada.Unchecked_Conversion});
@item
it contains at least one complex statement such as a loop, a case
or a if statement, or a short circuit control form;
@item
the number of statements exceeds
a value specified by the @option{N} rule parameter;
@end itemize
@noindent
This rule has the following (mandatory) parameter for the @option{+R} option:
@table @emph
@item N
Positive integer specifying the maximum allowed total number of statements
in the subprogram body.
@end table
@node Declarations_In_Blocks
@subsection @code{Declarations_In_Blocks}
@cindex @code{Declarations_In_Blocks} rule (for @command{gnatcheck})
@noindent
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.
This rule has no parameters.
@node Deep_Inheritance_Hierarchies
@subsection @code{Deep_Inheritance_Hierarchies}
@cindex @code{Deep_Inheritance_Hierarchies} rule (for @command{gnatcheck})
@noindent
Flags a tagged derived type declaration or an interface type declaration if
its depth (in its inheritance
hierarchy) exceeds the value specified by the @option{N} rule parameter.
The inheritance depth of a tagged type or interface type is defined as 0 for
a type with no parent and no progenitor, and otherwise as 1 + max of the
depths of the immediate parent and immediate progenitors.
This rule does not flag private extension
declarations. In the case of a private extension, the corresponding full
declaration is checked.
This rule has the following (mandatory) parameter for the @option{+R} option:
@table @emph
@item N
Integer not less than -1 specifying the maximal allowed depth of any inheritance
hierarchy. If the rule parameter is set to -1, the rule flags all the declarations
of tagged and interface types.
@end table
@node Deeply_Nested_Generics
@subsection @code{Deeply_Nested_Generics}
@cindex @code{Deeply_Nested_Generics} rule (for @command{gnatcheck})
@noindent
Flags a generic declaration nested in another generic declaration if
the nesting level of the inner generic exceeds
a value specified by the @option{N} rule parameter.
The nesting level is the number of generic declaratons that enclose the given
(generic) declaration. Formal packages are not flagged by this rule.
This rule has the following (mandatory) parameters for the @option{+R} option:
@table @emph
@item N
Positive integer specifying the maximal allowed nesting level
for a generic declaration.
@end table
@node Deeply_Nested_Inlining
@subsection @code{Deeply_Nested_Inlining}
@cindex @code{Deeply_Nested_Inlining} rule (for @command{gnatcheck})
@noindent
Flags a subprogram (or generic subprogram) if
pragma Inline has been applied to the subprogram but the subprogram
calls to another inlined subprogram that results in nested inlining
with nesting depth exceeding the value specified by the
@option{N} rule parameter.
This rule requires the global analysis of all the compilation units that
are @command{gnatcheck} arguments; such analysis may affect the tool's
performance.
This rule has the following (mandatory) parameter for the @option{+R} option:
@table @emph
@item N
Positive integer specifying the maximal allowed level of nested inlining.
@end table
@ignore
@node Deeply_Nested_Local_Inlining
@subsection @code{Deeply_Nested_Local_Inlining}
@cindex @code{Deeply_Nested_Local_Inlining} rule (for @command{gnatcheck})
@noindent
Flags a subprogram body if a pragma @code{Inline} is applied to the
corresponding subprogram (or generic subprogram) and the body contains a call
to another inlined subprogram that results in nested inlining with nesting
depth more then a value specified by the @option{N} rule parameter.
This rule is similar to @code{Deeply_Nested_Inlining} rule, but it
assumes that calls to subprograms in
with'ed units are not inlided, so all the analysis of the depth of inlining is
limited by the compilation unit where the subprogram body is located and the
units it depends semantically upon. Such analysis may be usefull for the case
when neiter @option{-gnatn} nor @option{-gnatN} option is used when building
the executable.
This rule has the following (mandatory) parameters for the @option{+R} option:
@table @emph
@item N
Positive integer specifying the maximal allowed level of nested inlining.
@end table
@end ignore
@node Default_Parameters
@subsection @code{Default_Parameters}
@cindex @code{Default_Parameters} rule (for @command{gnatcheck})
@noindent
Flag all default expressions for subprogram parameters. Parameter
declarations of formal and generic subprograms are also checked.
This rule has no parameters.
@node Direct_Calls_To_Primitives
@subsection @code{Direct_Calls_To_Primitives}
@cindex @code{Direct_Calls_To_Primitives} rule (for @command{gnatcheck})
@noindent
Flags any non-dispatching call to a dispatching primitive operation, except
for the common idiom where a primitive subprogram for a tagged type
directly calls the same primitive subprogram of the type's immediate ancestor.
This rule has no parameters.
@node Discriminated_Records
@subsection @code{Discriminated_Records}
@cindex @code{Discriminated_Records} rule (for @command{gnatcheck})
@noindent
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.
This rule has no parameters.
@node Enumeration_Ranges_In_CASE_Statements
@subsection @code{Enumeration_Ranges_In_CASE_Statements}
@cindex @code{Enumeration_Ranges_In_CASE_Statements} (for @command{gnatcheck})
@noindent
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.
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.
This rule has no parameters.
@node Exceptions_As_Control_Flow
@subsection @code{Exceptions_As_Control_Flow}
@cindex @code{Exceptions_As_Control_Flow} (for @command{gnatcheck})
@noindent
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 Exits_From_Conditional_Loops
@subsection @code{Exits_From_Conditional_Loops}
@cindex @code{Exits_From_Conditional_Loops} (for @command{gnatcheck})
@noindent
Flag any exit statement if it transfers the control out of a @code{for} loop
or a @code{while} loop. This includes cases when the @code{exit} statement
applies to a @code{FOR} or @code{while} loop, and cases when it is enclosed
in some @code{for} or @code{while} loop, but transfers the control from some
outer (inconditional) @code{loop} statement.
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
Flag each @code{exit} statement that does not specify the name of the loop
being exited.
The rule has no parameters.
@node Expanded_Loop_Exit_Names
@subsection @code{Expanded_Loop_Exit_Names}
@cindex @code{Expanded_Loop_Exit_Names} rule (for @command{gnatcheck})
@noindent
Flag all expanded loop names in @code{exit} statements.
This rule has no parameters.
@node Explicit_Full_Discrete_Ranges
@subsection @code{Explicit_Full_Discrete_Ranges}
@cindex @code{Explicit_Full_Discrete_Ranges} rule (for @command{gnatcheck})
@noindent
Flag each discrete range that has the form @code{A'First .. A'Last}.
This rule has no parameters.
@node Float_Equality_Checks
@subsection @code{Float_Equality_Checks}
@cindex @code{Float_Equality_Checks} rule (for @command{gnatcheck})
@noindent
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.
This rule has no parameters.
@node Forbidden_Attributes
@subsection @code{Forbidden_Attributes}
@cindex @code{Forbidden_Attributes} rule (for @command{gnatcheck})
@noindent
Flag each use of the specified attributes. The attributes to be detected are
named in the rule's parameters.
This rule has the following parameters:
@itemize @bullet
@item For the @option{+R} option
@table @asis
@item @emph{Attribute_Designator}
Adds the specified attribute to the set of attributes to be detected and sets
the detection checks for all the specified attributes ON.
If @emph{Attribute_Designator}
does not denote any attribute defined in the Ada standard
or in
@ref{Implementation Defined Attributes,,, gnat_rm, GNAT Reference
Manual}, it is treated as the name of unknown attribute.
@item @code{GNAT}
All the GNAT-specific attributes are detected; this sets
the detection checks for all the specified attributes ON.
@item @code{ALL}
All attributes are detected; this sets the rule ON.
@end table
@item For the @option{-R} option
@table @asis
@item @emph{Attribute_Designator}
Removes the specified attribute from the set of attributes to be
detected without affecting detection checks for
other attributes. If @emph{Attribute_Designator} does not correspond to any
attribute defined in the Ada standard or in
@ref{Implementation Defined Attributes,,, gnat_rm, GNAT Reference Manual},
this option is treated as turning OFF detection of all unknown attributes.
@item GNAT
Turn OFF detection of all GNAT-specific attributes
@item ALL
Clear the list of the attributes to be detected and
turn the rule OFF.
@end table
@end itemize
@noindent
Parameters are not case sensitive. If @emph{Attribute_Designator} does not
have the syntax of an Ada identifier and therefore can not be considered as a
(part of an) attribute designator, a diagnostic message is generated and the
corresponding parameter is ignored. (If an attribute allows a static
expression to be a part of the attribute designator, this expression is
ignored by this rule.)
When more then one parameter is given in the same rule option, the parameters
must be separated by commas.
If more then one option for this rule is specified for the 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
attributes 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_Attributes} (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 attributes to be detected.
@node Forbidden_Pragmas
@subsection @code{Forbidden_Pragmas}
@cindex @code{Forbidden_Pragmas} rule (for @command{gnatcheck})
@noindent
Flag each use of the specified pragmas. The pragmas to be detected
are named in the rule's parameters.
This rule has the following parameters:
@itemize @bullet
@item For the @option{+R} option
@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 @ref{Implementation Defined Pragmas,,, gnat_rm, 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
@ref{Implementation Defined Pragmas,,, gnat_rm, 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
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 Function_Style_Procedures
@subsection @code{Function_Style_Procedures}
@cindex @code{Function_Style_Procedures} rule (for @command{gnatcheck})
@noindent
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.
If a procedure can be rewritten as a function, but its @code{out} parameter is
of a limited type, it is not flagged.
Protected procedures are not flagged. Null procedures also are not flagged.
This rule has no parameters.
@node Generics_In_Subprograms
@subsection @code{Generics_In_Subprograms}
@cindex @code{Generics_In_Subprograms} rule (for @command{gnatcheck})
@noindent
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.
This rule has no parameters.
@node GOTO_Statements
@subsection @code{GOTO_Statements}
@cindex @code{GOTO_Statements} rule (for @command{gnatcheck})
@noindent
Flag each occurrence of a @code{goto} statement.
This rule has no parameters.
@node Implicit_IN_Mode_Parameters
@subsection @code{Implicit_IN_Mode_Parameters}
@cindex @code{Implicit_IN_Mode_Parameters} rule (for @command{gnatcheck})
@noindent
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.
@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
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.
This rule has no parameters.
@node Improperly_Located_Instantiations
@subsection @code{Improperly_Located_Instantiations}
@cindex @code{Improperly_Located_Instantiations} rule (for @command{gnatcheck})
@noindent
Flag all generic instantiations in library-level package specs
(including library generic packages) and in all subprogram bodies.
Instantiations in task and entry bodies are not flagged. Instantiations in the
bodies of protected subprograms are flagged.
This rule has no parameters.
@node Improper_Returns
@subsection @code{Improper_Returns}
@cindex @code{Improper_Returns} rule (for @command{gnatcheck})
@noindent
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.
This rule has no parameters.
@node Library_Level_Subprograms
@subsection @code{Library_Level_Subprograms}
@cindex @code{Library_Level_Subprograms} rule (for @command{gnatcheck})
@noindent
Flag all library-level subprograms (including generic subprogram instantiations).
This rule has no parameters.
@node Local_Packages
@subsection @code{Local_Packages}
@cindex @code{Local_Packages} rule (for @command{gnatcheck})
@noindent
Flag all local packages declared in package and generic package
specs.
Local packages in bodies are not flagged.
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
Flag each protected entry that can be called from more than one task.
This rule has no parameters.
@end ignore
@node Metrics
@subsection @code{Metrics}
@cindex @code{Metrics} rule (for @command{gnatcheck})
@noindent
There is a set of checks based on computing a metric value and comparing the
result with the specified upper (or lower, depending on a specific metric)
value specified for a given metric. A construct is flagged if a given metric
is applicable (can be computed) for it and the computed value is greater
then (lover then) the specified upper (lower) bound.
The name of any metric-based rule consists of the prefix @code{Metrics_}
followed by the name of the corresponding metric (see the table below).
For @option{+R} option, each metric-based rule has a numeric parameter
specifying the bound (integer or real, depending on a metric), @option{-R}
option for metric rules does not have a parameter.
The following table shows the metric names for that the corresponding
metrics-based checks are supported by gnatcheck, including the
constraint that must be satisfied by the bound that is specified for the check
and what bound - upper (U) or lower (L) - should be specified.
@multitable {@code{Cyclomatic_Complexity}}{Cyclomatic complexity}{Positive integer}
@ifnothtml
@headitem Check Name @tab Description @tab Bounds Value
@end ifnothtml
@ifhtml
@item @b{Check Name} @tab @b{Description} @tab @b{Bounds Value}
@end ifhtml
@c Above conditional code is workaround to bug in texi2html (Feb 2008)
@item @code{Essential_Complexity} @tab Essential complexity @tab Positive integer (U)
@item @code{Cyclomatic_Complexity} @tab Cyclomatic complexity @tab Positive integer (U)
@item @code{LSLOC} @tab Logical Source Lines of Code @tab Positive integer (U)
@end multitable
@noindent
The meaning and the computed values for all these metrics are exactly
the same as for the corresponding metrics in @command{gnatmetric}.
@emph{Example:} the rule
@smallexample
+RMetrics_Cyclomatic_Complexity : 7
@end smallexample
@noindent
means that all bodies with cyclomatic complexity exceeding 7 will be flagged.
To turn OFF the check for cyclomatic complexity metric, use the following option:
@smallexample
-RMetrics_Cyclomatic_Complexity
@end smallexample
@node Misnamed_Controlling_Parameters
@subsection @code{Misnamed_Controlling_Parameters}
@cindex @code{Misnamed_Controlling_Parameters} rule (for @command{gnatcheck})
@noindent
Flags a declaration of a dispatching operation, if the first parameter is
not a controlling one and its name is not @code{This} (the check for
parameter name is not case-sensitive). Declarations of dispatching functions
with controlling result and no controlling parameter are never flagged.
A subprogram body declaration, subprogram renaming declaration or subprogram
body stub is flagged only if it is not a completion of a prior subprogram
declaration.
This rule has no parameters.
@node Misnamed_Identifiers
@subsection @code{Misnamed_Identifiers}
@cindex @code{Misnamed_Identifiers} rule (for @command{gnatcheck})
@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:
@itemize @bullet
@item
type declarations
@item
subtype declarations
@item
constant declarations (but not number declarations)
@item
package renaming declarations (but not generic package renaming
declarations)
@end itemize
@noindent
This rule may have parameters. When used without parameters, the rule enforces
the following checks:
@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
Defining identifiers from incomplete type declarations are never flagged.
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.
@noindent
For a deferred constant, the defining name in the corresponding full constant
declaration is not checked.
Defining names of formal types are not checked.
The rule may have the following parameters:
@itemize @bullet
@item
For the @option{+R} option:
@table @code
@item Default
Sets the default listed above for all the names to be checked.
@item Type_Suffix=@emph{string}
Specifies the suffix for a type name.
@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.
For access types, @emph{string} may have the following format:
@emph{suffix1(suffix2)}. That means that an access type name
should have the @emph{suffix1} suffix except for the case when
the designated type is also an access type, in this case the
type name should have the @emph{suffix1 & suffix2} suffix.
@item Class_Access_Suffix=@emph{string}
Specifies the suffix for the name of an access type that points to some class-wide
type. If this parameter is set, it overrides for such access
types the suffix set by the @code{Type_Suffix} or @code{Access_Suffix}
parameter.
@item Class_Subtype_Suffix=@emph{string}
Specifies the suffix for the name of a subtype that denotes a class-wide type.
@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 Class_Access_Suffix
Removes the suffix specified for access types pointing to class-wide
type. This disables specific checks for names of access types pointing to
class-wide types 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. If @code{Access_Suffix} is set, these
access types are checked as any other access type name.
@item Class_Subtype_Suffix=@emph{string}
Removes the suffix specified for subtype names.
This disables checks for subtype names but
does not disable any other checks for this rule.
@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
@noindent
If more than one parameter is used, parameters must be separated by commas.
If more than one option is specified for the @command{gnatcheck} invocation,
a new option overrides the previous one(s).
The @option{+RMisnamed_Identifiers} option (with no parameter) enables
checks for all the
name suffixes specified by previous options used for this rule.
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.
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.
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.
@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
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.
This rule has no parameters.
@node Name_Clashes
@subsection @code{Name_Clashes}
@cindex @code{Name_Clashes} rule (for @command{gnatcheck})
@noindent
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.
This rule is enabled by default, but without setting any corresponding
dictionary file(s); thus the default effect is to do no checks.
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.
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.
@node Non_Qualified_Aggregates
@subsection @code{Non_Qualified_Aggregates}
@cindex @code{Non_Qualified_Aggregates} rule (for @command{gnatcheck})
@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.
This rule has no parameters.
@node Non_Short_Circuit_Operators
@subsection @code{Non_Short_Circuit_Operators}
@cindex @code{Non_Short_Circuit_Operators} rule (for @command{gnatcheck})
@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.
This rule has no parameters.
@node Non_SPARK_Attributes
@subsection @code{Non_SPARK_Attributes}
@cindex @code{Non_SPARK_Attributes} rule (for @command{gnatcheck})
@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.
@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
@noindent
This rule has no parameters.
@node Non_Tagged_Derived_Types
@subsection @code{Non_Tagged_Derived_Types}
@cindex @code{Non_Tagged_Derived_Types} rule (for @command{gnatcheck})
@noindent
Flag all derived type declarations that do not have a record extension part.
This rule has no parameters.
@node Non_Visible_Exceptions
@subsection @code{Non_Visible_Exceptions}
@cindex @code{Non_Visible_Exceptions} rule (for @command{gnatcheck})
@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:
@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
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
Renamings of local exceptions are not flagged.
This rule has no parameters.
@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:
@itemize @bullet
@item
a literal occurring in the initialization expression for a constant
declaration or a named number declaration, or
@item
an integer literal that is less than or equal to a value
specified by the @option{N} rule parameter.
@end itemize
@noindent
This rule may have the following parameters for the @option{+R} option:
@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 @code{ALL}
All integer literals are flagged
@end table
@noindent
If no parameters are set, the maximum unflagged value is 1.
The last specified check limit (or the fact that there is no limit at
all) is used when multiple @option{+R} options appear.
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.
@node OTHERS_In_Aggregates
@subsection @code{OTHERS_In_Aggregates}
@cindex @code{OTHERS_In_Aggregates} rule (for @command{gnatcheck})
@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.
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)}.
This rule has no parameters.
@node OTHERS_In_CASE_Statements
@subsection @code{OTHERS_In_CASE_Statements}
@cindex @code{OTHERS_In_CASE_Statements} rule (for @command{gnatcheck})
@noindent
Flag any use of an @code{others} choice in a @code{case} statement.
This rule has no parameters.
@node OTHERS_In_Exception_Handlers
@subsection @code{OTHERS_In_Exception_Handlers}
@cindex @code{OTHERS_In_Exception_Handlers} rule (for @command{gnatcheck})
@noindent
Flag any use of an @code{others} choice in an exception handler.
This rule has no parameters.
@node Outer_Loop_Exits
@subsection @code{Outer_Loop_Exits}
@cindex @code{Outer_Loop_Exits} rule (for @command{gnatcheck})
@noindent
Flag each @code{exit} statement containing a loop name that is not the name
of the immediately enclosing @code{loop} statement.
This rule has no parameters.
@node Overloaded_Operators
@subsection @code{Overloaded_Operators}
@cindex @code{Overloaded_Operators} rule (for @command{gnatcheck})
@noindent
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
This rule has no parameters.
@node Overly_Nested_Control_Structures
@subsection @code{Overly_Nested_Control_Structures}
@cindex @code{Overly_Nested_Control_Structures} rule (for @command{gnatcheck})
@noindent
Flag each control structure whose nesting level exceeds the value provided
in the rule parameter.
The control structures checked are the following:
@itemize @bullet
@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
@noindent
The rule has the following parameter for the @option{+R} option:
@table @emph
@item N
Positive integer specifying the maximal control structure nesting
level that is not flagged
@end table
@noindent
If the parameter for the @option{+R} option is not specified or
if it is not a positive integer, @option{+R} option is ignored.
If more then one option is specified for the gnatcheck call, the later option and
new parameter override the previous one(s).
@node Parameters_Out_Of_Order
@subsection @code{Parameters_Out_Of_Order}
@cindex @code{Parameters_Out_Of_Order} rule (for @command{gnatcheck})
@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
Only the first violation of the described order is flagged.
The following constructs are checked:
@itemize @bullet
@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
@noindent
Subprogram renamings are not checked.
This rule has no parameters.
@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
Flag each generic actual parameter corresponding to a generic formal
parameter with a default initialization, if positional notation is used.
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
Flag each actual parameter to a subprogram or entry call where the
corresponding formal parameter has a default expression, if positional
notation is used.
This rule has no parameters.
@node Positional_Components
@subsection @code{Positional_Components}
@cindex @code{Positional_Components} rule (for @command{gnatcheck})
@noindent
Flag each array, record and extension aggregate that includes positional
notation.
This rule has no parameters.
@node Positional_Generic_Parameters
@subsection @code{Positional_Generic_Parameters}
@cindex @code{Positional_Generic_Parameters} rule (for @command{gnatcheck})
@noindent
Flag each positional actual generic parameter except for the case when
the generic unit being iinstantiated has exactly one generic formal
parameter.
This rule has no parameters.
@node Positional_Parameters
@subsection @code{Positional_Parameters}
@cindex @code{Positional_Parameters} rule (for @command{gnatcheck})
@noindent
Flag each positional parameter notation in a subprogram or entry call,
except for the following:
@itemize @bullet
@item
Parameters of calls to of prefix or infix operators are not flagged
@item
If the called subprogram or entry has only one formal parameter,
the parameter of 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
@noindent
This rule has no parameters.
@node Predefined_Numeric_Types
@subsection @code{Predefined_Numeric_Types}
@cindex @code{Predefined_Numeric_Types} rule (for @command{gnatcheck})
@noindent
Flag each explicit use of the name of any numeric type or subtype defined
in package @code{Standard}.
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:
@smallexample @c ada
subtype My_Integer is Integer range Left .. Right;
Vy_Var : My_Integer;
@end smallexample
@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
This rule has no parameters.
@node Raising_External_Exceptions
@subsection @code{Raising_External_Exceptions}
@cindex @code{Raising_External_Exceptions} rule (for @command{gnatcheck})
@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.
This rule has no parameters.
@node Raising_Predefined_Exceptions
@subsection @code{Raising_Predefined_Exceptions}
@cindex @code{Raising_Predefined_Exceptions} rule (for @command{gnatcheck})
@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}).
This rule has no parameters.
@node Separate_Numeric_Error_Handlers
@subsection @code{Separate_Numeric_Error_Handlers}
@cindex @code{Separate_Numeric_Error_Handlers} rule (for @command{gnatcheck})
@noindent
Flags each exception handler that contains a choice for
the predefined @code{Constraint_Error} exception, but does not contain
the choice for the predefined @code{Numeric_Error} exception, or
that contains the choice for @code{Numeric_Error}, but does not contain the
choice for @code{Constraint_Error}.
This rule has no parameters.
@ignore
@node Recursion
@subsection @code{Recursion} (under construction, GLOBAL)
@cindex @code{Recursion} rule (for @command{gnatcheck})
@noindent
Flag recursive subprograms (cycles in the call graph). Declarations, and not
calls, of recursive subprograms are detected.
This rule has no parameters.
@end ignore
@ignore
@node Side_Effect_Functions
@subsection @code{Side_Effect_Functions} (under construction, GLOBAL)
@cindex @code{Side_Effect_Functions} rule (for @command{gnatcheck})
@noindent
Flag functions with side effects.
We define a side effect as changing any data object that is not local for the
body of this function.
At the moment, we do NOT consider a side effect any input-output operations
(changing a state or a content of any file).
We do not consider protected functions for this rule (???)
There are the following sources of side effect:
@enumerate
@item Explicit (or direct) side-effect:
@itemize @bullet
@item
direct assignment to a non-local variable;
@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 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
@item
activation of a task that change some non-local data object (directly or
indirectly);
@item
elaboration code of a package that is a result of a package instantiation;
@item
controlled objects;
@end itemize
@item Situations when we can suspect a side-effect, but the full static check
is either impossible or too hard:
@itemize @bullet
@item
assignment to access variables or to the objects pointed by access
variables;
@item
call to a subprogram pointed by access-to-subprogram value
@item
dispatching calls;
@end itemize
@end enumerate
@noindent
This rule has no parameters.
@end ignore
@node Slices
@subsection @code{Slices}
@cindex @code{Slices} rule (for @command{gnatcheck})
@noindent
Flag all uses of array slicing
This rule has no parameters.
@node Too_Many_Parents
@subsection @code{Too_Many_Parents}
@cindex @code{Too_Many_Parents} rule (for @command{gnatcheck})
@noindent
Flags any type declaration, single task declaration or single protected
declaration that has more then @option{N} parents, @option{N} is a parameter
of the rule.
A parent here is either a (sub)type denoted by the subtype mark from the
parent_subtype_indication (in case of a derived type declaration), or
any of the progenitors from the interface list, if any.
This rule has the following (mandatory) parameters for the @option{+R} option:
@table @emph
@item N
Positive integer specifying the maximal allowed number of parents.
@end table
@node Unassigned_OUT_Parameters
@subsection @code{Unassigned_OUT_Parameters}
@cindex @code{Unassigned_OUT_Parameters} rule (for @command{gnatcheck})
@noindent
Flags procedures' @code{out} parameters that are not assigned, and
identifies the contexts in which the assignments are missing.
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.
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.
Bodies of generic procedures are also considered.
The following are treated as assignments to an @code{out} parameter:
@itemize @bullet
@item
an assignment statement, with the parameter or some component as the target;
@item
passing the parameter (or one of its components) as an @code{out} or
@code{in out} parameter.
@end itemize
@noindent
This rule does not have any parameters.
@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
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.
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.
This rule has no parameters.
@node Unconditional_Exits
@subsection @code{Unconditional_Exits}
@cindex @code{Unconditional_Exits} rule (for @command{gnatcheck})
@noindent
Flag unconditional @code{exit} statements.
This rule has no parameters.
@node Unconstrained_Array_Returns
@subsection @code{Unconstrained_Array_Returns}
@cindex @code{Unconstrained_Array_Returns} rule (for @command{gnatcheck})
@noindent
Flag each function returning an unconstrained array. Function declarations,
function bodies (and body stubs) having no separate specifications,
and generic function instantiations are checked.
Function calls and function renamings are
not checked.
Generic function declarations, and function declarations in generic
packages are not checked, instead this rule checks the results of
generic instantiations (that is, expanded specification and expanded
body corresponding to an instantiation).
This rule has no parameters.
@node Universal_Ranges
@subsection @code{Universal_Ranges}
@cindex @code{Universal_Ranges} rule (for @command{gnatcheck})
@noindent
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.
This rule has no parameters.
@node Unnamed_Blocks_And_Loops
@subsection @code{Unnamed_Blocks_And_Loops}
@cindex @code{Unnamed_Blocks_And_Loops} rule (for @command{gnatcheck})
@noindent
Flag each unnamed block statement and loop statement.
The rule has no parameters.
@ignore
@node Unused_Subprograms
@subsection @code{Unused_Subprograms} (under construction, GLOBAL)
@cindex @code{Unused_Subprograms} rule (for @command{gnatcheck})
@noindent
Flag all unused subprograms.
This rule has no parameters.
@end ignore
@node USE_PACKAGE_Clauses
@subsection @code{USE_PACKAGE_Clauses}
@cindex @code{USE_PACKAGE_Clauses} rule (for @command{gnatcheck})
@noindent
Flag all @code{use} clauses for packages; @code{use type} clauses are
not flagged.
This rule has no parameters.
@node Visible_Components
@subsection @code{Visible_Components}
@cindex @code{Visible_Components} rule (for @command{gnatcheck})
@noindent
Flags all the type declarations located in the visible part of a library
package or a library generic package that can declare a visible component. A
type is considered as declaring a visible component if it contains a record
definition by its own or as a part of a record extension. Type declaration is
flagged even if it contains a record definition that defines no components.
Declarations located in private parts of local (generic) packages are not
flagged. Declarations in private packages are not flagged.
This rule has no parameters.
@node Volatile_Objects_Without_Address_Clauses
@subsection @code{Volatile_Objects_Without_Address_Clauses}
@cindex @code{Volatile_Objects_Without_Address_Clauses} rule (for @command{gnatcheck})
@noindent
Flag each volatile object that does not have an address clause.
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.
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}.
Only variable declarations, and not constant declarations, are checked.
This rule has no parameters.
@node Example of gnatcheck Usage @node Example of gnatcheck Usage
@section Example of @command{gnatcheck} Usage @section Example of @command{gnatcheck} Usage
...@@ -17484,6 +17484,15 @@ package body Sem_Ch3 is ...@@ -17484,6 +17484,15 @@ package body Sem_Ch3 is
and then Ekind (Current_Entity (Typ)) = E_Incomplete_Type and then Ekind (Current_Entity (Typ)) = E_Incomplete_Type
and then Full_View (Current_Entity (Typ)) = Typ and then Full_View (Current_Entity (Typ)) = Typ
then then
if Is_Tagged
and then Comes_From_Source (Current_Entity (Typ))
and then not Is_Tagged_Type (Current_Entity (Typ))
then
Make_Class_Wide_Type (Typ);
Error_Msg_N
("incomplete view of tagged type should be declared tagged?",
Parent (Current_Entity (Typ)));
end if;
return; return;
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment