Don't crash on C++23 code (#4771)
This commit is contained in:
parent
55292d476a
commit
1fcea5fb03
|
@ -1598,7 +1598,7 @@ static Token * createAstAtToken(Token *tok, bool cpp)
|
|||
semicolon2->astOperand2(state3.op.top());
|
||||
semicolon1->astOperand2(semicolon2);
|
||||
} else {
|
||||
if (!cpp || !Token::simpleMatch(state2.op.top(), ":"))
|
||||
if (!cpp || state2.op.empty() || !Token::simpleMatch(state2.op.top(), ":"))
|
||||
throw InternalError(tok, "syntax error", InternalError::SYNTAX);
|
||||
|
||||
semicolon1->astOperand2(state2.op.top());
|
||||
|
|
|
@ -434,6 +434,7 @@ private:
|
|||
TEST_CASE(noCrash4);
|
||||
TEST_CASE(noCrash5); // #10603
|
||||
TEST_CASE(noCrash6); // #10212
|
||||
TEST_CASE(noCrash7);
|
||||
|
||||
// --check-config
|
||||
TEST_CASE(checkConfiguration);
|
||||
|
@ -7357,6 +7358,12 @@ private:
|
|||
"struct c<a<e, d...>, true> {};\n"));
|
||||
}
|
||||
|
||||
void noCrash7() {
|
||||
ASSERT_THROW(tokenizeAndStringify("void g() {\n"// TODO: don't throw
|
||||
" for (using T = int; (T)false;) {}\n" // C++23 P2360R0: Extend init-statement to allow alias-declaration
|
||||
"}\n"), InternalError);
|
||||
}
|
||||
|
||||
void checkConfig(const char code[]) {
|
||||
errout.str("");
|
||||
|
||||
|
|
Loading…
Reference in New Issue