Fix spurious variable declaration with unknown macro (#4694)
This commit is contained in:
parent
8cc3e0b2ff
commit
491721a6ff
|
@ -6406,6 +6406,8 @@ 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:"))
|
||||||
|
continue;
|
||||||
//skip all the pointer part
|
//skip all the pointer part
|
||||||
bool isPointerOrRef = false;
|
bool isPointerOrRef = false;
|
||||||
while (Token::simpleMatch(varName, "*") || Token::Match(varName, "& %name% ,")) {
|
while (Token::simpleMatch(varName, "*") || Token::Match(varName, "& %name% ,")) {
|
||||||
|
|
|
@ -136,6 +136,7 @@ private:
|
||||||
TEST_CASE(varid_in_class21); // #7788
|
TEST_CASE(varid_in_class21); // #7788
|
||||||
TEST_CASE(varid_in_class22); // #10872
|
TEST_CASE(varid_in_class22); // #10872
|
||||||
TEST_CASE(varid_in_class23); // #11293
|
TEST_CASE(varid_in_class23); // #11293
|
||||||
|
TEST_CASE(varid_in_class24);
|
||||||
TEST_CASE(varid_namespace_1); // #7272
|
TEST_CASE(varid_namespace_1); // #7272
|
||||||
TEST_CASE(varid_namespace_2); // #7000
|
TEST_CASE(varid_namespace_2); // #7000
|
||||||
TEST_CASE(varid_namespace_3); // #8627
|
TEST_CASE(varid_namespace_3); // #8627
|
||||||
|
@ -1988,6 +1989,22 @@ private:
|
||||||
ASSERT_EQUALS(expected, tokenize(code, "test.cpp"));
|
ASSERT_EQUALS(expected, tokenize(code, "test.cpp"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void varid_in_class24() {
|
||||||
|
const char code[] = "class A {\n"
|
||||||
|
" Q_OBJECT\n"
|
||||||
|
"public:\n"
|
||||||
|
" using QPtr = QPointer<A>;\n"
|
||||||
|
"};\n";
|
||||||
|
|
||||||
|
const char expected[] = "1: class A {\n"
|
||||||
|
"2: Q_OBJECT\n"
|
||||||
|
"3: public:\n"
|
||||||
|
"4:\n"
|
||||||
|
"5: } ;\n";
|
||||||
|
|
||||||
|
ASSERT_EQUALS(expected, tokenize(code, "test.cpp"));
|
||||||
|
}
|
||||||
|
|
||||||
void varid_namespace_1() { // #7272
|
void varid_namespace_1() { // #7272
|
||||||
const char code[] = "namespace Blah {\n"
|
const char code[] = "namespace Blah {\n"
|
||||||
" struct foo { int x;};\n"
|
" struct foo { int x;};\n"
|
||||||
|
|
Loading…
Reference in New Issue