Fixed #1488 (Invalid warning about shadowed variable)
This commit is contained in:
parent
09ab841789
commit
587081cab5
|
@ -494,7 +494,8 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name)
|
|||
// look backwards
|
||||
if (Token::Match(tok->previous(), "typedef|}|>") ||
|
||||
(Token::Match(tok->previous(), "%type%") &&
|
||||
!Token::Match(tok->previous(), "return|new|const|friend")))
|
||||
(!Token::Match(tok->previous(), "return|new|const|friend") &&
|
||||
!Token::Match(tok->tokAt(-2), "friend class"))))
|
||||
{
|
||||
// scan backwards for the end of the previous statement
|
||||
int level = (tok->previous()->str() == "}") ? 1 : 0;
|
||||
|
|
|
@ -178,6 +178,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef38);
|
||||
TEST_CASE(simplifyTypedef39);
|
||||
TEST_CASE(simplifyTypedef40);
|
||||
TEST_CASE(simplifyTypedef41); // ticket #1488
|
||||
|
||||
TEST_CASE(reverseArraySyntax)
|
||||
TEST_CASE(simplify_numeric_condition)
|
||||
|
@ -3508,6 +3509,18 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef41()
|
||||
{
|
||||
// ticket #1488
|
||||
checkSimplifyTypedef("class Y;\n"
|
||||
"class X\n"
|
||||
"{\n"
|
||||
" typedef Y type;\n"
|
||||
" friend class type;\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void reverseArraySyntax()
|
||||
{
|
||||
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
||||
|
|
Loading…
Reference in New Issue