forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 15
Closed
Labels
-Wdeclaration-after-statement[ARCH] arm64This bug impacts ARCH=arm64This bug impacts ARCH=arm64[BUG] llvmA bug that should be fixed in upstream LLVMA bug that should be fixed in upstream LLVM[FIXED][LLVM] 14This bug was fixed in LLVM 14.xThis bug was fixed in LLVM 14.x[FIXED][LLVM] 15This bug was fixed in LLVM 15.xThis bug was fixed in LLVM 15.x
Description
Linus is proposing switching to -std=gnu11. In my tests, I found this introduced a warning with an arm64 big endian defconfig:
$ git diff HEAD
diff --git a/Makefile b/Makefile
index 289ce2be8032..e8d600be95a4 100644
--- a/Makefile
+++ b/Makefile
@@ -515,7 +515,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
-Werror=implicit-function-declaration -Werror=implicit-int \
-Werror=return-type -Wno-format-security \
- -std=gnu89
+ -std=gnu11 -Wno-shift-count-negative
KBUILD_CPPFLAGS := -D__KERNEL__
KBUILD_AFLAGS_KERNEL :=
KBUILD_CFLAGS_KERNEL :=
$ make -skj"$(nproc)" ARCH=arm64 LLVM=1 mrproper defconfig
$ scripts/config -d CPU_LITTLE_ENDIAN -e CPU_BIG_ENDIAN
$ make -skj"$(nproc)" ARCH=arm64 LLVM=1 olddefconfig lib/raid6/
lib/raid6/recov_neon_inner.c:55:8: warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement]
vy = vshrq_n_u8(vx, 4);
^
/home/nathan/cbl/toolchains/stow/llvm/2022-02-23_16-14-30-18fa0b15ccf610f34af1231440f89d20cb99e7a0/lib/clang/15.0.0/include/arm_neon.h:25231:14: note: expanded from macro 'vshrq_n_u8'
uint8x16_t __ret; \
^
lib/raid6/recov_neon_inner.c:60:8: warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement]
vy = vshrq_n_u8(px, 4);
^
/home/nathan/cbl/toolchains/stow/llvm/2022-02-23_16-14-30-18fa0b15ccf610f34af1231440f89d20cb99e7a0/lib/clang/15.0.0/include/arm_neon.h:25231:14: note: expanded from macro 'vshrq_n_u8'
uint8x16_t __ret; \
^
lib/raid6/recov_neon_inner.c:96:8: warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement]
vy = vshrq_n_u8(vx, 4);
^
/home/nathan/cbl/toolchains/stow/llvm/2022-02-23_16-14-30-18fa0b15ccf610f34af1231440f89d20cb99e7a0/lib/clang/15.0.0/include/arm_neon.h:25231:14: note: expanded from macro 'vshrq_n_u8'
uint8x16_t __ret; \
^
3 warnings generated.
...Looking at arm_neon.h:
#ifdef __LITTLE_ENDIAN__
#define vshrq_n_u8(__p0, __p1) __extension__ ({ \
uint8x16_t __s0 = __p0; \
uint8x16_t __ret; \
__ret = (uint8x16_t) __builtin_neon_vshrq_n_v((int8x16_t)__s0, __p1, 48); \
__ret; \
})
#else
#define vshrq_n_u8(__p0, __p1) __extension__ ({ \
uint8x16_t __s0 = __p0; \
uint8x16_t __rev0; __rev0 = __builtin_shufflevector(__s0, __s0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); \
uint8x16_t __ret; \
__ret = (uint8x16_t) __builtin_neon_vshrq_n_v((int8x16_t)__rev0, __p1, 48); \
__ret = __builtin_shufflevector(__ret, __ret, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); \
__ret; \
})
#endifIt looks like this file is automatically generated, so I am not sure how to make __rev0 appear after __ret.
cc @DavidSpickett for thoughts, as you have helped with ARM LLVM problems before.
Metadata
Metadata
Assignees
Labels
-Wdeclaration-after-statement[ARCH] arm64This bug impacts ARCH=arm64This bug impacts ARCH=arm64[BUG] llvmA bug that should be fixed in upstream LLVMA bug that should be fixed in upstream LLVM[FIXED][LLVM] 14This bug was fixed in LLVM 14.xThis bug was fixed in LLVM 14.x[FIXED][LLVM] 15This bug was fixed in LLVM 15.xThis bug was fixed in LLVM 15.x
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
arndb commentedon Feb 25, 2022
I think part of the issue here is that <arm_neon.h> is a system header, which has more relaxed rules for warnings, so we intentionally don't get a warning with "-std=gnu89 -Wdeclaration-after-statement -Wno-gnu" despite the code being in standard c89 without GNU extensions.
It appears that with "-std=gnu11 -Wdeclaration-after-statement", clang incorrectly warns about it even in system headers as this is correct behavior in both c11 and gnu11, but we ask for a warning anyway.
nathanchance commentedon Feb 25, 2022
Right. I can see in
Sema::ActOnCompoundStmt()that there is a check for the diagnostic being ignored (!Diags.isIgnored(MixedDeclsCodeID, L)), which callsDiagnosticIDs::getDiagnosticSeverity(), which does check if the source location is in a system macro; maybe something about that flow is messed up?nathanchance commentedon Feb 25, 2022
I've filed an upstream LLVM bug: llvm/llvm-project#54062
MarcusJohnson91 commentedon Feb 28, 2022
Why C11? C18 is exactly the same, with just one unused macro that was introduced in C11 removed.
arndb commentedon Feb 28, 2022
C11 is the newest standard that the oldest supported compiler (gcc-5.1) already understands. I think we can probably just do away with explicitly picking a -std= option and go with the compiler's default, which should be gnu11 or higher for all supported versions of gcc or clang.
Kbuild: remove -std=gnu89 from compiler arguments
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
491 remaining items
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11
Kbuild: move to -std=gnu11