[clang] [Clang][C2y] Add support for if declarations (N3356 paper) (PR #198244)

via cfe-commits cfe-commits at lists.llvm.org
Tue May 26 10:48:13 PDT 2026


================
@@ -1909,19 +1909,11 @@ Sema::ConditionResult Parser::ParseCondition(StmtResult *InitStmt,
       return ParseCondition(nullptr, Loc, CK, MissingOK);
     }
 
-    if (Tok.is(tok::semi) && ParsedAttrs) {
+    if (Tok.is(tok::semi)) {
----------------
Sirraide wrote:

I believe we do still need to check if we parsed any attributes at all because afaik this is invalid:
```c
if (; true) {} // ERROR
```
but this is ok:
```c
if ([[]]; true) {} // OK
```
However, this is a bit of an issue since both of these have the same AST representation (they’re just `NullStmt`s)... I wonder if we could update `ActOnAttributedStmt()` to _always_ create an `AttributedStmt` even if there are no attributes in the _attribute-specifier-sequence_: We could add an additional `bool AlwaysBuildAttributedStmt = false` parameter to `ActOnAttributedStmt()` for this. Can you try and see if this approach works?

https://github.com/llvm/llvm-project/pull/198244


More information about the cfe-commits mailing list