From 3ad4533ea4b01c398dbceb36204b64e6d6eaf537 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:29:20 +0200 Subject: [PATCH] Fix #12536 FP uninitvar for unused reference (#6259) --- lib/astutils.cpp | 1 + test/testuninitvar.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 96ba644f3d5..7bf42b5a493 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -3305,6 +3305,7 @@ static ExprUsage getFunctionUsage(const Token* tok, int indirect, const Settings return ExprUsage::PassedByReference; } } + return ExprUsage::NotUsed; } } if (!args.empty() && indirect == 0 && !addressOf) diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 215b5167428..3ce6c654036 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -4345,6 +4345,13 @@ class TestUninitVar : public TestFixture { " a = item.a;\n" "}", "test.c"); ASSERT_EQUALS("", errout_str()); + + valueFlowUninit("void f(int& r) {}\n" // #12536 + "void g() {\n" + " int i;\n" + " f(i);\n" + "}"); + ASSERT_EQUALS("", errout_str()); } void uninitStructMember() { // struct members