Fixed #1456 (PATCH: Variable hides typedef with same name false positive)
This commit is contained in:
parent
f4d600e93b
commit
54bf67e766
|
@ -407,6 +407,10 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name)
|
|||
}
|
||||
else if (end->str() == ",")
|
||||
{
|
||||
// check for derived class
|
||||
if (Token::Match(tok->previous(), "public|private|protected"))
|
||||
return false;
|
||||
|
||||
// find end of definition
|
||||
int level = 0;
|
||||
while (end && end->next() && (!Token::Match(end->next(), ";|)|>") ||
|
||||
|
@ -439,7 +443,7 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name)
|
|||
{
|
||||
// look backwards
|
||||
if (Token::Match(tok->previous(), "%type%") &&
|
||||
!Token::Match(tok->previous(), "return|new|const"))
|
||||
!Token::Match(tok->previous(), "return|new|const|volatile"))
|
||||
{
|
||||
// duplicate definition so skip entire template
|
||||
while (end && end->str() != "{")
|
||||
|
|
|
@ -174,6 +174,8 @@ private:
|
|||
TEST_CASE(simplifyTypedef35);
|
||||
TEST_CASE(simplifyTypedef36); // ticket #1434
|
||||
TEST_CASE(simplifyTypedef37); // ticket #1449
|
||||
TEST_CASE(simplifyTypedef38);
|
||||
TEST_CASE(simplifyTypedef39);
|
||||
TEST_CASE(reverseArraySyntax)
|
||||
TEST_CASE(simplify_numeric_condition)
|
||||
|
||||
|
@ -3394,6 +3396,28 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void simplifyTypedef38()
|
||||
{
|
||||
const char code[] = "typedef C A;\n"
|
||||
"struct AB : public A, public B { };";
|
||||
const char expected[] = "; struct AB : public C , public B { } ;";
|
||||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
|
||||
checkSimplifyTypedef(code);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef39()
|
||||
{
|
||||
const char code[] = "typedef int A;\n"
|
||||
"template <const A, volatile A>::value;";
|
||||
const char expected[] = "; ;";
|
||||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
|
||||
checkSimplifyTypedef(code);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void reverseArraySyntax()
|
||||
{
|
||||
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
||||
|
|
Loading…
Reference in New Issue