Skip to content

Commit e255ee3

Browse files
committed
Merge branch 'topic/fix_deeply_inlining' into 'master'
Fix the "Deeply_Nested_Inlining" rule Closes #407 See merge request eng/libadalang/langkit-query-language!348
2 parents f29d587 + 1dfc18b commit e255ee3

File tree

5 files changed

+32
-12
lines changed

5 files changed

+32
-12
lines changed

lkql_checker/share/lkql/deeply_nested_inlining.lkql

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ fun inlined_body(name) = match name.p_referenced_decl()
77
| b@BaseSubpBody when b?.p_has_aspect("Inline")
88
=> b
99
| EnumLiteralDecl => null
10-
| GenericSubpInstantiation(f_generic_subp_name: *(
11-
p_referenced_decl(): b@GenericSubpDecl(
12-
p_has_aspect("Inline"): true)))
13-
=> b?.p_body_part()
14-
| d@BasicDecl when d?.p_is_subprogram() and d?.p_has_aspect("Inline")
15-
=> d?.p_body_part()
10+
| g@GenericSubpInstantiation(f_generic_subp_name: *(p_referenced_decl(): b@GenericSubpDecl))
11+
when b.p_has_aspect("Inline") or g.p_has_aspect("Inline")
12+
=> b.p_body_part()
13+
| d@BasicDecl when d.p_is_subprogram() and d.p_has_aspect("Inline")
14+
=> d.p_body_part()
1615
| * => null
1716

1817
# Return true if we reach a level ``n`` of inlining of 0

testsuite/tests/checks/deeply_nested_inlining/deeply_inlined_2012.adb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@ package body Deeply_Inlined_2012 is
3535
New_P4;
3636
end P5;
3737

38+
procedure Free (Elem : in out T) is
39+
begin
40+
Free (Elem.C);
41+
end Free;
42+
3843
end Deeply_Inlined_2012;

testsuite/tests/checks/deeply_nested_inlining/deeply_inlined_2012.ads

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
with Ada.Unchecked_Deallocation;
2+
13
package Deeply_Inlined_2012 is
24

35
generic
@@ -18,4 +20,20 @@ package Deeply_Inlined_2012 is
1820
generic
1921
procedure P5 with Inline; -- FLAG
2022

23+
type T is private;
24+
25+
procedure Free (Elem : in out T); -- NOFLAG
26+
27+
private
28+
type U is null record;
29+
type U_Access is access U;
30+
31+
procedure Free is new Ada.Unchecked_Deallocation -- NOFLAG
32+
(U, U_Access);
33+
34+
type T is record
35+
C : U_Access;
36+
end record;
37+
38+
pragma Inline (Free);
2139
end Deeply_Inlined_2012;

testsuite/tests/checks/deeply_nested_inlining/inlined.ads

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
package Inlined is
2-
32
procedure P0; -- NOFLAG
43
pragma Inline (P0);
54

@@ -17,5 +16,4 @@ package Inlined is
1716

1817
function F2 return Boolean; -- NOFLAG
1918
pragma Inline (F2);
20-
2119
end Inlined;

testsuite/tests/checks/deeply_nested_inlining/test.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ deeply_inlined_2012.adb:32:14: rule violation: deeply nested inlining
3838
32 | procedure New_P4 is new P4; -- FLAG
3939
| ^^^^^^
4040

41-
deeply_inlined_2012.ads:16:14: rule violation: deeply nested inlining
42-
16 | procedure P4 with Inline; -- FLAG
41+
deeply_inlined_2012.ads:18:14: rule violation: deeply nested inlining
42+
18 | procedure P4 with Inline; -- FLAG
4343
| ^^
4444

45-
deeply_inlined_2012.ads:19:14: rule violation: deeply nested inlining
46-
19 | procedure P5 with Inline; -- FLAG
45+
deeply_inlined_2012.ads:21:14: rule violation: deeply nested inlining
46+
21 | procedure P5 with Inline; -- FLAG
4747
| ^^
4848

0 commit comments

Comments
 (0)