[clang] [Clang] fix parser recovery for invalid static_assert string messages (PR #187859)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 1 05:03:55 PDT 2026
================
@@ -980,7 +980,7 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd) {
if (getLangOpts().CPlusPlus11) {
for (unsigned I = 0;; ++I) {
const Token &T = GetLookAheadToken(I);
- if (T.is(tok::r_paren))
+ if (T.isOneOf(tok::r_paren, tok::semi, tok::eof))
----------------
cor3ntin wrote:
I agree with Aaron, this does not seem to be the right fix.
The issue seems to be that `T.consumeClose()` return false on semicolon - It's weird but changing that is probably gonna hurt recovery in other places.
so the
```
if (T.consumeClose())
return nullptr;
```
Fails to do its job - maybe we can check here `if(Tok.isNot(r_paren) || /*...*/`).
Not very elegant but better than anything that would involve change to Sema
For the diagnostic message in @AaronBallman's link, we could choose to display it only if `ParseConstantExpressionInExprEvalContext()` produces something valid.
https://github.com/llvm/llvm-project/pull/187859
More information about the cfe-commits
mailing list