Fix syntaxError on lambda inside decltype (#4650)
Use case where it gave an issue: using customComparator = decltype([] (const X& lhs, const X& rhs) { return lhs.CompareTo(rhs); }); std::map<X, int, costomComparator> m; Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
This commit is contained in:
parent
7799f820a3
commit
63e30d1b8c
|
@ -387,9 +387,13 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
|
|
||||||
tok = tok->tokAt(3);
|
tok = tok->tokAt(3);
|
||||||
|
|
||||||
while (tok && tok->str() != ";")
|
while (tok && tok->str() != ";") {
|
||||||
|
if (Token::simpleMatch(tok, "decltype ("))
|
||||||
|
tok = tok->linkAt(1);
|
||||||
|
else
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// unnamed struct and union
|
// unnamed struct and union
|
||||||
else if (tok->isKeyword() && Token::Match(tok, "struct|union {") &&
|
else if (tok->isKeyword() && Token::Match(tok, "struct|union {") &&
|
||||||
|
|
|
@ -122,10 +122,14 @@ public:
|
||||||
else if (classDef_ && classDef_->str() == "using") {
|
else if (classDef_ && classDef_->str() == "using") {
|
||||||
typeStart = classDef->tokAt(3);
|
typeStart = classDef->tokAt(3);
|
||||||
typeEnd = typeStart;
|
typeEnd = typeStart;
|
||||||
while (typeEnd->next() && typeEnd->next()->str() != ";")
|
while (typeEnd->next() && typeEnd->next()->str() != ";") {
|
||||||
|
if (Token::simpleMatch(typeEnd, "decltype ("))
|
||||||
|
typeEnd = typeEnd->linkAt(1);
|
||||||
|
else
|
||||||
typeEnd = typeEnd->next();
|
typeEnd = typeEnd->next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& name() const;
|
const std::string& name() const;
|
||||||
|
|
||||||
|
|
|
@ -366,6 +366,7 @@ private:
|
||||||
TEST_CASE(symboldatabase100); // #10174
|
TEST_CASE(symboldatabase100); // #10174
|
||||||
TEST_CASE(symboldatabase101);
|
TEST_CASE(symboldatabase101);
|
||||||
TEST_CASE(symboldatabase102);
|
TEST_CASE(symboldatabase102);
|
||||||
|
TEST_CASE(symboldatabase103);
|
||||||
|
|
||||||
TEST_CASE(createSymbolDatabaseFindAllScopes1);
|
TEST_CASE(createSymbolDatabaseFindAllScopes1);
|
||||||
TEST_CASE(createSymbolDatabaseFindAllScopes2);
|
TEST_CASE(createSymbolDatabaseFindAllScopes2);
|
||||||
|
@ -5060,6 +5061,15 @@ private:
|
||||||
ASSERT(db->scopeList.back().className == "g");
|
ASSERT(db->scopeList.back().className == "g");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void symboldatabase103() {
|
||||||
|
GET_SYMBOL_DB("void f() {\n"
|
||||||
|
"using lambda = decltype([]() { return true; });\n"
|
||||||
|
"lambda{}();\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT(db != nullptr);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void createSymbolDatabaseFindAllScopes1() {
|
void createSymbolDatabaseFindAllScopes1() {
|
||||||
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
|
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
|
||||||
ASSERT(db->scopeList.size() == 3);
|
ASSERT(db->scopeList.size() == 3);
|
||||||
|
|
Loading…
Reference in New Issue