File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5552,7 +5552,10 @@ void Tokenizer::removeMacrosInGlobalScope()
55525552 if (tok->str () == " (" ) {
55535553 tok = tok->link ();
55545554 if (Token::Match (tok, " ) %type% {" ) &&
5555- !Token::Match (tok->next (), " const|namespace|class|struct|union|noexcept|override|final|volatile|mutable" ))
5555+ !tok->next ()->isStandardType () &&
5556+ !tok->next ()->isKeyword () &&
5557+ !Token::Match (tok->next (), " override|final" ) &&
5558+ tok->next ()->isUpperCaseName ())
55565559 tok->deleteNext ();
55575560 }
55585561
Original file line number Diff line number Diff line change @@ -561,7 +561,7 @@ static bool iscpp11init_impl(const Token * const tok)
561561 nameToken = nameToken->link ()->previous ();
562562 if (nameToken->str () == " ]" ) {
563563 const Token* newTok = nameToken->link ()->previous ();
564- while (Token::Match (newTok, " %type%" ) && !newTok->isKeyword ())
564+ while (Token::Match (newTok, " %type%|:: " ) && !newTok->isKeyword ())
565565 newTok = newTok->previous ();
566566 if (Token::simpleMatch (newTok, " new" ))
567567 return true ;
Original file line number Diff line number Diff line change @@ -5256,6 +5256,15 @@ class TestTokenizer : public TestFixture {
52565256 " \n "
52575257 " BOOL CSetProgsAdvDlg::OnInitDialog() {}" ),
52585258 InternalError);
5259+
5260+ ASSERT_EQUALS (" struct S {\n "
5261+ " S ( ) : p { new ( malloc ( 4 ) ) int { } } { }\n "
5262+ " int * p ;\n "
5263+ " } ;" ,
5264+ tokenizeAndStringify (" struct S {\n "
5265+ " S() : p{new (malloc(4)) int{}} {}\n "
5266+ " int* p;\n "
5267+ " };\n " ));
52595268 }
52605269
52615270 void addSemicolonAfterUnknownMacro () {
@@ -7563,6 +7572,20 @@ class TestTokenizer : public TestFixture {
75637572 " { void" ,
75647573 TokenImpl::Cpp11init::NOINIT);
75657574
7575+ testIsCpp11init (" struct S {\n "
7576+ " std::uint8_t* p;\n "
7577+ " S() : p{ new std::uint8_t[1]{} } {}\n "
7578+ " };\n " ,
7579+ " { } } {" ,
7580+ TokenImpl::Cpp11init::CPP11INIT);
7581+
7582+ testIsCpp11init (" struct S {\n "
7583+ " S() : p{new (malloc(4)) int{}} {}\n "
7584+ " int* p;\n "
7585+ " };\n " ,
7586+ " { } } {" ,
7587+ TokenImpl::Cpp11init::CPP11INIT);
7588+
75667589 ASSERT_NO_THROW (tokenizeAndStringify (" template<typename U> struct X {};\n " // don't crash
75677590 " template<typename T> auto f(T t) -> X<decltype(t + 1)> {}\n " ));
75687591 #undef testIsCpp11init
You can’t perform that action at this time.
0 commit comments