Skip to content

Commit 3e7e879

Browse files
committed
Update the GNATcheck example
1 parent 2a77485 commit 3e7e879

File tree

4 files changed

+81
-87
lines changed

4 files changed

+81
-87
lines changed

lkql_checker/share/examples/README.gnatcheck

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
G N A T C H E C K E X A M P L E
2-
==================================
1+
G N A T C H E C K E X A M P L E
2+
==================================
33

44
This directory contains a simple example of using GNATcheck. This example is
55
derived from one of the examples included in the GNAT compiler distribution
@@ -8,29 +8,26 @@ installation if you have one).
88

99
Compared to the original example, the following two things have been added:
1010

11-
- A sample GNATcheck coding standard file named 'coding_standard.rules'; this
12-
is a text file containing a set of GNATcheck rule options).
13-
14-
- The original project file now contains the package 'Check'; this package
15-
tells GNATcheck to use the coding standard file mentioned above.
11+
- A sample GNATcheck coding standard file named 'rules.lkql'; this is an LKQL
12+
file containing a set of GNATcheck rules and their configuration.
1613

1714
If you want to try out GNATcheck on any other project - just copy the sample
18-
coding standard file to another project's directory, and add the
19-
'Check' package to this project file.
15+
coding standard file to another project's directory, besides the GPR file.
16+
GNATcheck will use it by default when running on this project file.
2017

2118
You can also modify the coding standard file in any way you want - you can
2219
add new rules, change rule parameters, disable some rules. Please refer to
2320
the GNATcheck Reference Manual for more details.
2421

2522

26-
2723
Using GNATcheck from the command line
2824
-------------------------------------
2925

3026
$ gnatcheck -P simple.gpr
3127

3228
GNATcheck will output messages in your command shell, and will also generate
33-
the report file "gnatcheck.out" in the project's objects directory.
29+
the report file "gnatcheck/gnatcheck.out" in the project's objects directory.
30+
3431

3532
Using GNATcheck from GPS
3633
------------------------

lkql_checker/share/examples/coding_standard.rules

Lines changed: 0 additions & 70 deletions
This file was deleted.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
val rules = @{
2+
Abstract_Type_Declarations,
3+
Anonymous_Arrays,
4+
Anonymous_Subtypes,
5+
Blocks,
6+
7+
Boolean_Relational_Operators,
8+
# Flag each call to a predefined relational operator
9+
# (<, >, <=, >=, = and /=) for the predefined Boolean type.
10+
11+
Complex_Inlined_Subprograms: {N: 3},
12+
# Flag a subprogram (or generic subprogram, or instantiation of a
13+
# subprogram) if pragma Inline is applied to it and at least one of the
14+
# following conditions is met:
15+
# * it contains at least one complex declaration such as a subprogram
16+
# body, package, task, protected declaration, or a generic instantiation
17+
# (except instantiation of Ada.Unchecked_Conversion);
18+
# * it contains at least one complex statement such as a loop, a case or
19+
# an if statement;
20+
# * the number of statements exceeds 3
21+
22+
Controlled_Type_Declarations,
23+
24+
Deep_Inheritance_Hierarchies: {N: 5},
25+
# Flag a tagged derived type declaration or an interface type declaration
26+
# if its depth (in its inheritance hierarchy) exceeds 5
27+
28+
Deeply_Nested_Generics: {N: 3},
29+
# Flag a generic declaration nested in another generic declaration if the
30+
# nesting level of the inner generic exceeds 3
31+
32+
Identifier_Casing: {Others: "mixed"},
33+
# Flag any defining identifier if it casing does not follow the rules: the
34+
# first letter and every letter after underscore are uppercase, all the
35+
# other lettres are lowercase
36+
37+
Identifier_Suffixes: {
38+
Type_Suffix: "_Type",
39+
Access_Suffix: "_Access_Type",
40+
Class_Access_Suffix: "_Class_Type"
41+
},
42+
# Flag any defining identifier if it corresponds to the given kind of
43+
# entities but does not have a specified suffix
44+
45+
Identifier_Prefixes: {
46+
Type: "T_",
47+
Access: "A_",
48+
Constant: "C_"
49+
},
50+
# Flag any defining identifier if it corresponds to the given kind of
51+
# entities but does not have a specified prefix
52+
53+
Non_Qualified_Aggregates,
54+
Non_Short_Circuit_Operators,
55+
56+
OTHERS_In_Aggregates,
57+
OTHERS_In_CASE_Statements,
58+
OTHERS_In_Exception_Handlers,
59+
60+
Warnings: "km",
61+
# Include warnings generated by the compiler with '-gnatwk' (variables that
62+
# could be constants) and '-gnatwm' (modified but unreferenced variables)
63+
# into generated gnatcheck report
64+
65+
Style_Checks: "uO",
66+
# Include warnings generated by the compiler style checks '-gnatyu'
67+
# (unnecessary blank lines) and '-gnatyO' (overriding subprograms are
68+
# not explicitly marked as such.) into generated gnatcheck report
69+
70+
Restrictions: {Arg: ["No_Allocators", "No_Tasking", "No_Dependence => Ada.Containers"]}
71+
# Include warnings generated by the compiler with the specified restrictions
72+
# into generated gnatcheck report
73+
}

lkql_checker/share/examples/simple.gpr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,4 @@ Project Simple is
5050
-- This attribute contains the switches used for "diners" only
5151
end Builder;
5252

53-
package Check is
54-
for Default_Switches ("ada") use ("-rules", "-from=coding_standard.rules");
55-
-- This attribute contains the switches used by the coding standard
56-
-- verifier
57-
end Check;
58-
5953
end Simple;

0 commit comments

Comments
 (0)