diff --git a/lib/fwdanalysis.cpp b/lib/fwdanalysis.cpp index 9a151920b..83a1b511d 100644 --- a/lib/fwdanalysis.cpp +++ b/lib/fwdanalysis.cpp @@ -501,8 +501,6 @@ bool FwdAnalysis::possiblyAliased(const Token *expr, const Token *startToken) co const bool pure = false; const bool followVar = false; for (const Token *tok = startToken; tok; tok = tok->previous()) { - if (tok->str() == "{" && tok->scope()->type == Scope::eFunction && !(tok->astParent() && tok->astParent()->str() == ",")) - break; if (Token::Match(tok, "%name% (") && !Token::Match(tok, "if|while|for")) { // Is argument passed by reference? diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index bc2093958..0e616b01d 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -161,6 +161,7 @@ private: TEST_CASE(localvaralias18); // ticket #9234 - iterator TEST_CASE(localvaralias19); // ticket #9828 TEST_CASE(localvaralias20); // ticket #10966 + TEST_CASE(localvaralias21); TEST_CASE(localvarasm); TEST_CASE(localvarstatic); TEST_CASE(localvarextern); @@ -4926,6 +4927,18 @@ private: errout.str()); } + void localvaralias21() { // #11728 + functionVariableUsage("void f(int i) {\n" + " bool b = true;\n" + " bool* p = &b;\n" + " int j{};\n" + " if (i)\n" + " b = false;\n" + " if (*p) {}\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + void localvarasm() { functionVariableUsage("void foo(int &b)\n"