@@ -5262,7 +5262,7 @@ class TestSymbolDatabase : public TestFixture {
52625262
52635263 void createSymbolDatabaseFindAllScopes5 ()
52645264 {
5265- GET_SYMBOL_DB (" class C {\n "
5265+ GET_SYMBOL_DB (" class C {\n " // #11444
52665266 " public:\n "
52675267 " template<typename T>\n "
52685268 " class D;\n "
@@ -5282,7 +5282,12 @@ class TestSymbolDatabase : public TestFixture {
52825282 ASSERT (db);
52835283 ASSERT_EQUALS (6 , db->scopeList .size ());
52845284 const Token* const var = Token::findsimplematch (tokenizer.tokens (), " IN (" );
5285- TODO_ASSERT (var && var->variable ());
5285+ ASSERT (var && var->variable ());
5286+ ASSERT_EQUALS (var->variable ()->name (), " IN" );
5287+ auto it = db->scopeList .begin ();
5288+ std::advance (it, 4 );
5289+ ASSERT_EQUALS (it->className , " S" );
5290+ ASSERT_EQUALS (var->variable ()->scope (), &*it);
52865291 }
52875292
52885293 void createSymbolDatabaseFindAllScopes6 ()
@@ -7686,23 +7691,35 @@ class TestSymbolDatabase : public TestFixture {
76867691 }
76877692
76887693 void executableScopeWithUnknownFunction () {
7689- GET_SYMBOL_DB (" class Fred {\n "
7690- " void foo(const std::string & a = \"\" );\n "
7691- " };\n "
7692- " Fred::foo(const std::string & b) { }" );
7694+ {
7695+ GET_SYMBOL_DB (" class Fred {\n "
7696+ " void foo(const std::string & a = \"\" );\n "
7697+ " };\n "
7698+ " Fred::foo(const std::string & b) { }" );
76937699
7694- ASSERT (db && db->scopeList .size () == 3 );
7695- std::list<Scope>::const_iterator scope = db->scopeList .cbegin ();
7696- ASSERT_EQUALS (Scope::eGlobal, scope->type );
7697- ++scope;
7698- ASSERT_EQUALS (Scope::eClass, scope->type );
7699- const Scope * class_scope = &*scope;
7700- ++scope;
7701- ASSERT (class_scope->functionList .size () == 1 );
7702- ASSERT (class_scope->functionList .cbegin ()->hasBody ());
7703- ASSERT (class_scope->functionList .cbegin ()->functionScope == &*scope);
7704- }
7700+ ASSERT (db && db->scopeList .size () == 3 );
7701+ std::list<Scope>::const_iterator scope = db->scopeList .cbegin ();
7702+ ASSERT_EQUALS (Scope::eGlobal, scope->type );
7703+ ++scope;
7704+ ASSERT_EQUALS (Scope::eClass, scope->type );
7705+ const Scope* class_scope = &*scope;
7706+ ++scope;
7707+ ASSERT (class_scope->functionList .size () == 1 );
7708+ ASSERT (class_scope->functionList .cbegin ()->hasBody ());
7709+ ASSERT (class_scope->functionList .cbegin ()->functionScope == &*scope);
7710+ }
7711+ {
7712+ GET_SYMBOL_DB (" bool f(bool (*g)(int));\n "
7713+ " bool f(bool (*g)(int)) { return g(0); }\n " );
77057714
7715+ ASSERT (db && db->scopeList .size () == 2 );
7716+ std::list<Scope>::const_iterator scope = db->scopeList .cbegin ();
7717+ ASSERT_EQUALS (Scope::eGlobal, scope->type );
7718+ ASSERT (scope->functionList .size () == 1 );
7719+ ++scope;
7720+ ASSERT_EQUALS (Scope::eFunction, scope->type );
7721+ }
7722+ }
77067723#define typeOf (...) typeOf_(__FILE__, __LINE__, __VA_ARGS__)
77077724 std::string typeOf_ (const char * file, int line, const char code[], const char pattern[], const char filename[] = " test.cpp" , const Settings *settings = nullptr ) {
77087725 Tokenizer tokenizer (settings ? settings : &settings2, this );
@@ -8375,6 +8392,15 @@ class TestSymbolDatabase : public TestFixture {
83758392 ASSERT (tok->variable () && tok->variable ()->valueType ());
83768393 ASSERT_EQUALS (" signed int * const &" , tok->variable ()->valueType ()->str ());
83778394 }
8395+ {
8396+ GET_SYMBOL_DB (" auto a = 1;\n " );
8397+ ASSERT_EQUALS (" " , errout.str ());
8398+
8399+ const Token* tok = tokenizer.tokens ();
8400+ tok = Token::findsimplematch (tok, " auto" );
8401+ ASSERT (tok && tok->valueType ());
8402+ ASSERT_EQUALS (" signed int" , tok->valueType ()->str ());
8403+ }
83788404 }
83798405
83808406 void valueTypeThis () {
0 commit comments