[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C
Nathan Chancellor via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 7 08:44:04 PDT 2023
nathanchance added a comment.
In D76096#4564855 <https://reviews.llvm.org/D76096#4564855>, @DavidSpickett wrote:
> One of the kernel tests now fails to build for AArch64 and Arm:
>
> 00:00:48 ++ make CC=/home/tcwg-buildslave/workspace/tcwg_kernel_0/bin/aarch64-cc LD=/home/tcwg-buildslave/workspace/tcwg_kernel_0/llvm-install/bin/ld.lld SUBLEVEL=0 EXTRAVERSION=-bisect ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- HOSTCC=/home/tcwg-buildslave/workspace/tcwg_kernel_0/llvm-install/bin/clang -j32 -s -k
> 00:08:26 lib/test_scanf.c:661:2: error: implicit conversion from 'int' to 'unsigned char' changes value from -168 to 88 [-Werror,-Wconstant-conversion]
> 00:08:26 661 | test_number_prefix(unsigned char, "0xA7", "%2hhx%hhx", 0, 0xa7, 2, check_uchar);
> 00:08:26 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 00:08:26 lib/test_scanf.c:609:29: note: expanded from macro 'test_number_prefix'
> 00:08:26 609 | T result[2] = {~expect[0], ~expect[1]}; \
> 00:08:26 | ~ ^~~~~~~~~~
> 00:08:27 1 error generated.
> 00:08:27 make[3]: *** [scripts/Makefile.build:243: lib/test_scanf.o] Error 1
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/test_scanf.c#n661
>
> Seems like the test should be fixed, though I wonder why this same error isn't effecting GCC builds.
Thanks for the report! I sent a patch for this already, just waiting for it to be picked up: https://lore.kernel.org/20230807-test_scanf-wconstant-conversion-v2-1-839ca39083e1@kernel.org/
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76096/new/
https://reviews.llvm.org/D76096
More information about the cfe-commits
mailing list