Skip to content

Commit

Permalink
Fix for alliedmodders#972 when a static is used by a stock Function
Browse files Browse the repository at this point in the history
This adds stock functions to the maybe used set which seems most appropriate.

We can then mark all of the functions they refer too as maybe used also.
  • Loading branch information
c0rp3n committed Jun 9, 2024
1 parent 2213b8e commit e99733c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/semantics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2876,6 +2876,10 @@ bool Semantics::CheckFunctionDeclImpl(FunctionDecl* info) {
if (info->as<MemberFunctionDecl>())
maybe_used_.emplace_back(info);

// We never warn about unused stock functions.
if (info->is_stock())
maybe_used_.emplace_back(info);

auto fwd = info->prototype();
if (fwd && fwd->deprecate() && !info->is_stock())
report(info->pos(), 234) << info->name() << fwd->deprecate();
Expand Down
7 changes: 7 additions & 0 deletions tests/compile-only/ok-static-used-by-stock.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
static void SomeHelperFunction()
{}

stock void HelpMe()
{
SomeHelperFunction();
}
5 changes: 5 additions & 0 deletions tests/compile-only/ok-static-used-by-stock.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// warnings_are_errors: true
#include "ok-static-used-by-stock.inc"

public void main()
{}

0 comments on commit e99733c

Please sign in to comment.