]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Further improvements for C23 tests
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 17 Nov 2024 17:00:49 +0000 (09:00 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 17 Nov 2024 17:17:24 +0000 (09:17 -0800)
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

index 40ed1175e63c9a13a64a8444c7af565e1c9c5ac8..83a13b7281e02daa416fd04465329d594ecde3f1 100644 (file)
@@ -1118,7 +1118,9 @@ fi[]dnl
 #     <iso646.h> <stdbool.h> <stdint.h>
 # C11 adds:
 #     <stdalign.h> <stdnoreturn.h>
-# C23 adds:
+# C23 adds the following.  Do not test it, though, as compiler options like
+# -std=gnu23 are useful even when <stdbit.h> is supplied by a non-C23 library,
+# not by the compiler:
 #     <stdbit.h>
 
 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 <stddef.h>
 constexpr nullptr_t null_pointer = nullptr;
 
-#include <stdbit.h>
-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;
 '
 ]])])