Skip to content

Commit

Permalink
Merge branch 'dev/KP-18636' into 'master'
Browse files Browse the repository at this point in the history
KP detector for 18636

See merge request eng/libadalang/langkit-query-language!76
  • Loading branch information
ArnaudCharlet committed Jul 20, 2023
2 parents 6053204 + 10caabb commit 9a82b5e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lkql_checker/share/lkql/kp/KP-18636.lkql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Flag 'Image applied to objects of a class-wide interface type

@check(message="possible occurrence of KP 18636", impact="22.*,23.*")
fun kp_18636(node) =
node is AttributeRef
when node.f_attribute.p_name_is("Image")
and node.f_prefix is Name(
p_referenced_decl() is ObjectDecl or ParamSpec or GenericFormalObjDecl,
p_expression_type() is ClasswideTypeDecl(
p_is_interface_type() is true))
9 changes: 9 additions & 0 deletions testsuite/tests/checks/KP-18636/p.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package body P is

procedure Proc (Object : One'Class) is
S : constant String := Object'Image; -- FLAG
begin
null;
end Proc;

end P;
8 changes: 8 additions & 0 deletions testsuite/tests/checks/KP-18636/p.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package P is

type Root is interface;
type One is interface and Root;

procedure Proc (Object : One'Class);

end P;
2 changes: 2 additions & 0 deletions testsuite/tests/checks/KP-18636/prj.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project Prj is
end Prj;
4 changes: 4 additions & 0 deletions testsuite/tests/checks/KP-18636/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
p.adb:4:30: rule violation: possible occurrence of KP 18636
4 | S : constant String := Object'Image; -- FLAG
| ^^^^^^^^^^^^

3 changes: 3 additions & 0 deletions testsuite/tests/checks/KP-18636/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
driver: 'checker'
rule_name: KP_18636
project: 'prj.gpr'

0 comments on commit 9a82b5e

Please sign in to comment.