Fix 10738: FP knownEmptyContainer with auto reference (#3734)

* Fix 10738: FP knownEmptyContainer with auto reference

* Format
This commit is contained in:
Paul Fultz II 2022-01-21 02:56:55 -06:00 committed by GitHub
parent 6c2b1f093d
commit a7dbd288c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -5858,7 +5858,7 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
Token *autoTok = nullptr;
if (Token::Match(var1Tok->tokAt(-2), ";|{|}|(|const|constexpr auto"))
autoTok = var1Tok->previous();
else if (Token::Match(var1Tok->tokAt(-3), ";|{|}|(|const|constexpr auto *"))
else if (Token::Match(var1Tok->tokAt(-3), ";|{|}|(|const|constexpr auto *|&|&&"))
autoTok = var1Tok->tokAt(-2);
if (autoTok) {
ValueType vt(*vt2);

View File

@ -5481,6 +5481,15 @@ private:
"}\n",
true);
ASSERT_EQUALS("", errout.str());
check("void f() {\n"
" std::vector<int> v;\n"
" auto& rv = v;\n"
" rv.push_back(42);\n"
" for (auto i : v) {}\n"
"}\n",
true);
ASSERT_EQUALS("", errout.str());
}
void checkMutexes() {