Skip to content

Commit e1053db

Browse files
Add test for #11841 (#8621)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent 26bff2d commit e1053db

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

test/testsymboldatabase.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ class TestSymbolDatabase : public TestFixture {
430430
TEST_CASE(symboldatabase110);
431431
TEST_CASE(symboldatabase111); // [[fallthrough]]
432432
TEST_CASE(symboldatabase112); // explicit operator
433+
TEST_CASE(symboldatabase113);
433434

434435
TEST_CASE(createSymbolDatabaseFindAllScopes1);
435436
TEST_CASE(createSymbolDatabaseFindAllScopes2);
@@ -5864,6 +5865,33 @@ class TestSymbolDatabase : public TestFixture {
58645865
ASSERT(f && f->function() && f->function()->isExplicit());
58655866
}
58665867

5868+
void symboldatabase113() { // #11841
5869+
GET_SYMBOL_DB("template <typename T>\n"
5870+
"struct S {\n"
5871+
" S();\n"
5872+
" int& g() { return a; }\n"
5873+
" struct I;\n"
5874+
"private:\n"
5875+
" int a;\n"
5876+
"};\n"
5877+
"template <>\n"
5878+
"struct S<int>::I{};\n");
5879+
ASSERT(db->scopeList.size() == 4);
5880+
auto it = db->scopeList.begin();
5881+
++it;
5882+
ASSERT_EQUALS_ENUM(ScopeType::eStruct, it->type);
5883+
ASSERT_EQUALS("I", it->className);
5884+
ASSERT_EQUALS(0, it->varlist.size());
5885+
++it;
5886+
ASSERT_EQUALS_ENUM(ScopeType::eStruct, it->type);
5887+
ASSERT_EQUALS("S < int >", it->className);
5888+
ASSERT_EQUALS(1, it->varlist.size());
5889+
++it;
5890+
ASSERT_EQUALS_ENUM(ScopeType::eFunction, it->type);
5891+
ASSERT_EQUALS("g", it->className);
5892+
ASSERT_EQUALS(0, it->varlist.size());
5893+
}
5894+
58675895
void createSymbolDatabaseFindAllScopes1() {
58685896
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
58695897
ASSERT(db->scopeList.size() == 3);

0 commit comments

Comments
 (0)