Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'topic/257' into 'master'
Add KP detector for eng/toolchain/gnat#693. Closes #257 See merge request eng/libadalang/langkit-query-language!210
- Loading branch information
Showing
5 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@check(help="possible occurrence of KP 19038", | ||
message="possible occurrence of KP 19038", | ||
impact="24.1") | ||
fun kp_19038(node) = | ||
|" Detect all occurrences of aspect "Exclusive_Functions". | ||
node is AspectAssoc( | ||
f_id: Name(p_name_is("exclusive_functions"): true) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
project Prj is | ||
end Prj; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
with Ada.Text_IO; | ||
|
||
procedure Excl1 is | ||
protected type PT with Exclusive_Functions is -- FLAG | ||
function Unlock return Boolean; | ||
procedure Unlock; | ||
entry E; | ||
end PT; | ||
|
||
Locked : Boolean := True; | ||
|
||
protected body PT is | ||
function Unlock return Boolean is | ||
Previous : constant Boolean := Locked; | ||
begin | ||
Locked := False; | ||
return Previous; | ||
end; | ||
|
||
procedure Unlock is | ||
begin | ||
Locked := False; | ||
end; | ||
|
||
entry E when not Locked is | ||
begin | ||
Locked := True; | ||
end; | ||
end; | ||
|
||
PO : PT; | ||
|
||
task T; | ||
|
||
task body T is | ||
Unused : Boolean; | ||
begin | ||
delay 1.0; | ||
PO.Unlock; | ||
delay 1.0; | ||
Unused := PO.Unlock; | ||
end; | ||
|
||
begin | ||
select | ||
PO.E; | ||
Ada.Text_IO.Put_Line ("Entry call succeeded"); | ||
or | ||
delay 2.0; | ||
Ada.Text_IO.Put_Line ("Entry call timed out"); | ||
end select; | ||
|
||
select | ||
PO.E; | ||
Ada.Text_IO.Put_Line ("Entry call succeeded"); | ||
or | ||
delay 2.0; | ||
Ada.Text_IO.Put_Line ("Entry call timed out"); | ||
end select; | ||
end; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
test.adb:4:27: rule violation: possible occurrence of KP 19038 | ||
4 | protected type PT with Exclusive_Functions is -- FLAG | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
driver: checker | ||
rule_name: KP_19038 | ||
project: prj.gpr |