Skip to content

Commit

Permalink
Merge pull request #9354 from erlang/revert-9323-isabell/inline-nifs
Browse files Browse the repository at this point in the history
Revert "stdlib: Add warning for inlined nifs without loading"
  • Loading branch information
lucioleKi authored Jan 28, 2025
2 parents c8226a1 + 4ae5ec8 commit 1b2af94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 32 deletions.
11 changes: 5 additions & 6 deletions lib/stdlib/src/erl_lint.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4619,20 +4619,19 @@ check_remote_function(Anno, M, F, As, St0) ->
%% been enabled.
check_load_nif(Anno, erlang, load_nif, [_, _], St0) ->
St = St0#lint{load_nif = true},
check_nif_inline(Anno, St);
check_load_nif(Anno, erlang, nif_error, _, St) ->
check_nif_inline(Anno, St);
case is_warn_enabled(nif_inline, St) of
true -> check_nif_inline(Anno, St);
false -> St
end;
check_load_nif(_Anno, _ModName, _FuncName, _Args, St) ->
St.

check_nif_inline(Anno, St) ->
case is_warn_enabled(nif_inline, St) andalso
any(fun is_inline_opt/1, St#lint.compile) of
case any(fun is_inline_opt/1, St#lint.compile) of
true -> add_warning(Anno, nif_inline, St);
false -> St
end.

is_inline_opt({inline, {_F,_A}}) -> true;
is_inline_opt({inline, [_|_]=_FAs}) -> true;
is_inline_opt(inline) -> true;
is_inline_opt(_) -> false.
Expand Down
27 changes: 1 addition & 26 deletions lib/stdlib/test/erl_lint_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4977,32 +4977,7 @@ inline_nifs(Config) ->
gurka() -> ok.
">>,
[],
{warnings,[{{2,22},erl_lint,nif_inline}]}},
{explicit_inline_unloaded_1,
<<"-compile({inline, [bar/0]}).
-nifs([bar/0]).
bar() -> erlang:nif_error(error).
">>,
[],
{warnings,[{{2,16},erl_lint,no_load_nif},
{{3,24},erl_lint,nif_inline}]}},
{explicit_inline_unloaded_2,
<<"-compile({inline, bar/0}).
-nifs([bar/0]).
bar() -> erlang:nif_error(error).
">>,
[],
{warnings,[{{2,16},erl_lint,no_load_nif},
{{3,24},erl_lint,nif_inline}]}},
{implicit_inline_unloaded,
<<"-compile(inline).
-nifs([bar/0]).
bar() -> erlang:nif_error(error).
gurka() -> ok.
">>,
[],
{warnings,[{{2,16},erl_lint,no_load_nif},
{{3,24},erl_lint,nif_inline}]}}],
{warnings,[{{2,22},erl_lint,nif_inline}]}}],
[] = run(Config, Ts).

undefined_nifs(Config) when is_list(Config) ->
Expand Down

0 comments on commit 1b2af94

Please sign in to comment.