Skip to content

Commit a552b26

Browse files
authored
fix #12657: Syntax error. Unexpected tokens in initializer. [internalAstError] (danmar#7580)
1 parent 4a53d04 commit a552b26

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/tokenlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
10701070
state.inGeneric = inGenericSaved;
10711071
tok = tok->link()->next();
10721072
if (Token::simpleMatch(tok, "::"))
1073-
compileBinOp(tok, state, compileTerm);
1073+
compileBinOp(tok, state, compileScope);
10741074
} else if (iscast(tok, state.cpp) && Token::simpleMatch(tok->link(), ") {") &&
10751075
Token::simpleMatch(tok->link()->linkAt(1), "} [")) {
10761076
Token *cast = tok;

test/testtokenize.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ class TestTokenizer : public TestFixture {
400400
TEST_CASE(astnoexcept);
401401
TEST_CASE(astvardecl);
402402
TEST_CASE(astnewscoped);
403+
TEST_CASE(astdecltypescope);
403404

404405
TEST_CASE(startOfExecutableScope);
405406

@@ -7130,6 +7131,10 @@ class TestTokenizer : public TestFixture {
71307131
ASSERT_EQUALS("(return (new (( (:: (:: (:: A B) C) D) true)))", testAst("return new A::B::C::D(true);", AstStyle::Z3));
71317132
}
71327133

7134+
void astdecltypescope() {
7135+
ASSERT_EQUALS("sizedecltypethism_P.(XSize::::{", testAst("size { decltype(this->m_P)::X::Size };"));
7136+
}
7137+
71337138
#define isStartOfExecutableScope(offset, code) isStartOfExecutableScope_(offset, code, __FILE__, __LINE__)
71347139
template<size_t size>
71357140
bool isStartOfExecutableScope_(int offset, const char (&code)[size], const char* file, int line) {

0 commit comments

Comments
 (0)