From 185e56ded1ca512821d9a33999f8aecd93734d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Tue, 14 Jan 2025 12:40:05 +0100 Subject: [PATCH 1/2] add test --- test/testsymboldatabase.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index f5a774ee821..42eee80787b 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -424,6 +424,7 @@ class TestSymbolDatabase : public TestFixture { TEST_CASE(symboldatabase106); TEST_CASE(symboldatabase107); TEST_CASE(symboldatabase108); + TEST_CASE(symboldatabase109); // #13553 TEST_CASE(createSymbolDatabaseFindAllScopes1); TEST_CASE(createSymbolDatabaseFindAllScopes2); @@ -5710,6 +5711,18 @@ class TestSymbolDatabase : public TestFixture { } } + void symboldatabase109() { // #13553 + GET_SYMBOL_DB("extern \"C\" {\n" + "class Base {\n" + "public:\n" + " virtual void show(void) = 0;\n" + "};\n" + "}\n"); + const Token *f = db ? Token::findsimplematch(tokenizer.tokens(), "show") : nullptr; + ASSERT(f != nullptr); + ASSERT(f && f->function() && f->function()->hasVirtualSpecifier()); + } + void createSymbolDatabaseFindAllScopes1() { GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }"); ASSERT(db->scopeList.size() == 3); From 5c6e8d57bf54a572658bffc0ff2f0bf1d24f7725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Tue, 14 Jan 2025 12:40:15 +0100 Subject: [PATCH 2/2] fix #13553 --- lib/symboldatabase.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 2ad9d487599..6488f1aeeee 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -2639,6 +2639,9 @@ const Token *Function::setFlags(const Token *tok1, const Scope *scope) if (tok1->isInline()) isInlineKeyword(true); + if (tok1->isExternC()) + isExtern(true); + // look for end of previous statement while (tok1->previous() && !Token::Match(tok1->previous(), ";|}|{|public:|protected:|private:")) { tok1 = tok1->previous(); @@ -2647,7 +2650,7 @@ const Token *Function::setFlags(const Token *tok1, const Scope *scope) isInlineKeyword(true); // extern function - if (tok1->isExternC() || tok1->str() == "extern") { + if (tok1->str() == "extern") { isExtern(true); }