Fix symbol database crash on template type aliases by ignoring them. (#1045)

This commit is contained in:
IOBYTE 2018-01-21 15:22:26 -05:00 committed by amai2012
parent 351b382a7b
commit 3159d151d3
2 changed files with 14 additions and 2 deletions

View File

@ -278,7 +278,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
// using type alias // using type alias
else if (_tokenizer->isCPP() && Token::Match(tok, "using %name% =")) { else if (_tokenizer->isCPP() && Token::Match(tok, "using %name% =")) {
if (!findType(tok->next(), scope)) { if (tok->strAt(-1) != ">" && !findType(tok->next(), scope)) {
// fill typeList.. // fill typeList..
typeList.push_back(Type(tok, nullptr, scope)); typeList.push_back(Type(tok, nullptr, scope));
Type* new_type = &typeList.back(); Type* new_type = &typeList.back();

View File

@ -351,7 +351,8 @@ private:
TEST_CASE(unionWithConstructor); TEST_CASE(unionWithConstructor);
TEST_CASE(using1); TEST_CASE(using1);
TEST_CASE(using2); // #8331 TEST_CASE(using2); // #8331 (segmentation fault)
TEST_CASE(using3); // #8343 (segmentation fault)
} }
void array() { void array() {
@ -5390,6 +5391,17 @@ private:
settings1.standards.cpp = original_std; settings1.standards.cpp = original_std;
} }
void using3() { // #8343 (segmentation fault)
Standards::cppstd_t original_std = settings1.standards.cpp;
settings1.standards.cpp = Standards::CPP11;
GET_SYMBOL_DB("template <typename T>\n"
"using vector = typename MemoryModel::template vector<T>;\n"
"vector<uninitialized_uint64> m_bits;");
settings1.standards.cpp = original_std;
ASSERT(db);
ASSERT_EQUALS("", errout.str());
}
}; };
REGISTER_TEST(TestSymbolDatabase) REGISTER_TEST(TestSymbolDatabase)