ast: fixed hang when checking beid

This commit is contained in:
Daniel Marjamäki 2014-02-05 06:05:48 +01:00
parent 2ed3b40937
commit 6ac9e180e0
2 changed files with 9 additions and 9 deletions

View File

@ -447,9 +447,6 @@ static void compileTerm(Token *& tok, std::stack<Token*> &op)
} else if (!Token::Match(tok->next(), "(|[") && !templatefunc) {
op.push(tok);
tok = tok->next();
} else if (Token::Match(tok, "%type% ( {")) {
op.push(tok);
tok = tok->linkAt(2);
} else {
Token *name = tok;
Token *par = templatefunc ? tok->linkAt(1)->next() : tok->next();
@ -508,9 +505,6 @@ static void compileTerm(Token *& tok, std::stack<Token*> &op)
op.pop();
}
op.push(unaryop);
} else if (Token::Match(tok,"( {")) {
op.push(tok->next());
tok = tok->link()->next();
} else if (Token::simpleMatch(tok->link(),") (")) {
// Parenthesized sub-expression
Token *nextpar = tok->link()->next();
@ -525,6 +519,9 @@ static void compileTerm(Token *& tok, std::stack<Token*> &op)
compileExpression(tok,op);
tok = tok->next();
}
} else if (tok->str() == "{") {
op.push(tok);
tok = tok->link()->next();
}
}

View File

@ -10157,9 +10157,12 @@ private:
// ({..})
ASSERT_EQUALS("a{+d+ bc+", testAst("a+({b+c;})+d"));
ASSERT_EQUALS("a{d*+ bc+", testAst("a+({b+c;})*d"));
ASSERT_EQUALS("xa(= bc( yd(= ef(", testAst("x=(int)(a({b(c);}));"
"y=(int)(d({e(f);}));"));
ASSERT_EQUALS("xa{((= bc( yd{((= ef(",
testAst("x=(int)(a({b(c);}));" // don't hang
"y=(int)(d({e(f);}));"));
ASSERT_EQUALS("QT_WA{{,( QT_WA{{,( x1=",
testAst("QT_WA({},{x=0;});" // don't hang
"QT_WA({x=1;},{x=2;});"));
}
void astbrackets() const { // []