Skip to content

-Wdeclaration-after-statement in arm_neon.h #54062

Closed
@nathanchance

Description

@nathanchance

The Linux kernel is looking to upgrade from -std=gnu89 to -std=gnu11. The kernel builds with -Wdeclaration-after-statement, which exposes an issue in arm_neon.h with arm64 big endian: https://godbolt.org/z/313sW6zrW

$ 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.

Metadata

Metadata

Labels

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions