Fixed #7706 ((debug) Executable scope 'foo' with unknown function.)

This commit is contained in:
Robert Reif 2016-08-20 22:43:27 +02:00 committed by Daniel Marjamäki
parent 86a6723a84
commit 62ac40fc5e
3 changed files with 27 additions and 3 deletions

View File

@ -9215,10 +9215,10 @@ void Tokenizer::simplifyQtSignalsSlots()
else else
--indentlevel; --indentlevel;
} }
if (tok2->strAt(1) == "Q_OBJECT")
if (tok2->strAt(1) == "Q_OBJECT") {
tok2->deleteNext(); tok2->deleteNext();
} else if (Token::Match(tok2->next(), "public|protected|private slots|Q_SLOTS :")) {
if (Token::Match(tok2->next(), "public|protected|private slots|Q_SLOTS :")) {
tok2 = tok2->next(); tok2 = tok2->next();
tok2->str(tok2->str() + ":"); tok2->str(tok2->str() + ":");
tok2->deleteNext(2); tok2->deleteNext(2);

View File

@ -279,6 +279,7 @@ private:
TEST_CASE(findFunction8); TEST_CASE(findFunction8);
TEST_CASE(findFunction9); TEST_CASE(findFunction9);
TEST_CASE(findFunction10); // #7673 TEST_CASE(findFunction10); // #7673
TEST_CASE(findFunction11);
TEST_CASE(noexceptFunction1); TEST_CASE(noexceptFunction1);
TEST_CASE(noexceptFunction2); TEST_CASE(noexceptFunction2);
@ -3417,6 +3418,19 @@ private:
ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 2); ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 2);
} }
void findFunction11() {
GET_SYMBOL_DB("class Fred : public QObject {\n"
" Q_OBJECT\n"
"private slots:\n"
" void foo();\n"
"};\n"
"void Fred::foo() { }");
ASSERT_EQUALS("", errout.str());
const Token *f = Token::findsimplematch(tokenizer.tokens(), "foo ( ) {");
ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 4);
}
#define FUNC(x) const Function *x = findFunctionByName(#x, &db->scopeList.front()); \ #define FUNC(x) const Function *x = findFunctionByName(#x, &db->scopeList.front()); \
ASSERT_EQUALS(true, x != nullptr); \ ASSERT_EQUALS(true, x != nullptr); \
if (x) ASSERT_EQUALS(true, x->isNoExcept()); if (x) ASSERT_EQUALS(true, x->isNoExcept());

View File

@ -5625,6 +5625,16 @@ private:
ASSERT_EQUALS(result3, tokenizeAndStringify(code3,false)); ASSERT_EQUALS(result3, tokenizeAndStringify(code3,false));
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
const char code4[] = "class MyObject : public QObject {"
" Q_OBJECT "
"public slots:"
"};";
const char result4[] = "class MyObject : public QObject { "
"public: "
"} ;";
ASSERT_EQUALS(result4, tokenizeAndStringify(code4,false));
} }
void simplifySQL() { void simplifySQL() {