From 6ac9e180e0d803bea26a020525b3bebafe4525fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 5 Feb 2014 06:05:48 +0100 Subject: [PATCH] ast: fixed hang when checking beid --- lib/tokenlist.cpp | 9 +++------ test/testtokenize.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 578ad9f0d..6879086af 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -447,9 +447,6 @@ static void compileTerm(Token *& tok, std::stack &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 &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 &op) compileExpression(tok,op); tok = tok->next(); } + } else if (tok->str() == "{") { + op.push(tok); + tok = tok->link()->next(); } } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 0c7709918..a2b93c4ee 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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 { // []