Fixed #8156 (wrong ast for 'z = (x & (unsigned)1) | (y & (unsigned)2);')

This commit is contained in:
Daniel Marjamäki 2017-08-26 23:25:45 +02:00
parent e74e4c6934
commit 713f607168
2 changed files with 5 additions and 0 deletions

View File

@ -388,14 +388,18 @@ static Token * findCppTypeInitPar(Token *tok)
{
if (!tok || !Token::Match(tok->previous(), "[,()] %name%"))
return nullptr;
bool istype = false;
while (Token::Match(tok, "%name%|::|<")) {
if (tok->str() == "<") {
tok = tok->link();
if (!tok)
return nullptr;
}
istype |= tok->isStandardType();
tok = tok->next();
}
if (!istype)
return nullptr;
if (!Token::Match(tok, "[*&]"))
return nullptr;
while (Token::Match(tok, "[*&]"))

View File

@ -8039,6 +8039,7 @@ private:
ASSERT_EQUALS("fint(0,(", testAst("f(int(),0);"));
ASSERT_EQUALS("f(0,(", testAst("f(int *(),0);")); // typedef int* X; f(X(),0);
ASSERT_EQUALS("f((0,(", testAst("f((intp)int *(),0);"));
ASSERT_EQUALS("zx1(&y2(&|=", testAst("z = (x & (unsigned)1) | (y & (unsigned)2);")); // not type()
// for
ASSERT_EQUALS("for;;(", testAst("for(;;)"));