Skip to content

Commit

Permalink
Merge branch 'topic/97' into 'master'
Browse files Browse the repository at this point in the history
Fix off-by-one error when reaching max diagnoses to print.

Closes #97

See merge request eng/libadalang/langkit-query-language!217
  • Loading branch information
Roldak committed May 6, 2024
2 parents b571ab3 + ae7bc1b commit d849b42
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lkql_checker/src/gnatcheck-diagnoses.adb
Expand Up @@ -1845,7 +1845,7 @@ package body Gnatcheck.Diagnoses is
begin
if not Limit_Exceeded then
if Max_Diagnoses > 0 and then
Diagnoses_Reported > Max_Diagnoses
Diagnoses_Reported >= Max_Diagnoses
then
Limit_Exceeded := True;
Info ("Maximum diagnoses reached, " &
Expand Down
9 changes: 9 additions & 0 deletions testsuite/tests/gnatcheck/max_diagnoses/test.adb
@@ -0,0 +1,9 @@
procedure Test is
A : Integer := 0;
begin
if A /= 0 or else A /= 1 then null; end if; -- FLAG
if A /= 0 or else A /= 1 then null; end if;
if A /= 0 or else A /= 1 then null; end if;
if A /= 0 or else A /= 1 then null; end if;
end Test;

2 changes: 2 additions & 0 deletions testsuite/tests/gnatcheck/max_diagnoses/test.out
@@ -0,0 +1,2 @@
test.adb:4:06: suspicious equality
Maximum diagnoses reached, see the report file for full details
6 changes: 6 additions & 0 deletions testsuite/tests/gnatcheck/max_diagnoses/test.yaml
@@ -0,0 +1,6 @@
format: brief
driver: gnatcheck
input_sources: [test.adb]
extra_args: [-m1]
rules:
- +Rsuspicious_equalities

0 comments on commit d849b42

Please sign in to comment.