Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/tokenlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,10 @@ static void compileTerm(Token *&tok, AST_state& state)
if (precedes(tok,end)) // typically for something like `MACRO(x, { if (c) { ... } })`, where end is the last curly, and tok is the open curly for the if
tok = end;
}
} else if (tok->next() == end) {
tok->astOperand1(state.op.top());
state.op.pop();
tok = tok->next();
} else
compileBinOp(tok, state, compileExpression);
if (tok != end)
Expand Down
14 changes: 14 additions & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ class TestTokenizer : public TestFixture {
TEST_CASE(simplifyIfSwitchForInit4);
TEST_CASE(simplifyIfSwitchForInit5);

TEST_CASE(newPlacementArgsCppInit); // #13775

TEST_CASE(cpp20_default_bitfield_initializer);

TEST_CASE(cpp11init);
Expand Down Expand Up @@ -8070,6 +8072,18 @@ class TestTokenizer : public TestFixture {
ASSERT_EQUALS("void f ( ) { if ( [ ] { ; } ) { } }", tokenizeAndStringify(code, settings));
}

void newPlacementArgsCppInit() { // #13775
const char code[] = "::new(nullptr) int {};";
SimpleTokenizer tokenizer(settings1, *this);
tokenizer.tokenize(code);
const Token *inttok = Token::findsimplematch(tokenizer.tokens(), "int");
ASSERT(inttok);
const Token *brace = inttok->next();
ASSERT(brace);
ASSERT_EQUALS(brace->astOperand1(), inttok);
ASSERT_EQUALS(brace->astOperand2(), static_cast<const Token*>(nullptr));
}

void cpp20_default_bitfield_initializer() {
const Settings s1 = settingsBuilder().cpp(Standards::CPP20).build();
const char code[] = "struct S { int a:2 = 0; };";
Expand Down
Loading