[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The rules in this chapter can be used to enforce specific usage patterns for a variety of language features.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Abstract_Type_Declarations
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Anonymous_Subtypes
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 for
loops such as the following are
flagged (since 1..N
is formally a “range”):
for I in 1 .. N loop … end loop; |
Declaring an explicit subtype solves the problem:
subtype S is Integer range 1..N; … for I in S loop … end loop; |
This rule has no parameters.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Blocks
Flag each block statement.
This rule has no parameters.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Complex_Inlined_Subprograms
Flags a subprogram (or generic subprogram) if pragma Inline is applied to the subprogram and at least one of the following conditions is met:
Ada.Unchecked_Conversion
);
This rule has the following (mandatory) parameter for the ‘+R’ option:
Positive integer specifying the maximum allowed total number of statements in the subprogram body.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Controlled_Type_Declarations
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 Ada.Finalization
but has a controlled
component is not checked.
This rule has no parameters.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Declarations_In_Blocks
Flag all block statements containing local declarations. A declare
block with an empty declarative_part or with a declarative part
containing only pragmas and/or use
clauses is not flagged.
This rule has no parameters.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Deeply_Nested_Inlining
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 ‘N’ rule parameter.
This rule requires the global analysis of all the compilation units that
are gnatcheck
arguments; such analysis may affect the tool’s
performance.
This rule has the following (mandatory) parameter for the ‘+R’ option:
Positive integer specifying the maximal allowed level of nested inlining.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Default_Parameters
Flag all default expressions in parameters specifications. All parameter specifications are checked: in subprograms (including formal, generic and protected subprograms) and in task and protected entries (including accept statements and entry bodies).
This rule has no parameters.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Discriminated_Records
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Explicit_Full_Discrete_Ranges
Flag each discrete range that has the form A'First .. A'Last
.
This rule has no parameters.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Float_Equality_Checks
Flag all calls to the predefined equality operations for floating-point types.
Both “=
” and “/=
” operations are checked.
User-defined equality operations are not flagged, nor are “=
”
and “/=
” operations for fixed-point types.
This rule has no parameters.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Function_Style_Procedures
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 out
and no parameters of mode 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 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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Generics_In_Subprograms
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Implicit_IN_Mode_Parameters
Flag each occurrence of a formal parameter with an implicit in
mode.
Note that access
parameters, although they technically behave
like in
parameters, are not flagged.
This rule has no parameters.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Improperly_Located_Instantiations
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Library_Level_Subprograms
Flag all library-level subprograms (including generic subprogram instantiations).
This rule has no parameters.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Non_Qualified_Aggregates
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Numeric_Literals
Flag each use of a numeric literal in an index expression, and in any circumstance except for the following:
This rule may have the following parameters for the ‘+R’ option:
N is an integer literal used as the maximal value that is not flagged (i.e., integer literals not exceeding this value are allowed)
ALL
All integer literals are flagged
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 ‘+R’ options appear.
The ‘-R’ option for this rule has no parameters. It disables the rule but retains the last specified maximum unflagged value. If the ‘+R’ option subsequently appears, this value is used as the threshold for the check.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Parameters_Out_Of_Order
Flag each subprogram and entry declaration whose formal parameters are not ordered according to the following scheme:
in
and access
parameters first,
then in out
parameters,
and then out
parameters;
in
mode, parameters with default initialization expressions
occur last
Only the first violation of the described order is flagged.
The following constructs are checked:
Subprogram renamings are not checked.
This rule has no parameters.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Raising_Predefined_Exceptions
Flag each raise
statement that raises a predefined exception
(i.e., one of the exceptions Constraint_Error
, Numeric_Error
,
Program_Error
, Storage_Error
, or Tasking_Error
).
This rule has no parameters.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Unassigned_OUT_Parameters
Flags procedures’ out
parameters that are not assigned, and
identifies the contexts in which the assignments are missing.
An out
parameter is flagged in the statements in the procedure
body’s handled sequence of statements (before the procedure body’s
exception
part, if any) if this sequence of statements contains
no assignments to the parameter.
An 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 neither assignment to the parameter nor a raise
statement.
Bodies of generic procedures are also considered.
The following are treated as assignments to an out
parameter:
out
or
in out
parameter.
This rule does not have any parameters.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Unconstrained_Array_Returns
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.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by root on February 6, 2012 using texi2html 1.82.