Merge pull request #899 from IOBYTE/master
Fixed #8044: Crash below SymbolDatabase::setValueType
This commit is contained in:
commit
0037e9b2ec
|
@ -4743,11 +4743,14 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
|
|||
if (isconst)
|
||||
varvt.constness |= 1;
|
||||
setValueType(parent->previous(), varvt);
|
||||
const_cast<Variable *>(parent->previous()->variable())->setFlags(varvt);
|
||||
Variable *var = const_cast<Variable *>(parent->previous()->variable());
|
||||
if (var) {
|
||||
var->setFlags(varvt);
|
||||
if (vt2->typeScope && vt2->typeScope->definedType) {
|
||||
const_cast<Variable *>(parent->previous()->variable())->type(vt2->typeScope->definedType);
|
||||
var->type(vt2->typeScope->definedType);
|
||||
autoToken->type(vt2->typeScope->definedType);
|
||||
}
|
||||
}
|
||||
} else if (vt2->container) {
|
||||
// TODO: Determine exact type of RHS
|
||||
const Token *typeStart = parent->astOperand2();
|
||||
|
|
|
@ -330,6 +330,7 @@ private:
|
|||
TEST_CASE(auto6); // #7963 (segmentation fault)
|
||||
TEST_CASE(auto7);
|
||||
TEST_CASE(auto8);
|
||||
TEST_CASE(auto9); // #8044 (segmentation fault)
|
||||
}
|
||||
|
||||
void array() {
|
||||
|
@ -5159,6 +5160,31 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void auto9() { // #8044 (segmentation fault)
|
||||
GET_SYMBOL_DB("class DHTTokenTracker {\n"
|
||||
" static const size_t SECRET_SIZE = 4;\n"
|
||||
" unsigned char secret_[2][SECRET_SIZE];\n"
|
||||
" void validateToken();\n"
|
||||
"};\n"
|
||||
"template <typename T> struct DerefEqual<T> derefEqual(const T& t) {\n"
|
||||
" return DerefEqual<T>(t);\n"
|
||||
"}\n"
|
||||
"template <typename T>\n"
|
||||
"struct RefLess {\n"
|
||||
" bool operator()(const std::shared_ptr<T>& lhs,\n"
|
||||
" const std::shared_ptr<T>& rhs)\n"
|
||||
" {\n"
|
||||
" return lhs.get() < rhs.get();\n"
|
||||
" }\n"
|
||||
"};\n"
|
||||
"void DHTTokenTracker::validateToken()\n"
|
||||
"{\n"
|
||||
" for (auto& elem : secret_) {\n"
|
||||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS(true, db != nullptr); // not null
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestSymbolDatabase)
|
||||
|
|
Loading…
Reference in New Issue