Skip to content

Commit c2b9350

Browse files
committed
Merge branch 'topic/kp_19749' into 'master'
Add detector for KP-19749 Closes #439 See merge request eng/libadalang/langkit-query-language!402
2 parents ca17026 + c35f9d0 commit c2b9350

25 files changed

+212
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import stdlib
2+
3+
@check(help="possible occurrence of KP 19749",
4+
message="possible occurrence of KP 19749")
5+
fun kp_19749(node) =
6+
|" Flag "Task_Dispatching_Policy", "Locking_Policy" and "Queuing_Policy"
7+
|" in units that don't contain any explicit tasking construct.
8+
node is PragmaNode
9+
when match node.f_id.text.to_lower_case
10+
| ("task_dispatching_policy" | "locking_policy" | "queuing_policy") =>
11+
(from node.unit.root select first n@AdaNode when stdlib.is_tasking_construct(n)) is null
12+
| * => false

lkql_checker/share/lkql/kp/kp.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"kp_19625": "24.*",
2424
"kp_19696": "24.*,25.1",
2525
"kp_19747": "24.*",
26+
"kp_19749": "24.*,25.*",
2627
"kp_19753": "21.*,22.*,23.*,24.*,25.*",
2728
"kp_ob03_009": "19.*",
2829
"kp_p226_024": "7.1.*,7.2.*,7.3.*,7.4.1,7.4.2,7.4.3",

lkql_checker/share/lkql/stdlib.lkql

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,37 @@ fun depends_on_mutable_discriminant(component_decl) =
695695
for v in from component_decl through parent select VariantPart].to_list
696696
])
697697

698+
fun is_tasking_construct(node) =
699+
|" Returns whether the given node is a construct related to Ada tasking,
700+
|" in other words: All constructs described in the section 9 of Ada RM.
701+
node is (
702+
TaskTypeDecl
703+
| TaskBody
704+
| SingleTaskDecl
705+
| SingleTaskTypeDecl
706+
| ProtectedTypeDecl
707+
| ProtectedBody
708+
| SingleProtectedDecl
709+
| AcceptStmt
710+
| AcceptStmtBody
711+
| RequeueStmt
712+
| SelectStmt
713+
| DelayStmt
714+
| AbortStmt
715+
| ObjectDecl(
716+
p_type_expression: TypeExpr(
717+
p_designated_type_decl(): (ProtectedTypeDecl | TaskTypeDecl)
718+
)
719+
)
720+
| Name(
721+
p_is_call: true,
722+
p_referenced_decl: d@BasicDecl when ultimate_subprogram_alias(d) is (
723+
EntryDecl
724+
| BasicSubpDecl(any parent: (ProtectedTypeDecl | ProtectedBody | SingleProtectedDecl))
725+
)
726+
)
727+
)
728+
698729
selector component_types
699730
|" Return all the ``BaseTypeDecl`` corresponding to all fields of a given
700731
|" type, including their full views, base types and subtypes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
project Prj is
2+
for Source_Dirs use ("src");
3+
end Prj;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pragma Task_Dispatching_Policy (FIFO_Within_Priorities); -- NOFLAG
2+
3+
with Task_Type; use Task_Type;
4+
5+
procedure Abort_Stmt is
6+
begin
7+
abort T_Obj;
8+
end Abort_Stmt;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pragma Task_Dispatching_Policy (FIFO_Within_Priorities); -- NOFLAG
2+
3+
procedure Delay_Stmt is
4+
begin
5+
delay Duration (0);
6+
end Delay_Stmt;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
pragma Task_Dispatching_Policy (FIFO_Within_Priorities); -- FLAG
2+
pragma Locking_Policy (Ceiling_Locking); -- FLAG
3+
pragma Queuing_Policy (FIFO_Queuing); -- FLAG
4+
pragma Discard_Names; -- NOFLAG
5+
6+
with Task_Type; use Task_Type;
7+
with Protected_Type; use Protected_Type;
8+
9+
procedure Flags is
10+
begin
11+
null;
12+
end Flags;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pragma Task_Dispatching_Policy (FIFO_Within_Priorities); -- NOFLAG
2+
3+
with Protected_Type; use Protected_Type;
4+
5+
procedure Protected_Obj_Decl is
6+
O : P;
7+
begin
8+
null;
9+
end Protected_Obj_Decl;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pragma Task_Dispatching_Policy (FIFO_Within_Priorities); -- NOFLAG
2+
3+
with Protected_Type; use Protected_Type;
4+
5+
procedure Protected_Subp_Call is
6+
begin
7+
P_Obj.Proc;
8+
end Protected_Subp_Call;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pragma Task_Dispatching_Policy (FIFO_Within_Priorities); -- NOFLAG
2+
3+
package body Protected_Type is
4+
protected body P is
5+
procedure Proc is
6+
begin
7+
null;
8+
end Proc;
9+
end P;
10+
end Protected_Type;

0 commit comments

Comments
 (0)