Fixed #2314 (False positive: (style) Template instantiation 'Foo' hides typedef with same name)
This commit is contained in:
parent
0473473e7b
commit
bf136f0123
|
@ -518,6 +518,9 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name)
|
|||
if (!Token::Match(tok->tokAt(-2), "%type%"))
|
||||
return false;
|
||||
|
||||
if (!Token::Match(tok->tokAt(-3), ",|<"))
|
||||
return false;
|
||||
|
||||
duplicateTypedefError(*tokPtr, name, "Template instantiation");
|
||||
*tokPtr = end->link();
|
||||
return true;
|
||||
|
@ -6602,7 +6605,7 @@ bool Tokenizer::simplifyCalculations()
|
|||
}
|
||||
|
||||
// Remove parentheses around number..
|
||||
if (Token::Match(tok->tokAt(-2), "%any% ( %num% )") && !tok->tokAt(-2)->isName())
|
||||
if (Token::Match(tok->tokAt(-2), "%any% ( %num% )") && !tok->tokAt(-2)->isName() && tok->strAt(-2) != ">")
|
||||
{
|
||||
tok = tok->previous();
|
||||
tok->deleteThis();
|
||||
|
|
|
@ -221,6 +221,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef62); // ticket #2082
|
||||
TEST_CASE(simplifyTypedef63); // ticket #2175 'typedef float x[3];'
|
||||
TEST_CASE(simplifyTypedef64);
|
||||
TEST_CASE(simplifyTypedef65); // ticket #2314
|
||||
|
||||
TEST_CASE(simplifyTypedefFunction1);
|
||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||
|
@ -4589,6 +4590,18 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef65() // ticket #2314
|
||||
{
|
||||
const char code[] = "typedef BAR<int> Foo; \n"
|
||||
"int main() { \n"
|
||||
" Foo b(0); \n"
|
||||
" return b > Foo(10); \n"
|
||||
"}";
|
||||
const std::string actual(sizeof_(code));
|
||||
ASSERT_EQUALS("; int main ( ) { BAR < int > b ( 0 ) ; return b > BAR < int > ( 10 ) ; }", actual);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedefFunction1()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue