Skip to content

Commit

Permalink
Merge branch 'topic/dw_conv_doc' into 'master'
Browse files Browse the repository at this point in the history
Document change to Downward_View_Conversions rule

See merge request eng/libadalang/langkit-query-language!159
  • Loading branch information
raph-amiard committed Jan 2, 2024
2 parents 3eb7d09 + 7f7a56f commit fa23099
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lkql_checker/doc/gnatcheck_rm/predefined_rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ Flag downward view conversions.

This rule has no parameters.

This rule will also flag downward view conversions done through access types.

.. rubric:: Example

.. code-block:: ada
Expand All @@ -303,9 +305,11 @@ This rule has no parameters.
package body Foo is
procedure Proc1 (X : in out T1'Class) is
Var : T2 := T2 (X); -- FLAG
Var : T2 := T2 (X); -- FLAG
X_Acc : T1_Access := X'Unrestricted_Access;
Var_2 : T2_Access := T2_Access (X_Acc); -- FLAG
begin
Proc2 (T2'Class (X)); -- FLAG
Proc2 (T2'Class (X)); -- FLAG
end Proc1;
procedure Proc2 (X : in out T2'Class) is
Expand Down
1 change: 1 addition & 0 deletions lkql_checker/share/lkql/downward_view_conversions.lkql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Flag downward view conversions.
# This rule will also flag downward view conversions done through access types.

fun is_downward_conv(expr_type, t) =
|" Whether converting from `expr_type` to `t` is a downward view conversion
Expand Down

0 comments on commit fa23099

Please sign in to comment.