Skip to content

Commit

Permalink
Fix erroneous warning on enum struct parameters.
Browse files Browse the repository at this point in the history
Bug: issue #991
Test: new test case
  • Loading branch information
dvander committed Nov 29, 2024
1 parent 35e55c8 commit ebe6a5b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/semantics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,9 @@ bool Semantics::CheckBinaryExpr(BinaryExpr* expr) {

// If it's an outparam, also mark it as read.
if (sym->vclass() == sARGUMENT &&
(sym->type()->isReference() || sym->type()->isArray()))
(sym->type()->isReference() ||
sym->type()->isArray() ||
sym->type()->isEnumStruct()))
{
markusage(sym, uREAD);
}
Expand Down
18 changes: 18 additions & 0 deletions tests/compile-only/ok-enum-struct-param-implicit-read.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// warnings_are_errors: true

enum struct Foo
{
int value;
}

void FunctionWithStructParam(Foo param) // warning 204: symbol is assigned a value that is never used: "param"
{
Foo bar;
bar.value = 1;
param = bar;
}

public main() {
Foo foo;
FunctionWithStructParam(foo);
}

0 comments on commit ebe6a5b

Please sign in to comment.