File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1738,6 +1738,8 @@ static Token * createAstAtToken(Token *tok)
17381738 AST_state state (cpp);
17391739 if (Token::Match (tok, " %name% (" ))
17401740 state.functionCallEndPar = tok->linkAt (1 );
1741+ if (Token::simpleMatch (tok->tokAt (-1 ), " ::" ) && (!tok->tokAt (-2 ) || !tok->tokAt (-2 )->isName ()))
1742+ tok = tok->tokAt (-1 );
17411743 compileExpression (tok, state);
17421744 Token * const endToken = tok;
17431745 if (endToken == tok1 || !endToken)
@@ -1760,11 +1762,6 @@ static Token * createAstAtToken(Token *tok)
17601762 return endToken->previous ();
17611763 }
17621764
1763- if (cpp && ((!tok->previous () && tok->str () == " ::" ) || Token::Match (tok->previous (), " [;{}] ::" ))) {
1764- AST_state state (cpp);
1765- compileExpression (tok, state);
1766- }
1767-
17681765 return tok;
17691766}
17701767
Original file line number Diff line number Diff line change @@ -2480,6 +2480,14 @@ class TestLeakAutoVar : public TestFixture {
24802480 " std::shared_ptr<C> a{c, [](C* x) { delete x; }};\n "
24812481 " }" , true );
24822482 ASSERT_EQUALS (" " , errout_str ());
2483+
2484+ check (" struct DirDeleter {\n " // #12544
2485+ " void operator()(DIR* d) { ::closedir(d); }\n "
2486+ " };\n "
2487+ " void openDir(DIR* dir) {\n "
2488+ " std::shared_ptr<DIR> dp(dir, DirDeleter());\n "
2489+ " }\n " , true );
2490+ ASSERT_EQUALS (" [test.cpp:2]: (information) --check-library: Function closedir() should have <noreturn> configuration\n " , errout_str ()); // don't crash
24832491 }
24842492 void smartPointerRelease () {
24852493 check (" void f() {\n "
Original file line number Diff line number Diff line change @@ -6218,6 +6218,13 @@ class TestTokenizer : public TestFixture {
62186218 " (kInput & (uint64_t(1) << 63)) ? 63 : 64;\n "
62196219 " };\n " ;
62206220 ASSERT_NO_THROW (tokenizeAndStringify (code));
6221+
6222+ code = " void f(const std::vector<int>& v) {\n " // #12569
6223+ " ::std::for_each(v.begin(), v.end(), [](int i) {\n "
6224+ " int j(i ? i : 5);\n "
6225+ " });\n "
6226+ " }\n " ;
6227+ ASSERT_NO_THROW (tokenizeAndStringify (code));
62216228 }
62226229
62236230 void astnewdelete () const {
You can’t perform that action at this time.
0 commit comments