Fixed #644 (Tokenizer::simplifyComma: Wrong simplification in cast)
This commit is contained in:
parent
37dae83e06
commit
7479b943cc
|
@ -3710,6 +3710,38 @@ void Tokenizer::simplifyComma()
|
|||
continue;
|
||||
}
|
||||
|
||||
// Skip unhandled template specifiers..
|
||||
if (Token::Match(tok, "%var% <"))
|
||||
{
|
||||
// Todo.. use the link instead.
|
||||
unsigned int parlevel = 0;
|
||||
unsigned int comparelevel = 0;
|
||||
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
||||
{
|
||||
if (tok2->str() == "<")
|
||||
++comparelevel;
|
||||
else if (tok2->str() == ">")
|
||||
{
|
||||
if (comparelevel <= 1)
|
||||
{
|
||||
tok = tok2;
|
||||
break;
|
||||
}
|
||||
++comparelevel;
|
||||
}
|
||||
else if (tok2->str() == "(")
|
||||
++parlevel;
|
||||
else if (tok2->str() == ")")
|
||||
{
|
||||
if (parlevel == 0)
|
||||
break;
|
||||
--parlevel;
|
||||
}
|
||||
else if (Token::Match(tok2, "[;{}]"))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tok->str() != ",")
|
||||
continue;
|
||||
|
||||
|
|
|
@ -1309,6 +1309,15 @@ private:
|
|||
"}\n";
|
||||
ASSERT_EQUALS(" void f ( ) { A a ; A b ; if ( a . f ) { a . f = b . f ; a . g = b . g ; } }", sizeof_(code));
|
||||
}
|
||||
|
||||
// keep the comma in template specifiers..
|
||||
{
|
||||
const char code[] = "void f()\n"
|
||||
"{\n"
|
||||
" int a = b<T<char,3>, int>();\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(" void f ( ) { int a ; a = b < T < char , 3 > , int > ( ) ; }", sizeof_(code));
|
||||
}
|
||||
}
|
||||
|
||||
void conditionOperator()
|
||||
|
|
Loading…
Reference in New Issue