File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -8033,7 +8033,7 @@ bool Tokenizer::simplifyRedundantParentheses()
80338033 while (Token::Match (tok2, " %type%|static|const|extern" ) && tok2->str () != " operator" ) {
80348034 tok2 = tok2->previous ();
80358035 }
8036- if (tok2 && !Token::Match (tok2, " [;, {]" )) {
8036+ if (tok2 && !Token::Match (tok2, " [;{]" )) {
80378037 // Not a variable declaration
80388038 } else {
80398039 tok->deleteThis ();
Original file line number Diff line number Diff line change @@ -482,6 +482,8 @@ class TestTokenizer : public TestFixture {
482482 TEST_CASE (simplifyPlatformTypes);
483483
484484 TEST_CASE (dumpFallthrough);
485+
486+ TEST_CASE (simplifyRedundantParentheses);
485487 }
486488
487489#define tokenizeAndStringify (...) tokenizeAndStringify_(__FILE__, __LINE__, __VA_ARGS__)
@@ -8556,6 +8558,14 @@ class TestTokenizer : public TestFixture {
85568558 const std::string dump = ostr.str ();
85578559 ASSERT (dump.find (" isAttributeFallthrough=\" true\" " ) != std::string::npos);
85588560 }
8561+
8562+ void simplifyRedundantParentheses () {
8563+ const char *code = " int f(struct S s) {\n "
8564+ " return g(1, &(int){ s.i });\n "
8565+ " }\n " ;
8566+ SimpleTokenizer tokenizer (settingsDefault, *this , false );
8567+ ASSERT_NO_THROW (tokenizer.tokenize (code));
8568+ }
85598569};
85608570
85618571REGISTER_TEST (TestTokenizer)
You can’t perform that action at this time.
0 commit comments