From 36d12d7866a10bb20300b6ba499b831f1f7f6421 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Mon, 28 Nov 2016 17:21:46 +0100 Subject: [PATCH] SymbolDatabase: Function::retDef should not point at "static" or "extern" --- lib/symboldatabase.cpp | 2 +- test/testsymboldatabase.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index e13239c00..d7e26e2b0 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1899,7 +1899,7 @@ Function* SymbolDatabase::addGlobalFunctionDecl(Scope*& scope, const Token *tok, tok1 = tok1->previous(); // find the return type - while (tok1 && Token::Match(tok1->next(), "static|extern|const")) { + while (Token::Match(tok1, "static|extern|const")) { if (tok1->str() == "static") function.isStaticLocal(true); else if (tok1->str() == "extern") diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 570c88ca8..149997db2 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -1350,22 +1350,22 @@ private: if (db) { const Token *f = Token::findsimplematch(tokenizer.tokens(), "f1"); - ASSERT(f && f->function() && f->function()->isStaticLocal()); + ASSERT(f && f->function() && f->function()->isStaticLocal() && f->function()->retDef->str() == "void"); f = Token::findsimplematch(tokenizer.tokens(), "f2"); - ASSERT(f && f->function() && !f->function()->isStaticLocal()); + ASSERT(f && f->function() && !f->function()->isStaticLocal() && f->function()->retDef->str() == "void"); f = Token::findsimplematch(tokenizer.tokens(), "f3"); - ASSERT(f && f->function() && f->function()->isExtern()); + ASSERT(f && f->function() && f->function()->isExtern() && f->function()->retDef->str() == "void"); f = Token::findsimplematch(tokenizer.tokens(), "f4"); - ASSERT(f && f->function() && !f->function()->isExtern()); + ASSERT(f && f->function() && !f->function()->isExtern() && f->function()->retDef->str() == "void"); f = Token::findsimplematch(tokenizer.tokens(), "f5"); - ASSERT(f && f->function() && f->function()->isExtern()); + ASSERT(f && f->function() && f->function()->isExtern() && f->function()->retDef->str() == "void"); f = Token::findsimplematch(tokenizer.tokens(), "f6"); - ASSERT(f && f->function() && !f->function()->isExtern()); + ASSERT(f && f->function() && !f->function()->isExtern() && f->function()->retDef->str() == "void"); } }