Fixed #1327 (False positive: Redundant code: Found a statement that begins with numeric constant)
This commit is contained in:
parent
6e48f57826
commit
f9d5fb3191
|
@ -5365,11 +5365,16 @@ void Tokenizer::simplifyComma()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tok->str() == "(")
|
||||||
|
{
|
||||||
|
tok = tok->link();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Skip unhandled template specifiers..
|
// Skip unhandled template specifiers..
|
||||||
if (Token::Match(tok, "%var% <"))
|
if (Token::Match(tok, "%var% <"))
|
||||||
{
|
{
|
||||||
// Todo.. use the link instead.
|
// Todo.. use the link instead.
|
||||||
unsigned int parlevel = 0;
|
|
||||||
unsigned int comparelevel = 0;
|
unsigned int comparelevel = 0;
|
||||||
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
||||||
{
|
{
|
||||||
|
@ -5384,14 +5389,6 @@ void Tokenizer::simplifyComma()
|
||||||
}
|
}
|
||||||
++comparelevel;
|
++comparelevel;
|
||||||
}
|
}
|
||||||
else if (tok2->str() == "(")
|
|
||||||
++parlevel;
|
|
||||||
else if (tok2->str() == ")")
|
|
||||||
{
|
|
||||||
if (parlevel == 0)
|
|
||||||
break;
|
|
||||||
--parlevel;
|
|
||||||
}
|
|
||||||
else if (Token::Match(tok2, "[;{}]"))
|
else if (Token::Match(tok2, "[;{}]"))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1878,6 +1878,19 @@ private:
|
||||||
"}\n";
|
"}\n";
|
||||||
ASSERT_EQUALS("void f ( ) { int a ; a = b < T < char , 3 > , int > ( ) ; }", sizeof_(code));
|
ASSERT_EQUALS("void f ( ) { int a ; a = b < T < char , 3 > , int > ( ) ; }", sizeof_(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// ticket #1327
|
||||||
|
const char code[] = "const C<1,2,3> foo ()\n"
|
||||||
|
"{\n"
|
||||||
|
" return C<1,2,3>(x,y);\n"
|
||||||
|
"}\n";
|
||||||
|
const char expected[] = "const C < 1 , 2 , 3 > foo ( ) "
|
||||||
|
"{"
|
||||||
|
" return C < 1 , 2 , 3 > ( x , y ) ; "
|
||||||
|
"}";
|
||||||
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void conditionOperator()
|
void conditionOperator()
|
||||||
|
|
Loading…
Reference in New Issue