Don't insert union into template argument list, add test

This commit is contained in:
chrchr 2022-03-14 15:03:28 +01:00
parent fdc7577c32
commit 03c3674094
2 changed files with 18 additions and 12 deletions

View File

@ -1371,7 +1371,7 @@ void Tokenizer::simplifyTypedef()
structRemoved = true; structRemoved = true;
typeStart = typeStart->next(); typeStart = typeStart->next();
} }
if (Token::Match(typeStart, "struct|class") && Token::Match(tok2, "%name% ::")) if (Token::Match(typeStart, "struct|class|union") && Token::Match(tok2, "%name% ::"))
typeStart = typeStart->next(); typeStart = typeStart->next();
if (sameStartEnd) if (sameStartEnd)

View File

@ -4860,17 +4860,23 @@ private:
} }
void symboldatabase98() { // #10451 void symboldatabase98() { // #10451
GET_SYMBOL_DB("struct A { typedef struct {} B; };\n" {
"void f() {\n" GET_SYMBOL_DB("struct A { typedef struct {} B; };\n"
" auto g = [](A::B b) -> void { A::B b2 = b; };\n" } "void f() {\n"
"};\n"); " auto g = [](A::B b) -> void { A::B b2 = b; };\n"
ASSERT(db); "};\n");
ASSERT_EQUALS(3, db->scopeList.size()); ASSERT(db);
ASSERT_EQUALS(5, db->scopeList.size());
const Token *functok = Token::findmatch(tokenizer.tokens(), "%name% ("); }
ASSERT(functok); {
ASSERT(functok->function()); GET_SYMBOL_DB("typedef union {\n"
ASSERT_EQUALS(functok->function()->type, Function::Type::eConstructor); " int i;\n"
"} U;\n"
"template <auto U::*>\n"
"void f();\n");
ASSERT(db);
ASSERT_EQUALS(2, db->scopeList.size());
}
} }
void createSymbolDatabaseFindAllScopes1() { void createSymbolDatabaseFindAllScopes1() {