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/255' into 'master'
Add KP detector for eng/toolchain/gcc#210. Closes #255 See merge request eng/libadalang/langkit-query-language!205
- Loading branch information
Showing
5 changed files
with
55 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,16 @@ | ||
import stdlib | ||
|
||
@check(help="possible occurrence of KP 19159", | ||
message="possible occurrence of KP 19159", | ||
impact="23.*,24.*") | ||
fun kp_19159(node) = | ||
|" Look for a value conversion between array types directly | ||
|" passed as an actual parameter in a call to a subprogram. | ||
node is CallExpr(p_is_call(): true) when stdlib.any([ | ||
p.actual is CallExpr( | ||
p_kind(): "type_conversion", | ||
p_expression_type(): BaseTypeDecl(p_is_array_type(): true) | ||
) | ||
for p in node.p_call_params() | ||
]) | ||
|
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,30 @@ | ||
procedure Test is | ||
|
||
type Arr1 is array (1 .. 32) of Integer; | ||
|
||
type Arr2 is array (1 .. 32) of Integer; | ||
|
||
type Int is range 1 .. 100; | ||
|
||
procedure Foo (A : Arr2) is | ||
begin | ||
if A (16) /= 42 then | ||
raise Program_Error; | ||
end if; | ||
end Foo; | ||
|
||
procedure Bar (X : Integer) is | ||
begin | ||
null; | ||
end Bar; | ||
|
||
A : Arr1; | ||
B : Int := 10; | ||
C : Arr2; | ||
|
||
begin | ||
A (16) := 42; | ||
Foo (Arr2 (A)); -- FLAG | ||
Bar (Integer (B)); -- NOFLAG | ||
C := Arr2 (A); -- NOFLAG | ||
end Test; |
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:27:3: rule violation: possible occurrence of KP 19159 | ||
27 | Foo (Arr2 (A)); -- 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_19159 | ||
project: prj.gpr |