Fix spurious variable declaration with unknown macro and using (#4698)
This commit is contained in:
parent
25a6146ffa
commit
0b62c73ff0
|
@ -6406,7 +6406,7 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, co
|
|||
varName = varName->next();
|
||||
else
|
||||
--typelen;
|
||||
if (isCPP() && Token::Match(varName, "public:|private:|protected:"))
|
||||
if (isCPP() && Token::Match(varName, "public:|private:|protected:|using"))
|
||||
continue;
|
||||
//skip all the pointer part
|
||||
bool isPointerOrRef = false;
|
||||
|
|
|
@ -1990,18 +1990,28 @@ private:
|
|||
}
|
||||
|
||||
void varid_in_class24() {
|
||||
const char code[] = "class A {\n"
|
||||
" Q_OBJECT\n"
|
||||
"public:\n"
|
||||
" using QPtr = QPointer<A>;\n"
|
||||
"};\n";
|
||||
const char *code{}, *expected{};
|
||||
|
||||
const char expected[] = "1: class A {\n"
|
||||
"2: Q_OBJECT\n"
|
||||
"3: public:\n"
|
||||
"4:\n"
|
||||
"5: } ;\n";
|
||||
code = "class A {\n"
|
||||
" Q_OBJECT\n"
|
||||
"public:\n"
|
||||
" using QPtr = QPointer<A>;\n"
|
||||
"};\n";
|
||||
expected = "1: class A {\n"
|
||||
"2: Q_OBJECT\n"
|
||||
"3: public:\n"
|
||||
"4:\n"
|
||||
"5: } ;\n";
|
||||
ASSERT_EQUALS(expected, tokenize(code, "test.cpp"));
|
||||
|
||||
code = "class A {\n"
|
||||
" Q_OBJECT\n"
|
||||
" using QPtr = QPointer<A>;\n"
|
||||
"};\n";
|
||||
expected = "1: class A {\n"
|
||||
"2: Q_OBJECT\n"
|
||||
"3:\n"
|
||||
"4: } ;\n";
|
||||
ASSERT_EQUALS(expected, tokenize(code, "test.cpp"));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue