diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 373814405..58d030438 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -10357,6 +10357,7 @@ void Tokenizer::simplifyQtSignalsSlots() tok2->str(tok2->str() + ":"); tok2->deleteNext(); tok2->deleteNext(); + tok2 = tok2->previous(); } else if (Token::Match(tok2->next(), "signals|Q_SIGNALS :")) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 9dd3c5136..2d2425549 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -5646,6 +5646,24 @@ private: "}"; ASSERT_EQUALS(result2, tokenizeAndStringify(code2,false)); + + const char code3[] = "class MyObject : public QObject {" + " MyObject() {}" + " ~MyObject() {}" + " public slots:" + " signals:" + " void test() {}" + "};"; + const char result3 [] = "class MyObject : public QObject { " + "MyObject ( ) { } " + "~ MyObject ( ) { } " + "public: " + "protected: " + "void test ( ) { } " + "} ;"; + + ASSERT_EQUALS(result3, tokenizeAndStringify(code3,false)); + ASSERT_EQUALS("", errout.str()); } void sql()