<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/54062>54062</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            -Wdeclaration-after-statement in arm_neon.h
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          nathanchance
      </td>
    </tr>
</table>

<pre>
    The Linux kernel is looking to [upgrade from `-std=gnu89` to `-std=gnu11`](https://lore.kernel.org/r/CAHk-=wh97QY9fEQUK6zMVQwaQ_JWDvR=R+TxQ_0OYrMHQ+egvQ@mail.gmail.com/). The kernel builds with `-Wdeclaration-after-statement`, which exposes an issue in `arm_neon.h` with arm64 big endian:

```
$ cat repro.c
#include <arm_neon.h>

static inline uint8x16_t SHLBYTE(uint8x16_t v)
{
    return vshlq_n_u8(v, 1);
}

$ clang --target=aarch64-linux-gnu -mbig-endian -std=gnu11 -Wdeclaration-after-statement -fsyntax-only -ffreestanding repro.c
repro.c:5:9: warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement]
        return vshlq_n_u8(v, 1);
               ^
.../lib/clang/15.0.0/include/arm_neon.h:24823:14: note: expanded from macro 'vshlq_n_u8'
  uint8x16_t __ret; \
             ^
1 warning generated.

$ clang --target=aarch64-linux-gnu -mbig-endian -std=gnu89 -Wdeclaration-after-statement -fsyntax-only repro.c
```

As far as I understand based on reading `clang::ProcessWarningOptions()` and `DiagnosticIDs::getDiagnosticSeverity()`, there should not be any warnings from system headers if `-Wsystem-headers` is not passed, which the kernel does not do.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVV2PqzYQ_TXkZQTiM4GHPORjV3vbe3Wbe7dd7VNkYAB3HTu1TTbpr-8YkpukqlatVAQ2HuPxmTNnTKnq0_y5Q_jMZX-EN9QSBXADQqk3LluwCrxs2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