Skip to content

Commit 07cc7c3

Browse files
committed
Fix
1 parent 75f8dfd commit 07cc7c3

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

lib/tokenlist.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,11 +1787,12 @@ static Token * createAstAtToken(Token *tok)
17871787
}
17881788
}
17891789

1790-
if (Token::Match(tok, "%type% %name%|*|&|&&|::") && !Token::Match(tok, "return|new|delete")) {
1791-
int typecount = 0;
1790+
if ((Token::Match(tok, "%type% %name%|*|&|&&|::") && !Token::Match(tok, "return|new|delete")) ||
1791+
(Token::Match(tok, ":: %tyoe%") && !tok->next()->isKeyword())) {
1792+
int typecount = tok->str() == "::" ? 1 : 0;
17921793
Token *typetok = tok;
17931794
while (Token::Match(typetok, "%type%|::|*|&|&&|<")) {
1794-
if (typetok->isName() && (!Token::simpleMatch(typetok->previous(), "::") || tok->str() == "::"))
1795+
if (typetok->isName() && !Token::simpleMatch(typetok->previous(), "::"))
17951796
typecount++;
17961797
if (typetok->str() == "<") {
17971798
if (Token* closing = typetok->findClosingBracket()) {

test/testtokenize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ class TestTokenizer : public TestFixture {
425425
TEST_CASE(astrvaluedecl);
426426
TEST_CASE(astorkeyword);
427427
TEST_CASE(astenumdecl);
428+
TEST_CASE(astfuncdecl);
428429

429430
TEST_CASE(startOfExecutableScope);
430431

@@ -7419,7 +7420,7 @@ class TestTokenizer : public TestFixture {
74197420

74207421
void astfuncdecl() {
74217422
ASSERT_EQUALS("", testAst("bool operator==(const S& a, const S& b);", AstStyle::Simple, ListSimplification::Full));
7422-
ASSERT_EQUALS("", testAst("::int32_t f() {}"));
7423+
ASSERT_EQUALS("", testAst("::int32_t f();"));
74237424
}
74247425

74257426
#define isStartOfExecutableScope(offset, code) isStartOfExecutableScope_(offset, code, __FILE__, __LINE__)

0 commit comments

Comments
 (0)