Fix issue 8993: False positive duplicateCondition related to auto (#1831)
This commit is contained in:
parent
dc0e8c214e
commit
195da2b3d2
|
@ -4925,6 +4925,8 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
|
||||||
vt2_.pointer = 1;
|
vt2_.pointer = 1;
|
||||||
if ((vt.constness & (1 << vt2->pointer)) != 0)
|
if ((vt.constness & (1 << vt2->pointer)) != 0)
|
||||||
vt2_.constness |= (1 << vt2->pointer);
|
vt2_.constness |= (1 << vt2->pointer);
|
||||||
|
if (!Token::Match(autoTok->tokAt(1), "*|&"))
|
||||||
|
vt2_.constness = vt.constness;
|
||||||
var->setValueType(vt2_);
|
var->setValueType(vt2_);
|
||||||
if (vt2->typeScope && vt2->typeScope->definedType) {
|
if (vt2->typeScope && vt2->typeScope->definedType) {
|
||||||
var->type(vt2->typeScope->definedType);
|
var->type(vt2->typeScope->definedType);
|
||||||
|
|
|
@ -2978,6 +2978,14 @@ private:
|
||||||
" if (b) {}\n"
|
" if (b) {}\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void checkInvalidTestForOverflow() {
|
||||||
|
|
Loading…
Reference in New Issue