diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index a26d8820b..c30f9db3d 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -320,7 +320,7 @@ bool TokenList::createTokens(std::istream &code, const std::string& file0) std::getline(code, line); - unsigned int row; + unsigned int row=0; std::istringstream fiss(line); if (fiss >> row) { // Update the current line number @@ -955,6 +955,7 @@ static Token * createAstAtToken(Token *tok, bool cpp) ; else if (Token::simpleMatch(tok->astParent(), "(") && Token::simpleMatch(tok->astParent()->astParent(), "[") && + tok->astParent()->astParent()->astOperand1() && tok == tok->astParent()->astParent()->astOperand1()->astOperand1()) ; else diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index 444286f94..cb433a683 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -130,6 +130,7 @@ private: TEST_CASE(garbageCode88); TEST_CASE(garbageCode89); TEST_CASE(garbageCode90); + TEST_CASE(garbageCode91); TEST_CASE(garbageValueFlow); TEST_CASE(garbageSymbolDatabase); @@ -712,6 +713,10 @@ private: ASSERT_THROW(checkCode("{ } { } typedef int u_array [[ ] ; typedef u_array & u_array_ref] ( ) { } u_array_ref_gbl_obj0"), InternalError); // do not crash } + void garbageCode91() { // #6791 + checkCode("typedef __attribute__((vector_size (16))) { return[ (v2df){ } ;] }"); // do not crash + } + void garbageValueFlow() { // #6089 const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"