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();
|
varName = varName->next();
|
||||||
else
|
else
|
||||||
--typelen;
|
--typelen;
|
||||||
if (isCPP() && Token::Match(varName, "public:|private:|protected:"))
|
if (isCPP() && Token::Match(varName, "public:|private:|protected:|using"))
|
||||||
continue;
|
continue;
|
||||||
//skip all the pointer part
|
//skip all the pointer part
|
||||||
bool isPointerOrRef = false;
|
bool isPointerOrRef = false;
|
||||||
|
|
|
@ -1990,18 +1990,28 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void varid_in_class24() {
|
void varid_in_class24() {
|
||||||
const char code[] = "class A {\n"
|
const char *code{}, *expected{};
|
||||||
|
|
||||||
|
code = "class A {\n"
|
||||||
" Q_OBJECT\n"
|
" Q_OBJECT\n"
|
||||||
"public:\n"
|
"public:\n"
|
||||||
" using QPtr = QPointer<A>;\n"
|
" using QPtr = QPointer<A>;\n"
|
||||||
"};\n";
|
"};\n";
|
||||||
|
expected = "1: class A {\n"
|
||||||
const char expected[] = "1: class A {\n"
|
|
||||||
"2: Q_OBJECT\n"
|
"2: Q_OBJECT\n"
|
||||||
"3: public:\n"
|
"3: public:\n"
|
||||||
"4:\n"
|
"4:\n"
|
||||||
"5: } ;\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"));
|
ASSERT_EQUALS(expected, tokenize(code, "test.cpp"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue