https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93287

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
_Static_assert is a declaration in the C standard to allow it to be at the
toplevel too.

Also this fails as expected (on both GCC and Clang):
int f(void)
{
  if (1)
    _Static_assert (1);
}

---- CUT ----
so yes _Static_assert is a declaration.

I would say it is a bug in clang rather than gcc here.
clang documentation is really really lacking here too:
https://clang.llvm.org/docs/DiagnosticsReference.html#wdeclaration-after-statement

:)

GCC is much better:
https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html#index-Wdeclaration-after-statement
-Wdeclaration-after-statement (C and Objective-C only)
Warn when a declaration is found after a statement in a block. This construct,
known from C++, was introduced with ISO C99 and is by default allowed in GCC.
It is not supported by ISO C90. See Mixed Declarations[1].

[1]
https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Mixed-Declarations.html#Mixed-Declarations

Reply via email to