From b378f42eddbe8b8008f9a926bbc8dc0c4edf5950 Mon Sep 17 00:00:00 2001 From: Hugo Guerrier Date: Mon, 28 Oct 2024 10:56:35 +0100 Subject: [PATCH] Ignore accept statement bodies in 'one_construct_per_line' --- .../share/lkql/one_construct_per_line.lkql | 2 +- .../checks/one_construct_per_line/line.adb | 21 ++++++++ .../checks/one_construct_per_line/test.out | 48 ++++++++++--------- 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/lkql_checker/share/lkql/one_construct_per_line.lkql b/lkql_checker/share/lkql/one_construct_per_line.lkql index f75c6b5b3..28e89d22f 100644 --- a/lkql_checker/share/lkql/one_construct_per_line.lkql +++ b/lkql_checker/share/lkql/one_construct_per_line.lkql @@ -26,7 +26,7 @@ fun one_construct_per_line(node) = LabelDecl | GenericSubpInternal | ConcreteFormalSubpDecl | ExtendedReturnStmtObjectDecl | - NamedStmtDecl)) + NamedStmtDecl | AcceptStmtBody)) and (node.token_end().end_line == stdlib.next_non_blank_token_line(node.token_end()) or node.token_start().start_line == diff --git a/testsuite/tests/checks/one_construct_per_line/line.adb b/testsuite/tests/checks/one_construct_per_line/line.adb index 5b64c8514..fcc60854f 100644 --- a/testsuite/tests/checks/one_construct_per_line/line.adb +++ b/testsuite/tests/checks/one_construct_per_line/line.adb @@ -1,5 +1,26 @@ package body Line is + task type Tsk is + entry Start (I : Integer; B : Boolean); -- NOFLAG + end Tsk; + + task type Other_Tsk is + entry Start (I : Integer; B : Boolean); -- NOFLAG + end Other_Tsk; + + task body Tsk is + begin + accept Start (I : Integer; B : Boolean) do -- NOFLAG + null; + end Start; + end Tsk; + + task body Other_Tsk is + begin + accept Start (I : Integer; B : Boolean) do null; -- FLAG + end Start; + end Other_Tsk; + procedure Proc (I : in out Integer) is Tmp : Integer; diff --git a/testsuite/tests/checks/one_construct_per_line/test.out b/testsuite/tests/checks/one_construct_per_line/test.out index 90b80cd2f..d87221f0d 100644 --- a/testsuite/tests/checks/one_construct_per_line/test.out +++ b/testsuite/tests/checks/one_construct_per_line/test.out @@ -14,46 +14,50 @@ line.ads:9:14: rule violation: more than one construct on the same line 9 | procedure Proc (I : in out Integer); end Line; -- FLAG | ^^^^ -line.adb:8:7: rule violation: more than one construct on the same line -8 | B3 : Boolean; B4 : Boolean; -- FLAG (2) - | ^^ +line.adb:20:50: rule violation: more than one construct on the same line +20 | accept Start (I : Integer; B : Boolean) do null; -- FLAG + | ^^^^^ -line.adb:8:21: rule violation: more than one construct on the same line -8 | B3 : Boolean; B4 : Boolean; -- FLAG (2) - | ^^ +line.adb:29:7: rule violation: more than one construct on the same line +29 | B3 : Boolean; B4 : Boolean; -- FLAG (2) + | ^^ -line.adb:12:10: rule violation: more than one construct on the same line -12 | I := J; if I > 0 then -- FLAG (2) +line.adb:29:21: rule violation: more than one construct on the same line +29 | B3 : Boolean; B4 : Boolean; -- FLAG (2) + | ^^ + +line.adb:33:10: rule violation: more than one construct on the same line +33 | I := J; if I > 0 then -- FLAG (2) | ^^^^^^^ -line.adb:12:18: rule violation: more than one construct on the same line -12 | I := J; if I > 0 then -- FLAG (2) +line.adb:33:18: rule violation: more than one construct on the same line +33 | I := J; if I > 0 then -- FLAG (2) | __________________^ -13 || I := 0; end if; -- FLAG +34 || I := 0; end if; -- FLAG ||__________________________^ -line.adb:13:12: rule violation: more than one construct on the same line -13 | I := 0; end if; -- FLAG +line.adb:34:12: rule violation: more than one construct on the same line +34 | I := 0; end if; -- FLAG | ^^^^^^^ -line.adb:26:18: rule violation: more than one construct on the same line -26 | My_Loop_2: for I in 1 .. 2 loop -- FLAG +line.adb:47:18: rule violation: more than one construct on the same line +47 | My_Loop_2: for I in 1 .. 2 loop -- FLAG | __________________^ || || ~~~ 1 other lines ~~~ || -28 || end loop My_Loop_2; +49 || end loop My_Loop_2; ||_________________________^ -line.adb:30:7: rule violation: more than one construct on the same line -30 | Tmp := I; I := I + 1; -- FLAG (2) +line.adb:51:7: rule violation: more than one construct on the same line +51 | Tmp := I; I := I + 1; -- FLAG (2) | ^^^^^^^^^ -line.adb:30:17: rule violation: more than one construct on the same line -30 | Tmp := I; I := I + 1; -- FLAG (2) +line.adb:51:17: rule violation: more than one construct on the same line +51 | Tmp := I; I := I + 1; -- FLAG (2) | ^^^^^^^^^^^ -line.adb:32:7: rule violation: more than one construct on the same line -32 | I := I + 1; end Proc; -- FLAG +line.adb:53:7: rule violation: more than one construct on the same line +53 | I := I + 1; end Proc; -- FLAG | ^^^^^^^^^^^