Issue 141659
Summary [Clang][C23] No diagnostic for attribute declaration where statement is required
Labels clang
Assignees
Reporter sheumann
    In C23, something like `[[/*possible attributes*/]];` is an attribute declaration, not a statement. So it is not allowed by the syntax in places where a statement is required, specifically as the secondary block of a selection or iteration statement.

Therefore, code like the following should give a diagnostic (at least with `-std=c23 -pedantic`), but Clang currently does not produce one:

```
int main(void) {
    if (1)
 [[]];
}
```

If desired, this could still be allowed as an extension when not pedantically following the standard. I do not have a strong opinion on whether it should be. For reference, GCC gives an error for this, even without `-std=c23 -pedantic`.

(This differs from C++, since C++ allows declaration statements.)

Godbolt link: https://godbolt.org/z/sKGe99x9P
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to