parent
2bccde0e3b
commit
0636018df3
|
@ -704,7 +704,7 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
|
|||
type = Variables::referenceArray;
|
||||
else if (i->isArray())
|
||||
type = (i->dimensions().size() == 1U) ? Variables::array : Variables::pointerArray;
|
||||
else if (i->isReference())
|
||||
else if (i->isReference() && !(i->valueType() && i->valueType()->type == ValueType::UNKNOWN_TYPE && Token::simpleMatch(i->typeStartToken(), "auto")))
|
||||
type = Variables::reference;
|
||||
else if (i->nameToken()->previous()->str() == "*" && i->nameToken()->strAt(-2) == "*")
|
||||
type = Variables::pointerPointer;
|
||||
|
|
|
@ -217,6 +217,7 @@ private:
|
|||
TEST_CASE(localvarAddr); // #7477
|
||||
TEST_CASE(localvarDelete);
|
||||
TEST_CASE(localvarLambda); // #8941, #8948
|
||||
TEST_CASE(localvarStructuredBinding); // #10368
|
||||
|
||||
TEST_CASE(localvarCppInitialization);
|
||||
TEST_CASE(localvarCpp11Initialization);
|
||||
|
@ -5995,6 +5996,16 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
void localvarStructuredBinding() {
|
||||
functionVariableUsage("void f() {\n" // #10368
|
||||
" std::map<int, double> m;\n"
|
||||
" m[2] = 2.0;\n"
|
||||
" for (auto& [k, v] : m) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvarCppInitialization() {
|
||||
functionVariableUsage("void foo() {\n"
|
||||
" int buf[6];\n"
|
||||
|
|
Loading…
Reference in New Issue