Skip to content

Commit f70142f

Browse files
committed
checker: fix downward view conversions false positive
1 parent 0def05c commit f70142f

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

lkql_checker/share/lkql/downward_view_conversions.lkql

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ fun is_downward_conv(expr_type, t) =
33
|" of tagged types
44
expr_type is AdaNode
55
and t is AdaNode
6-
and t.p_full_view() is target@BaseTypeDecl
76
# Compare specific types in case one or the other is the classwide
87
# version
9-
when target.p_specific_type() != expr_type.p_specific_type()
10-
and target.p_is_derived_type(expr_type)
8+
when t.p_full_view().p_specific_type() != expr_type.p_full_view().p_specific_type()
9+
and t.p_is_derived_type(expr_type)
1110

1211
fun is_tagged(typ) =
1312
|" Whether typ is tagged or an access to a tagged type

testsuite/tests/checks/downward_view_conversions/test_downwardconv.adb

+27
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,33 @@ procedure Main is
3636
end Proc2;
3737

3838
end Foo;
39+
40+
procedure No_Flag is
41+
package P is
42+
type T is tagged private;
43+
subtype S is T;
44+
type T_Access is access all T;
45+
type T_Constant_Access is access constant T;
46+
47+
type U is new T with private;
48+
private
49+
type T is tagged null record;
50+
type U is new T with null record;
51+
end P;
52+
53+
package body P is
54+
function F (X : T_Access) return T_Constant_Access
55+
is (T_Constant_Access (X)); -- NOFLAG
56+
57+
function G (X : U) return T is (T (X)); -- NOFLAG
58+
59+
function I (X : T) return T is (T (X)); -- NOFLAG
60+
61+
function J (X : T) return S is (S (X)); -- NOFLAG
62+
end P;
63+
begin
64+
null;
65+
end No_Flag;
3966
begin
4067
null;
4168
end Main;

0 commit comments

Comments
 (0)