Fix issue 8993: False positive duplicateCondition related to auto (#1831)

This commit is contained in:
Paul Fultz II 2019-05-14 01:57:36 -05:00 committed by Daniel Marjamäki
parent dc0e8c214e
commit 195da2b3d2
2 changed files with 10 additions and 0 deletions

View File

@ -4925,6 +4925,8 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
vt2_.pointer = 1;
if ((vt.constness & (1 << vt2->pointer)) != 0)
vt2_.constness |= (1 << vt2->pointer);
if (!Token::Match(autoTok->tokAt(1), "*|&"))
vt2_.constness = vt.constness;
var->setValueType(vt2_);
if (vt2->typeScope && vt2->typeScope->definedType) {
var->type(vt2->typeScope->definedType);

View File

@ -2978,6 +2978,14 @@ private:
" if (b) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// #8993
check("void f(const std::string& x) {\n"
" auto y = x;\n"
" if (x.empty()) y = \"1\";\n"
" if (y.empty()) return;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void checkInvalidTestForOverflow() {