Fixed #7471 (Tokenizer::prepareTernaryOpForAST: typedef with comma inside ?:)
This commit is contained in:
parent
b7b92b2140
commit
06d5e73e88
|
@ -3530,6 +3530,11 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
|||
simplifyTypedef();
|
||||
}
|
||||
|
||||
// Add parentheses to ternary operator where necessary
|
||||
// TODO: this is only necessary if one typedef simplification had a comma and was used within ?:
|
||||
// If typedef handling is refactored and moved to symboldatabase someday we can remove this
|
||||
prepareTernaryOpForAST();
|
||||
|
||||
for (Token* tok = list.front(); tok;) {
|
||||
if (Token::Match(tok, "union|struct|class union|struct|class"))
|
||||
tok->deleteNext();
|
||||
|
|
|
@ -8025,6 +8025,8 @@ private:
|
|||
ASSERT_EQUALS("a ? ( b , c ) : d ;", tokenizeAndStringify("a ? (b , c) : d;"));
|
||||
|
||||
ASSERT_EQUALS("a ? ( 1 ? ( a , b ) : 3 ) : d ;", tokenizeAndStringify("a ? 1 ? a, b : 3 : d;"));
|
||||
|
||||
ASSERT_EQUALS("a ? ( std :: map < int , int > ( ) ) : 0 ;", tokenizeAndStringify("typedef std::map<int,int> mymap; a ? mymap() : 0;"));
|
||||
}
|
||||
|
||||
std::string testAst(const char code[],bool verbose=false) {
|
||||
|
|
Loading…
Reference in New Issue