From d5d33c599143f6c36406eb860571fced1da49ea4 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 17 Nov 2024 09:00:49 -0800 Subject: [PATCH] Further improvements for C23 tests Problems reported by Bruno Haible in: https://lists.gnu.org/r/bug-gnulib/2024-11/msg00140.html https://lists.gnu.org/r/bug-gnulib/2024-11/msg00141.html https://lists.gnu.org/r/bug-gnulib/2024-11/msg00145.html * lib/autoconf/c.m4 (_AC_C_C23_TEST_GLOBALS): In use_u8, add parens to pacify GCC 15 -Wbool-compare, and use sizeof to make it a conforming integer constant expression. Do not test stdbit.h, as some current sort-of-C23 environments lack it and want to use options like -std=gnu23 on such platforms. Use null_pointer to pacify GCC -Wunused-const-variable. --- lib/autoconf/c.m4 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index 40ed1175..83a13b72 100644 --- a/lib/autoconf/c.m4 +++ b/lib/autoconf/c.m4 @@ -1118,7 +1118,9 @@ fi[]dnl # # C11 adds: # -# C23 adds: +# C23 adds the following. Do not test it, though, as compiler options like +# -std=gnu23 are useful even when is supplied by a non-C23 library, +# not by the compiler: # AC_DEFUN([_AC_C_C89_TEST_GLOBALS], @@ -1447,7 +1449,9 @@ int function_with_unnamed_parameter (int) { return 0; } void c23_noreturn (); -bool use_u8 = !u8"\xFF" == u8'\''x'\''; +/* Test parsing of string and char UTF-8 literals (including hex escapes). + The parens pacify GCC 15. */ +bool use_u8 = (!sizeof u8"\xFF") == (!u8'\''x'\''); bool check_that_bool_works = true | false | !nullptr; #if !true @@ -1483,9 +1487,6 @@ static_assert (0 < -uione); #include constexpr nullptr_t null_pointer = nullptr; -#include -static_assert (__STDC_ENDIAN_LITTLE__ != __STDC_ENDIAN_BIG__); - static typeof (1 + 1L) two () { return 2; } static long int three () { return 3; } ' @@ -1504,6 +1505,7 @@ ac_c_conftest_c23_main=' goto label_at_end_of_block; label_at_end_of_block: } + ok |= !null_pointer; ok |= two != three; ' ]])])