GNATcheck Reference Manual
GNATcheck, The GNAT coding standard checker
GNATcheck
Version 25.1
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 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 ‘GNATcheck Reference Manual’, and with no Back-Cover Texts. A copy of the license is included in the section entitled ‘GNU Free Documentation License’.
- 1. Getting Started
- 2. Using GNATcheck
- 2.1. General GNATcheck Switches
- 2.2. The Check GPR Package
- 2.3. LKQL Rule Files
- 2.4. GNATcheck Rule Options
- 2.5. Mapping GNATcheck Rules Onto Coding Standards
- 2.6. GNATcheck Exit Codes
- 2.7. Format of the Report File
- 2.8. Rule Exemption
- 2.9. Using GNATcheck as a Known Problem Detector
- 2.10. Performance and Memory Usage
- 2.11. Transition from ASIS-based GNATcheck
- 3. Predefined Rules
- 3.1. Style-Related Rules
- 3.1.1. Tasking
- 3.1.2. Object Orientation
- 3.1.2.1.
Constructors - 3.1.2.2.
Deep_Inheritance_Hierarchies - 3.1.2.3.
Direct_Calls_To_Primitives - 3.1.2.4.
Downward_View_Conversions - 3.1.2.5.
No_Inherited_Classwide_Pre - 3.1.2.6.
Specific_Pre_Post - 3.1.2.7.
Specific_Parent_Type_Invariant - 3.1.2.8.
Specific_Type_Invariants - 3.1.2.9.
Too_Many_Parents - 3.1.2.10.
Too_Many_Primitives - 3.1.2.11.
Visible_Components
- 3.1.2.1.
- 3.1.3. Portability
- 3.1.3.1.
Bit_Records_Without_Layout_Definition - 3.1.3.2.
Forbidden_Aspects - 3.1.3.3.
Forbidden_Attributes - 3.1.3.4.
Forbidden_Pragmas - 3.1.3.5.
Implicit_SMALL_For_Fixed_Point_Types - 3.1.3.6.
Incomplete_Representation_Specifications - 3.1.3.7.
Membership_For_Validity - 3.1.3.8.
No_Explicit_Real_Range - 3.1.3.9.
No_Scalar_Storage_Order_Specified - 3.1.3.10.
Predefined_Numeric_Types - 3.1.3.11.
Printable_ASCII - 3.1.3.12.
Separate_Numeric_Error_Handlers - 3.1.3.13.
Size_Attribute_For_Types
- 3.1.3.1.
- 3.1.4. Program Structure
- 3.1.4.1.
Deep_Library_Hierarchy - 3.1.4.2.
Deeply_Nested_Generics - 3.1.4.3.
Deeply_Nested_Instantiations - 3.1.4.4.
Local_Packages - 3.1.4.5.
Non_Visible_Exceptions - 3.1.4.6.
Maximum_Expression_Complexity - 3.1.4.7.
Maximum_Subprogram_Lines - 3.1.4.8.
One_Tagged_Type_Per_Package - 3.1.4.9.
Raising_External_Exceptions - 3.1.4.10.
Same_Instantiations - 3.1.4.11.
Too_Many_Generic_Dependencies
- 3.1.4.1.
- 3.1.5. Programming Practice
- 3.1.5.1.
Access_To_Local_Objects - 3.1.5.2.
Actual_Parameters - 3.1.5.3.
Ada05_Formal_Packages - 3.1.5.4.
Ada_2022_In_Ghost_Code - 3.1.5.5.
Address_Attribute_For_Non_Volatile_Objects - 3.1.5.6.
Address_Specifications_For_Initialized_Objects - 3.1.5.7.
Address_Specifications_For_Local_Objects - 3.1.5.8.
Anonymous_Arrays - 3.1.5.9.
Binary_Case_Statements - 3.1.5.10.
Boolean_Negations - 3.1.5.11.
Calls_In_Exception_Handlers - 3.1.5.12.
Calls_Outside_Elaboration - 3.1.5.13.
Concurrent_Interfaces - 3.1.5.14.
Constant_Overlays - 3.1.5.15.
Default_Values_For_Record_Components - 3.1.5.16.
Direct_Equalities - 3.1.5.17.
Deriving_From_Predefined_Type - 3.1.5.18.
Duplicate_Branches - 3.1.5.19.
Enumeration_Ranges_In_CASE_Statements - 3.1.5.20.
Enumeration_Representation_Clauses - 3.1.5.21.
Exception_Propagation_From_Callbacks - 3.1.5.22.
Exception_Propagation_From_Export - 3.1.5.23.
Exception_Propagation_From_Tasks - 3.1.5.24.
Exceptions_As_Control_Flow - 3.1.5.25.
Exits_From_Conditional_Loops - 3.1.5.26.
EXIT_Statements_With_No_Loop_Name - 3.1.5.27.
Final_Package - 3.1.5.28.
Global_Variables - 3.1.5.29.
GOTO_Statements - 3.1.5.30.
Integer_Types_As_Enum - 3.1.5.31.
Improper_Returns - 3.1.5.32.
Local_Instantiations - 3.1.5.33.
Local_USE_Clauses - 3.1.5.34.
Maximum_Lines - 3.1.5.35.
Maximum_OUT_Parameters - 3.1.5.36.
Maximum_Parameters - 3.1.5.37.
Misplaced_Representation_Items - 3.1.5.38.
Nested_Paths - 3.1.5.39.
Nested_Subprograms - 3.1.5.40.
No_Closing_Names - 3.1.5.41.
No_Others_In_Exception_Handlers - 3.1.5.42.
Non_Component_In_Barriers - 3.1.5.43.
Non_Constant_Overlays - 3.1.5.44.
Nonoverlay_Address_Specifications - 3.1.5.45.
Non_Short_Circuit_Operators - 3.1.5.46.
Not_Imported_Overlays - 3.1.5.47.
Null_Paths - 3.1.5.48.
Objects_Of_Anonymous_Types - 3.1.5.49.
Operator_Renamings - 3.1.5.50.
OTHERS_In_Aggregates - 3.1.5.51.
OTHERS_In_CASE_Statements - 3.1.5.52.
OTHERS_In_Exception_Handlers - 3.1.5.53.
Outbound_Protected_Assignments - 3.1.5.54.
Outside_References_From_Subprograms - 3.1.5.55.
Overly_Nested_Control_Structures - 3.1.5.56.
Overly_Nested_Scopes - 3.1.5.57.
Parameters_Aliasing - 3.1.5.58.
POS_On_Enumeration_Types - 3.1.5.59.
Positional_Actuals_For_Defaulted_Generic_Parameters - 3.1.5.60.
Positional_Actuals_For_Defaulted_Parameters - 3.1.5.61.
Positional_Components - 3.1.5.62.
Positional_Generic_Parameters - 3.1.5.63.
Positional_Parameters - 3.1.5.64.
Potential_Parameters_Aliasing - 3.1.5.65.
Profile_Discrepancies - 3.1.5.66.
Recursive_Subprograms - 3.1.5.67.
Redundant_Boolean_Expressions - 3.1.5.68.
Redundant_Null_Statements - 3.1.5.69.
Restrictions - 3.1.5.70.
Same_Logic - 3.1.5.71.
Same_Operands - 3.1.5.72.
Same_Tests - 3.1.5.73.
Side_Effect_Parameters - 3.1.5.74.
Silent_Exception_Handlers - 3.1.5.75.
Single_Value_Enumeration_Types - 3.1.5.76.
SPARK_Procedures_Without_Globals - 3.1.5.77.
Trivial_Exception_Handlers - 3.1.5.78.
Unavailable_Body_Calls - 3.1.5.79.
Unchecked_Address_Conversions - 3.1.5.80.
Unchecked_Conversions_As_Actuals - 3.1.5.81.
Unconditional_Exits - 3.1.5.82.
Uninitialized_Global_Variables - 3.1.5.83.
Unnamed_Blocks_And_Loops - 3.1.5.84.
Unnamed_Exits - 3.1.5.85.
Use_Array_Slices - 3.1.5.86.
Use_Case_Statements - 3.1.5.87.
USE_Clauses - 3.1.5.88.
Use_For_Loops - 3.1.5.89.
Use_For_Of_Loops - 3.1.5.90.
Use_If_Expressions - 3.1.5.91.
Use_Memberships - 3.1.5.92.
USE_PACKAGE_Clauses - 3.1.5.93.
Use_Ranges - 3.1.5.94.
Use_Record_Aggregates - 3.1.5.95.
Use_Simple_Loops - 3.1.5.96.
Use_While_Loops - 3.1.5.97.
Variable_Scoping - 3.1.5.98.
Warnings
- 3.1.5.1.
- 3.1.6. Readability
- 3.1.6.1.
End_Of_Line_Comments - 3.1.6.2.
Headers - 3.1.6.3.
Identifier_Casing - 3.1.6.4.
Identifier_Prefixes - 3.1.6.5.
Identifier_Suffixes - 3.1.6.6.
Max_Identifier_Length - 3.1.6.7.
Min_Identifier_Length - 3.1.6.8.
Misnamed_Controlling_Parameters - 3.1.6.9.
Name_Clashes - 3.1.6.10.
Numeric_Format - 3.1.6.11.
Object_Declarations_Out_Of_Order - 3.1.6.12.
One_Construct_Per_Line - 3.1.6.13.
Style_Checks - 3.1.6.14.
Uncommented_BEGIN - 3.1.6.15.
Uncommented_BEGIN_In_Package_Bodies - 3.1.6.16.
Uncommented_End_Record
- 3.1.6.1.
- 3.2. Feature Usage Rules
- 3.2.1.
Abort_Statements - 3.2.2.
Abstract_Type_Declarations - 3.2.3.
Anonymous_Access - 3.2.4.
Anonymous_Subtypes - 3.2.5.
At_Representation_Clauses - 3.2.6.
Blocks - 3.2.7.
Complex_Inlined_Subprograms - 3.2.8.
Conditional_Expressions - 3.2.9.
Controlled_Type_Declarations - 3.2.10.
Declarations_In_Blocks - 3.2.11.
Deeply_Nested_Inlining - 3.2.12.
Default_Parameters - 3.2.13.
Discriminated_Records - 3.2.14.
Explicit_Full_Discrete_Ranges - 3.2.15.
Explicit_Inlining - 3.2.16.
Expression_Functions - 3.2.17.
Fixed_Equality_Checks - 3.2.18.
Float_Equality_Checks - 3.2.19.
Function_Style_Procedures - 3.2.20.
Generic_IN_OUT_Objects - 3.2.21.
Generics_In_Subprograms - 3.2.22.
Implicit_IN_Mode_Parameters - 3.2.23.
Improperly_Located_Instantiations - 3.2.24.
Library_Level_Subprograms - 3.2.25.
Membership_Tests - 3.2.26.
Non_Qualified_Aggregates - 3.2.27.
Number_Declarations - 3.2.28.
Numeric_Indexing - 3.2.29.
Numeric_Literals - 3.2.30.
Parameters_Out_Of_Order - 3.2.31.
Predicate_Testing - 3.2.32.
Relative_Delay_Statements - 3.2.33.
Renamings - 3.2.34.
Representation_Specifications - 3.2.35.
Quantified_Expressions - 3.2.36.
Raising_Predefined_Exceptions - 3.2.37.
Separates - 3.2.38.
Simple_Loop_Statements - 3.2.39.
Subprogram_Access - 3.2.40.
Suspicious_Equalities - 3.2.41.
Too_Many_Dependencies - 3.2.42.
Unassigned_OUT_Parameters - 3.2.43.
Unconstrained_Array_Returns - 3.2.44.
Unconstrained_Arrays
- 3.2.1.
- 3.3. Metrics-Related Rules
- 3.4. SPARK 2005 Rules
- 3.1. Style-Related Rules
- 4. Writing Your Own Rules
- 5. LKQL Language Reference
- 5.1. General Purpose Language Subset
- 5.1.1. Data Types
- 5.1.2. Declarations
- 5.1.3. Expressions
- 5.1.3.1. Block Expression
- 5.1.3.2. Field Access
- 5.1.3.3. Unwrap Expression
- 5.1.3.4. Call Expression
- 5.1.3.5. Constructor call
- 5.1.3.6. Indexing Expression
- 5.1.3.7. Comparison Expression
- 5.1.3.8. Object Literal
- 5.1.3.9. List Literal
- 5.1.3.10. List Comprehension
- 5.1.3.11. If Expression
- 5.1.3.12. Match Expression
- 5.1.3.13. Tuple Literal
- 5.1.3.14. Anonymous Function
- 5.1.3.15. Literals and Operators
- 5.1.3.16. Module Importation
- 5.2. Query Language Subset
- 5.3. Language changes
- 5.4. LKQL API
- 5.1. General Purpose Language Subset