Issue 161014
Summary -Wdeclaration-after-statement dislikes _Static_assert
Labels new issue
Assignees
Reporter Alcaro
    ```c
int foo(void)
{
    _Static_assert(2+2 == 4, "");
    int a = 2;
    _Static_assert(2+2 == 4, "");
    a += 2;
    _Static_assert(2+2 == 4, "");
    return a;
}
```
-xc -Wdeclaration-after-statement

https://godbolt.org/z/Ee4aPbcd9

Result: 1x `warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement]`.

Expected: Since a succeeding _Static_assert does nothing, it's neither declaration nor code; therefore, omit the warning. Especially considering _Static_assert itself is incompatible with standards before C99.

Found it at winehq, they're using that warning to enforce their coding style. https://gitlab.winehq.org/wine/wine/-/merge_requests/9061#note_116902
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to