Fix #8020 (ValueType: no value type for iterator + constant)
This commit is contained in:
parent
1c2339ae1d
commit
354a773bfe
|
@ -4872,6 +4872,13 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
|
|||
setValueType(parent, ValueType(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::FLOAT, 0U));
|
||||
return;
|
||||
}
|
||||
|
||||
// iterator +/- integral = iterator
|
||||
if (vt1->type == ValueType::Type::ITERATOR && vt2 && vt2->isIntegral() &&
|
||||
(parent->str() == "+" || parent->str() == "-")) {
|
||||
setValueType(parent, *vt1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (vt1->isIntegral() && vt1->pointer == 0U &&
|
||||
|
|
|
@ -347,6 +347,7 @@ private:
|
|||
TEST_CASE(auto7);
|
||||
TEST_CASE(auto8);
|
||||
TEST_CASE(auto9); // #8044 (segmentation fault)
|
||||
TEST_CASE(auto10); // #8020
|
||||
}
|
||||
|
||||
void array() {
|
||||
|
@ -5240,6 +5241,22 @@ private:
|
|||
ASSERT_EQUALS(true, db != nullptr); // not null
|
||||
}
|
||||
|
||||
void auto10() { // #8020
|
||||
GET_SYMBOL_DB("void f() {\n"
|
||||
" std::vector<int> ints(4);\n"
|
||||
" auto iter = ints.begin() + (ints.size() - 1);\n"
|
||||
"}");
|
||||
const Token *autotok = Token::findsimplematch(tokenizer.tokens(), "auto iter");
|
||||
|
||||
ASSERT(db && autotok && autotok->valueType());
|
||||
if (db && autotok && autotok->valueType()) {
|
||||
ASSERT_EQUALS(0, autotok->valueType()->constness);
|
||||
ASSERT_EQUALS(0, autotok->valueType()->pointer);
|
||||
ASSERT_EQUALS(ValueType::UNKNOWN_SIGN, autotok->valueType()->sign);
|
||||
ASSERT_EQUALS(ValueType::ITERATOR, autotok->valueType()->type);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestSymbolDatabase)
|
||||
|
|
Loading…
Reference in New Issue