diff options
Diffstat (limited to 'gl/m4/gnulib-common.m4')
| -rw-r--r-- | gl/m4/gnulib-common.m4 | 457 |
1 files changed, 396 insertions, 61 deletions
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4 index cb730449..034dae69 100644 --- a/gl/m4/gnulib-common.m4 +++ b/gl/m4/gnulib-common.m4 | |||
| @@ -1,9 +1,10 @@ | |||
| 1 | # gnulib-common.m4 | 1 | # gnulib-common.m4 |
| 2 | # serial 93 | 2 | # serial 113 |
| 3 | dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. | 3 | dnl Copyright (C) 2007-2025 Free Software Foundation, Inc. |
| 4 | dnl This file is free software; the Free Software Foundation | 4 | dnl This file is free software; the Free Software Foundation |
| 5 | dnl gives unlimited permission to copy and/or distribute it, | 5 | dnl gives unlimited permission to copy and/or distribute it, |
| 6 | dnl with or without modifications, as long as this notice is preserved. | 6 | dnl with or without modifications, as long as this notice is preserved. |
| 7 | dnl This file is offered as-is, without any warranty. | ||
| 7 | 8 | ||
| 8 | AC_PREREQ([2.62]) | 9 | AC_PREREQ([2.62]) |
| 9 | 10 | ||
| @@ -20,43 +21,61 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 20 | [/* Witness that <config.h> has been included. */ | 21 | [/* Witness that <config.h> has been included. */ |
| 21 | #define _GL_CONFIG_H_INCLUDED 1 | 22 | #define _GL_CONFIG_H_INCLUDED 1 |
| 22 | ]) | 23 | ]) |
| 24 | dnl Avoid warnings from gcc -Wtrailing-whitespace. | ||
| 25 | dnl This is a temporary workaround until Autoconf fixes it. | ||
| 26 | dnl Test case: | ||
| 27 | dnl empty1=; empty2=; AC_DEFINE_UNQUOTED([FOO], [$empty1$empty2], [...]) | ||
| 28 | dnl should produce "#define FOO /**/", not "#define FOO ". | ||
| 29 | AH_TOP([#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__ | ||
| 30 | # pragma GCC diagnostic push | ||
| 31 | # pragma GCC diagnostic ignored "-Wtrailing-whitespace" | ||
| 32 | #endif | ||
| 33 | ]) | ||
| 34 | AH_BOTTOM([#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__ | ||
| 35 | # pragma GCC diagnostic pop | ||
| 36 | #endif | ||
| 37 | ]) | ||
| 23 | AH_VERBATIM([_GL_GNUC_PREREQ], | 38 | AH_VERBATIM([_GL_GNUC_PREREQ], |
| 24 | [/* True if the compiler says it groks GNU C version MAJOR.MINOR. */ | 39 | [/* True if the compiler says it groks GNU C version MAJOR.MINOR. |
| 25 | #if defined __GNUC__ && defined __GNUC_MINOR__ | 40 | Except that |
| 41 | - clang groks GNU C 4.2, even on Windows, where it does not define | ||
| 42 | __GNUC__. | ||
| 43 | - The OpenMandriva-modified clang compiler pretends that it groks | ||
| 44 | GNU C version 13.1, but it doesn't: It does not support | ||
| 45 | __attribute__ ((__malloc__ (f, i))), nor does it support | ||
| 46 | __attribute__ ((__warning__ (message))) on a function redeclaration. | ||
| 47 | - Users can make clang lie as well, through the -fgnuc-version option. */ | ||
| 48 | #if defined __GNUC__ && defined __GNUC_MINOR__ && !defined __clang__ | ||
| 26 | # define _GL_GNUC_PREREQ(major, minor) \ | 49 | # define _GL_GNUC_PREREQ(major, minor) \ |
| 27 | ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__)) | 50 | ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__)) |
| 51 | #elif defined __clang__ | ||
| 52 | /* clang really only groks GNU C 4.2. */ | ||
| 53 | # define _GL_GNUC_PREREQ(major, minor) \ | ||
| 54 | ((major) < 4 + ((minor) <= 2)) | ||
| 28 | #else | 55 | #else |
| 29 | # define _GL_GNUC_PREREQ(major, minor) 0 | 56 | # define _GL_GNUC_PREREQ(major, minor) 0 |
| 30 | #endif | 57 | #endif |
| 31 | ]) | 58 | ]) |
| 32 | AH_VERBATIM([_Noreturn], | 59 | AH_VERBATIM([_Noreturn], |
| 33 | [/* The _Noreturn keyword of C11. */ | 60 | [/* The _Noreturn keyword of C11. |
| 61 | Do not use [[noreturn]], because with it the syntax | ||
| 62 | extern _Noreturn void func (...); | ||
| 63 | would not be valid; such a declaration would be valid only with 'extern' | ||
| 64 | and '_Noreturn' swapped, or without the 'extern' keyword. However, some | ||
| 65 | AIX system header files and several gnulib header files use precisely | ||
| 66 | this syntax with 'extern'. So even though C23 deprecates _Noreturn, | ||
| 67 | it is currently more portable to prefer it to [[noreturn]]. | ||
| 68 | |||
| 69 | Also, do not try to work around LLVM bug 59792 (clang 15 or earlier). | ||
| 70 | This rare bug can be worked around by compiling with 'clang -D_Noreturn=', | ||
| 71 | though the workaround may generate many false-alarm warnings. */ | ||
| 34 | #ifndef _Noreturn | 72 | #ifndef _Noreturn |
| 35 | # if (defined __cplusplus \ | 73 | # if ((!defined __cplusplus || defined __clang__) \ |
| 36 | && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ | 74 | && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0))) |
| 37 | || (defined _MSC_VER && 1900 <= _MSC_VER)) \ | ||
| 38 | && 0) | ||
| 39 | /* [[noreturn]] is not practically usable, because with it the syntax | ||
| 40 | extern _Noreturn void func (...); | ||
| 41 | would not be valid; such a declaration would only be valid with 'extern' | ||
| 42 | and '_Noreturn' swapped, or without the 'extern' keyword. However, some | ||
| 43 | AIX system header files and several gnulib header files use precisely | ||
| 44 | this syntax with 'extern'. */ | ||
| 45 | # define _Noreturn [[noreturn]] | ||
| 46 | # elif (defined __clang__ && __clang_major__ < 16 \ | ||
| 47 | && defined _GL_WORK_AROUND_LLVM_BUG_59792) | ||
| 48 | /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around | ||
| 49 | that rare LLVM bug, though you may get many false-alarm warnings. */ | ||
| 50 | # define _Noreturn | ||
| 51 | # elif ((!defined __cplusplus || defined __clang__) \ | ||
| 52 | && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ | ||
| 53 | || (!defined __STRICT_ANSI__ \ | ||
| 54 | && (_GL_GNUC_PREREQ (4, 7) \ | ||
| 55 | || (defined __apple_build_version__ \ | ||
| 56 | ? 6000000 <= __apple_build_version__ \ | ||
| 57 | : 3 < __clang_major__ + (5 <= __clang_minor__)))))) | ||
| 58 | /* _Noreturn works as-is. */ | 75 | /* _Noreturn works as-is. */ |
| 59 | # elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C | 76 | # elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C |
| 77 | /* Prefer __attribute__ ((__noreturn__)) to plain _Noreturn even if the | ||
| 78 | latter works, as 'gcc -std=gnu99 -Wpedantic' warns about _Noreturn. */ | ||
| 60 | # define _Noreturn __attribute__ ((__noreturn__)) | 79 | # define _Noreturn __attribute__ ((__noreturn__)) |
| 61 | # elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) | 80 | # elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) |
| 62 | # define _Noreturn __declspec (noreturn) | 81 | # define _Noreturn __declspec (noreturn) |
| @@ -90,6 +109,9 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 90 | # define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__) | 109 | # define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__) |
| 91 | # else | 110 | # else |
| 92 | # define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr | 111 | # define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr |
| 112 | /* The following lines list the first GCC version that supports the attribute. | ||
| 113 | Although the lines are not used in GCC 5 and later (as GCC 5 introduced | ||
| 114 | __has_attribute support), list GCC versions 5+ anyway for completeness. */ | ||
| 93 | # define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3) | 115 | # define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3) |
| 94 | # define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2) | 116 | # define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2) |
| 95 | # define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3) | 117 | # define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3) |
| @@ -110,12 +132,15 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 110 | # endif | 132 | # endif |
| 111 | # define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1) | 133 | # define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1) |
| 112 | # define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3) | 134 | # define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3) |
| 135 | # define _GL_ATTR_nonnull_if_nonzero _GL_GNUC_PREREQ (15, 1) | ||
| 113 | # define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0) | 136 | # define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0) |
| 114 | # define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3) | 137 | # define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3) |
| 115 | # define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7) | 138 | # define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7) |
| 116 | # define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96) | 139 | # define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96) |
| 140 | # define _GL_ATTR_reproducible _GL_GNUC_PREREQ (15, 1) | ||
| 117 | # define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9) | 141 | # define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9) |
| 118 | # define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0) | 142 | # define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0) |
| 143 | # define _GL_ATTR_unsequenced _GL_GNUC_PREREQ (15, 1) | ||
| 119 | # define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7) | 144 | # define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7) |
| 120 | # define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4) | 145 | # define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4) |
| 121 | # endif | 146 | # endif |
| @@ -131,6 +156,23 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 131 | # define _GL_HAVE___HAS_C_ATTRIBUTE 0 | 156 | # define _GL_HAVE___HAS_C_ATTRIBUTE 0 |
| 132 | #endif | 157 | #endif |
| 133 | 158 | ||
| 159 | /* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...)) | ||
| 160 | syntax, in function declarations. There are two problems here. | ||
| 161 | (Last tested with gcc/g++ 14 and clang/clang++ 18.) | ||
| 162 | |||
| 163 | 1) We want that the _GL_ATTRIBUTE_* can be cumulated on the same declaration | ||
| 164 | in any order. | ||
| 165 | =========================== foo.c = foo.cc =========================== | ||
| 166 | __attribute__ ((__deprecated__)) [[__nodiscard__]] int bar1 (int); | ||
| 167 | [[__nodiscard__]] __attribute__ ((__deprecated__)) int bar2 (int); | ||
| 168 | ====================================================================== | ||
| 169 | This gives a syntax error | ||
| 170 | - in C mode with gcc | ||
| 171 | <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108796>, and | ||
| 172 | - in C++ mode with clang++ version < 16, and | ||
| 173 | - in C++ mode, inside extern "C" {}, still in newer clang++ versions | ||
| 174 | <https://github.com/llvm/llvm-project/issues/101990>. | ||
| 175 | */ | ||
| 134 | /* Define if, in a function declaration, the attributes in bracket syntax | 176 | /* Define if, in a function declaration, the attributes in bracket syntax |
| 135 | [[...]] must come before the attributes in __attribute__((...)) syntax. | 177 | [[...]] must come before the attributes in __attribute__((...)) syntax. |
| 136 | If this is defined, it is best to avoid the bracket syntax, so that the | 178 | If this is defined, it is best to avoid the bracket syntax, so that the |
| @@ -145,6 +187,176 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 145 | # define _GL_BRACKET_BEFORE_ATTRIBUTE 1 | 187 | # define _GL_BRACKET_BEFORE_ATTRIBUTE 1 |
| 146 | # endif | 188 | # endif |
| 147 | #endif | 189 | #endif |
| 190 | /* | ||
| 191 | 2) We want that the _GL_ATTRIBUTE_* can be placed in a declaration | ||
| 192 | - without 'extern', in C as well as in C++, | ||
| 193 | - with 'extern', in C, | ||
| 194 | - with 'extern "C"', in C++ | ||
| 195 | in the same position. That is, we don't want to be forced to use a | ||
| 196 | macro which arranges for the attribute to come before 'extern' in | ||
| 197 | one case and after 'extern' in the other case, because such a macro | ||
| 198 | would make the source code of .h files pretty ugly. | ||
| 199 | =========================== foo.c = foo.cc =========================== | ||
| 200 | #ifdef __cplusplus | ||
| 201 | # define CC "C" | ||
| 202 | #else | ||
| 203 | # define CC | ||
| 204 | #endif | ||
| 205 | |||
| 206 | #define ND [[__nodiscard__]] | ||
| 207 | #define WUR __attribute__((__warn_unused_result__)) | ||
| 208 | |||
| 209 | #ifdef __cplusplus | ||
| 210 | extern "C" { | ||
| 211 | #endif | ||
| 212 | // gcc clang g++ clang++ | ||
| 213 | |||
| 214 | ND int foo (int); | ||
| 215 | int ND foo (int); // warn error warn error | ||
| 216 | int foo ND (int); | ||
| 217 | int foo (int) ND; // warn error warn error | ||
| 218 | |||
| 219 | WUR int foo (int); | ||
| 220 | int WUR foo (int); | ||
| 221 | int fo1 WUR (int); // error error error error | ||
| 222 | int foo (int) WUR; | ||
| 223 | |||
| 224 | #ifdef __cplusplus | ||
| 225 | } | ||
| 226 | #endif | ||
| 227 | |||
| 228 | // gcc clang g++ clang++ | ||
| 229 | |||
| 230 | ND extern CC int foo (int); // error error | ||
| 231 | extern CC ND int foo (int); // error error | ||
| 232 | extern CC int ND foo (int); // warn error warn error | ||
| 233 | extern CC int foo ND (int); | ||
| 234 | extern CC int foo (int) ND; // warn error warn error | ||
| 235 | |||
| 236 | WUR extern CC int foo (int); // warn | ||
| 237 | extern CC WUR int foo (int); | ||
| 238 | extern CC int WUR foo (int); | ||
| 239 | extern CC int foo WUR (int); // error error error error | ||
| 240 | extern CC int foo (int) WUR; | ||
| 241 | |||
| 242 | ND EXTERN_C_FUNC int foo (int); // error error | ||
| 243 | EXTERN_C_FUNC ND int foo (int); | ||
| 244 | EXTERN_C_FUNC int ND foo (int); // warn error warn error | ||
| 245 | EXTERN_C_FUNC int foo ND (int); | ||
| 246 | EXTERN_C_FUNC int foo (int) ND; // warn error warn error | ||
| 247 | |||
| 248 | WUR EXTERN_C_FUNC int foo (int); // warn | ||
| 249 | EXTERN_C_FUNC WUR int foo (int); | ||
| 250 | EXTERN_C_FUNC int WUR foo (int); | ||
| 251 | EXTERN_C_FUNC int fo2 WUR (int); // error error error error | ||
| 252 | EXTERN_C_FUNC int foo (int) WUR; | ||
| 253 | ====================================================================== | ||
| 254 | So, if we insist on using the 'extern' keyword ('extern CC' idiom): | ||
| 255 | * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] | ||
| 256 | in both C and C++, there is one available position: | ||
| 257 | - between the function name and the parameter list. | ||
| 258 | * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax | ||
| 259 | in both C and C++, there are several available positions: | ||
| 260 | - before the return type, | ||
| 261 | - between return type and function name, | ||
| 262 | - at the end of the declaration. | ||
| 263 | * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] in C and to | ||
| 264 | __attribute__((...)) syntax in C++, there is no available position: | ||
| 265 | it would need to come before 'extern' in C but after 'extern "C"' | ||
| 266 | in C++. | ||
| 267 | * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax in C and | ||
| 268 | to bracket syntax [[...]] in C++, there is one available position: | ||
| 269 | - before the return type. | ||
| 270 | Whereas, if we use the 'EXTERN_C_FUNC' idiom, which conditionally | ||
| 271 | omits the 'extern' keyword: | ||
| 272 | * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] | ||
| 273 | in both C and C++, there are two available positions: | ||
| 274 | - before the return type, | ||
| 275 | - between the function name and the parameter list. | ||
| 276 | * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax | ||
| 277 | in both C and C++, there are several available positions: | ||
| 278 | - before the return type, | ||
| 279 | - between return type and function name, | ||
| 280 | - at the end of the declaration. | ||
| 281 | * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] in C and to | ||
| 282 | __attribute__((...)) syntax in C++, there is one available position: | ||
| 283 | - before the return type. | ||
| 284 | * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax in C and | ||
| 285 | to bracket syntax [[...]] in C++, there is one available position: | ||
| 286 | - before the return type. | ||
| 287 | The best choice is therefore to use the 'EXTERN_C_FUNC' idiom and | ||
| 288 | put the attributes before the return type. This works regardless | ||
| 289 | to what the _GL_ATTRIBUTE_* macros expand. | ||
| 290 | */ | ||
| 291 | |||
| 292 | /* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...)) | ||
| 293 | syntax, in static/inline function definitions. | ||
| 294 | |||
| 295 | There are similar constraints as for function declarations. However, here, | ||
| 296 | we cannot omit the storage-class specifier. Therefore, the following rule | ||
| 297 | applies: | ||
| 298 | * The macros | ||
| 299 | _GL_ATTRIBUTE_CONST | ||
| 300 | _GL_ATTRIBUTE_DEPRECATED | ||
| 301 | _GL_ATTRIBUTE_MAYBE_UNUSED | ||
| 302 | _GL_ATTRIBUTE_NODISCARD | ||
| 303 | _GL_ATTRIBUTE_PURE | ||
| 304 | _GL_ATTRIBUTE_REPRODUCIBLE | ||
| 305 | _GL_ATTRIBUTE_UNSEQUENCED | ||
| 306 | which may expand to bracket syntax [[...]], must come first, before the | ||
| 307 | storage-class specifier. | ||
| 308 | * Other _GL_ATTRIBUTE_* macros, that expand to __attribute__((...)) syntax, | ||
| 309 | are better placed between the storage-class specifier and the return | ||
| 310 | type. | ||
| 311 | */ | ||
| 312 | |||
| 313 | /* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...)) | ||
| 314 | syntax, in variable declarations. | ||
| 315 | |||
| 316 | At which position can they be placed? | ||
| 317 | (Last tested with gcc/g++ 14 and clang/clang++ 18.) | ||
| 318 | |||
| 319 | =========================== foo.c = foo.cc =========================== | ||
| 320 | #ifdef __cplusplus | ||
| 321 | # define CC "C" | ||
| 322 | #else | ||
| 323 | # define CC | ||
| 324 | #endif | ||
| 325 | |||
| 326 | #define BD [[__deprecated__]] | ||
| 327 | #define AD __attribute__ ((__deprecated__)) | ||
| 328 | |||
| 329 | // gcc clang g++ clang++ | ||
| 330 | |||
| 331 | BD extern CC int var; // error error | ||
| 332 | extern CC BD int var; // error error | ||
| 333 | extern CC int BD var; // warn error warn error | ||
| 334 | extern CC int var BD; | ||
| 335 | |||
| 336 | AD extern CC int var; // warn | ||
| 337 | extern CC AD int var; | ||
| 338 | extern CC int AD var; | ||
| 339 | extern CC int var AD; | ||
| 340 | |||
| 341 | BD extern CC int z[]; // error error | ||
| 342 | extern CC BD int z[]; // error error | ||
| 343 | extern CC int BD z[]; // warn error warn error | ||
| 344 | extern CC int z1 BD []; | ||
| 345 | extern CC int z[] BD; // warn error error | ||
| 346 | |||
| 347 | AD extern CC int z[]; // warn | ||
| 348 | extern CC AD int z[]; | ||
| 349 | extern CC int AD z[]; | ||
| 350 | extern CC int z2 AD []; // error error error error | ||
| 351 | extern CC int z[] AD; | ||
| 352 | ====================================================================== | ||
| 353 | |||
| 354 | * For non-array variables, the only good position is after the variable name, | ||
| 355 | that is, at the end of the declaration. | ||
| 356 | * For array variables, you will need to distinguish C and C++: | ||
| 357 | - In C, before the 'extern' keyword. | ||
| 358 | - In C++, between the 'extern "C"' and the variable's type. | ||
| 359 | */ | ||
| 148 | ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead. | 360 | ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead. |
| 149 | [ | 361 | [ |
| 150 | /* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function | 362 | /* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function |
| @@ -152,7 +364,7 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 152 | _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied | 364 | _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied |
| 153 | by the Nth argument of the function is the size of the returned memory block. | 365 | by the Nth argument of the function is the size of the returned memory block. |
| 154 | */ | 366 | */ |
| 155 | /* Applies to: function, pointer to function, function types. */ | 367 | /* Applies to: functions, pointer to functions, function types. */ |
| 156 | #ifndef _GL_ATTRIBUTE_ALLOC_SIZE | 368 | #ifndef _GL_ATTRIBUTE_ALLOC_SIZE |
| 157 | # if _GL_HAS_ATTRIBUTE (alloc_size) | 369 | # if _GL_HAS_ATTRIBUTE (alloc_size) |
| 158 | # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) | 370 | # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) |
| @@ -163,7 +375,7 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 163 | 375 | ||
| 164 | /* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the | 376 | /* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the |
| 165 | function and report an error if it cannot do so. */ | 377 | function and report an error if it cannot do so. */ |
| 166 | /* Applies to: function. */ | 378 | /* Applies to: functions. */ |
| 167 | #ifndef _GL_ATTRIBUTE_ALWAYS_INLINE | 379 | #ifndef _GL_ATTRIBUTE_ALWAYS_INLINE |
| 168 | # if _GL_HAS_ATTRIBUTE (always_inline) | 380 | # if _GL_HAS_ATTRIBUTE (always_inline) |
| 169 | # define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) | 381 | # define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) |
| @@ -175,7 +387,7 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 175 | /* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show | 387 | /* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show |
| 176 | in stack traces when debugging. The compiler should omit the function from | 388 | in stack traces when debugging. The compiler should omit the function from |
| 177 | stack traces. */ | 389 | stack traces. */ |
| 178 | /* Applies to: function. */ | 390 | /* Applies to: functions. */ |
| 179 | #ifndef _GL_ATTRIBUTE_ARTIFICIAL | 391 | #ifndef _GL_ATTRIBUTE_ARTIFICIAL |
| 180 | # if _GL_HAS_ATTRIBUTE (artificial) | 392 | # if _GL_HAS_ATTRIBUTE (artificial) |
| 181 | # define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) | 393 | # define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) |
| @@ -201,18 +413,23 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 201 | # endif | 413 | # endif |
| 202 | #endif | 414 | #endif |
| 203 | 415 | ||
| 204 | /* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate | 416 | /* _GL_ATTRIBUTE_CONST declares: |
| 205 | calls to the function with the same arguments. | 417 | It is OK for a compiler to move calls to the function and to omit |
| 206 | This attribute is safe for a function that neither depends on nor affects | 418 | calls to the function if another call has the same arguments or the |
| 207 | observable state, and always returns exactly once - e.g., does not loop | 419 | result is not used. |
| 208 | forever, and does not call longjmp. | 420 | This attribute is safe for a function that neither depends on |
| 209 | (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */ | 421 | nor affects state, and always returns exactly once - |
| 422 | e.g., does not raise an exception, call longjmp, or loop forever. | ||
| 423 | (This attribute is stricter than _GL_ATTRIBUTE_PURE because the | ||
| 424 | function cannot observe state. It is stricter than | ||
| 425 | _GL_ATTRIBUTE_UNSEQUENCED because the function must return exactly | ||
| 426 | once and cannot depend on state addressed by its arguments.) */ | ||
| 210 | /* Applies to: functions. */ | 427 | /* Applies to: functions. */ |
| 211 | #ifndef _GL_ATTRIBUTE_CONST | 428 | #ifndef _GL_ATTRIBUTE_CONST |
| 212 | # if _GL_HAS_ATTRIBUTE (const) | 429 | # if _GL_HAS_ATTRIBUTE (const) |
| 213 | # define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) | 430 | # define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) |
| 214 | # else | 431 | # else |
| 215 | # define _GL_ATTRIBUTE_CONST | 432 | # define _GL_ATTRIBUTE_CONST _GL_ATTRIBUTE_UNSEQUENCED |
| 216 | # endif | 433 | # endif |
| 217 | #endif | 434 | #endif |
| 218 | 435 | ||
| @@ -460,6 +677,17 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 460 | # endif | 677 | # endif |
| 461 | #endif | 678 | #endif |
| 462 | 679 | ||
| 680 | /* _GL_ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) declares that the argument NP | ||
| 681 | (a pointer) must not be NULL if the argument NI (an integer) is != 0. */ | ||
| 682 | /* Applies to: functions. */ | ||
| 683 | #ifndef _GL_ATTRIBUTE_NONNULL_IF_NONZERO | ||
| 684 | # if _GL_HAS_ATTRIBUTE (nonnull_if_nonzero) | ||
| 685 | # define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) __attribute__ ((__nonnull_if_nonzero__ (np, ni))) | ||
| 686 | # else | ||
| 687 | # define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) | ||
| 688 | # endif | ||
| 689 | #endif | ||
| 690 | |||
| 463 | /* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is | 691 | /* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is |
| 464 | not meant to be NUL-terminated. */ | 692 | not meant to be NUL-terminated. */ |
| 465 | /* Applies to: struct/union members and variables that are arrays of element | 693 | /* Applies to: struct/union members and variables that are arrays of element |
| @@ -481,7 +709,7 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 481 | other attributes. */ | 709 | other attributes. */ |
| 482 | #ifndef _GL_ATTRIBUTE_NOTHROW | 710 | #ifndef _GL_ATTRIBUTE_NOTHROW |
| 483 | # if defined __cplusplus | 711 | # if defined __cplusplus |
| 484 | # if _GL_GNUC_PREREQ (2, 8) || __clang_major >= 4 | 712 | # if _GL_GNUC_PREREQ (2, 8) || __clang_major__ >= 4 |
| 485 | # if __cplusplus >= 201103L | 713 | # if __cplusplus >= 201103L |
| 486 | # define _GL_ATTRIBUTE_NOTHROW noexcept (true) | 714 | # define _GL_ATTRIBUTE_NOTHROW noexcept (true) |
| 487 | # else | 715 | # else |
| @@ -505,9 +733,9 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 505 | minimizing the memory required. */ | 733 | minimizing the memory required. */ |
| 506 | /* Applies to: struct members, struct, union, | 734 | /* Applies to: struct members, struct, union, |
| 507 | in C++ also: class. */ | 735 | in C++ also: class. */ |
| 736 | #ifndef _GL_ATTRIBUTE_PACKED | ||
| 508 | /* Oracle Studio 12.6 miscompiles code with __attribute__ ((__packed__)) despite | 737 | /* Oracle Studio 12.6 miscompiles code with __attribute__ ((__packed__)) despite |
| 509 | __has_attribute OK. */ | 738 | __has_attribute OK. */ |
| 510 | #ifndef _GL_ATTRIBUTE_PACKED | ||
| 511 | # if _GL_HAS_ATTRIBUTE (packed) && !defined __SUNPRO_C | 739 | # if _GL_HAS_ATTRIBUTE (packed) && !defined __SUNPRO_C |
| 512 | # define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) | 740 | # define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) |
| 513 | # else | 741 | # else |
| @@ -515,18 +743,51 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 515 | # endif | 743 | # endif |
| 516 | #endif | 744 | #endif |
| 517 | 745 | ||
| 518 | /* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate | 746 | /* _GL_ATTRIBUTE_PURE declares: |
| 519 | calls to the function with the same arguments if observable state is not | 747 | It is OK for a compiler to move calls to the function and to omit |
| 520 | changed between calls. | 748 | calls to the function if another call has the same arguments or the |
| 521 | This attribute is safe for a function that does not affect | 749 | result is not used, and if observable state is the same. |
| 522 | observable state, and always returns exactly once. | 750 | This attribute is safe for a function that does not affect observable state |
| 523 | (This attribute is looser than _GL_ATTRIBUTE_CONST.) */ | 751 | and always returns exactly once. |
| 752 | (This attribute is looser than _GL_ATTRIBUTE_CONST because the function | ||
| 753 | can depend on observable state. It is stricter than | ||
| 754 | _GL_ATTRIBUTE_REPRODUCIBLE because the function must return exactly | ||
| 755 | once and cannot affect state addressed by its arguments.) */ | ||
| 524 | /* Applies to: functions. */ | 756 | /* Applies to: functions. */ |
| 525 | #ifndef _GL_ATTRIBUTE_PURE | 757 | #ifndef _GL_ATTRIBUTE_PURE |
| 526 | # if _GL_HAS_ATTRIBUTE (pure) | 758 | # if _GL_HAS_ATTRIBUTE (pure) |
| 527 | # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) | 759 | # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) |
| 528 | # else | 760 | # else |
| 529 | # define _GL_ATTRIBUTE_PURE | 761 | # define _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_REPRODUCIBLE |
| 762 | # endif | ||
| 763 | #endif | ||
| 764 | |||
| 765 | /* _GL_ATTRIBUTE_REPRODUCIBLE declares: | ||
| 766 | It is OK for a compiler to move calls to the function and to omit duplicate | ||
| 767 | calls to the function with the same arguments, so long as the state | ||
| 768 | addressed by its arguments is the same and is updated in time for | ||
| 769 | the rest of the program. | ||
| 770 | This attribute is safe for a function that is effectless and idempotent; see | ||
| 771 | ISO C 23 § 6.7.12.7 for a definition of these terms. | ||
| 772 | (This attribute is looser than _GL_ATTRIBUTE_UNSEQUENCED because | ||
| 773 | the function need not be stateless and idempotent. It is looser | ||
| 774 | than _GL_ATTRIBUTE_PURE because the function need not return | ||
| 775 | exactly once and can affect state addressed by its arguments.) | ||
| 776 | See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and | ||
| 777 | <https://stackoverflow.com/questions/76847905/>. | ||
| 778 | ATTENTION! Efforts are underway to change the meaning of this attribute. | ||
| 779 | See <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3424.htm>. */ | ||
| 780 | /* Applies to: functions, pointer to functions, function types. */ | ||
| 781 | #ifndef _GL_ATTRIBUTE_REPRODUCIBLE | ||
| 782 | /* This may be revisited when gcc and clang support [[reproducible]] or possibly | ||
| 783 | __attribute__ ((__reproducible__)). */ | ||
| 784 | # ifndef _GL_BRACKET_BEFORE_ATTRIBUTE | ||
| 785 | # if _GL_HAS_ATTRIBUTE (reproducible) | ||
| 786 | # define _GL_ATTRIBUTE_REPRODUCIBLE [[reproducible]] | ||
| 787 | # endif | ||
| 788 | # endif | ||
| 789 | # ifndef _GL_ATTRIBUTE_REPRODUCIBLE | ||
| 790 | # define _GL_ATTRIBUTE_REPRODUCIBLE | ||
| 530 | # endif | 791 | # endif |
| 531 | #endif | 792 | #endif |
| 532 | 793 | ||
| @@ -554,6 +815,35 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 554 | # endif | 815 | # endif |
| 555 | #endif | 816 | #endif |
| 556 | 817 | ||
| 818 | /* _GL_ATTRIBUTE_UNSEQUENCED declares: | ||
| 819 | It is OK for a compiler to move calls to the function and to omit duplicate | ||
| 820 | calls to the function with the same arguments, so long as the state | ||
| 821 | addressed by its arguments is the same. | ||
| 822 | This attribute is safe for a function that is effectless, idempotent, | ||
| 823 | stateless, and independent; see ISO C 23 § 6.7.12.7 for a definition of | ||
| 824 | these terms. | ||
| 825 | (This attribute is stricter than _GL_ATTRIBUTE_REPRODUCIBLE because | ||
| 826 | the function must be stateless and independent. It is looser than | ||
| 827 | _GL_ATTRIBUTE_CONST because the function need not return exactly | ||
| 828 | once and can depend on state addressed by its arguments.) | ||
| 829 | See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and | ||
| 830 | <https://stackoverflow.com/questions/76847905/>. | ||
| 831 | ATTENTION! Efforts are underway to change the meaning of this attribute. | ||
| 832 | See <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3424.htm>. */ | ||
| 833 | /* Applies to: functions, pointer to functions, function types. */ | ||
| 834 | #ifndef _GL_ATTRIBUTE_UNSEQUENCED | ||
| 835 | /* This may be revisited when gcc and clang support [[unsequenced]] or possibly | ||
| 836 | __attribute__ ((__unsequenced__)). */ | ||
| 837 | # ifndef _GL_BRACKET_BEFORE_ATTRIBUTE | ||
| 838 | # if _GL_HAS_ATTRIBUTE (unsequenced) | ||
| 839 | # define _GL_ATTRIBUTE_UNSEQUENCED [[unsequenced]] | ||
| 840 | # endif | ||
| 841 | # endif | ||
| 842 | # ifndef _GL_ATTRIBUTE_UNSEQUENCED | ||
| 843 | # define _GL_ATTRIBUTE_UNSEQUENCED | ||
| 844 | # endif | ||
| 845 | #endif | ||
| 846 | |||
| 557 | /* A helper macro. Don't use it directly. */ | 847 | /* A helper macro. Don't use it directly. */ |
| 558 | #ifndef _GL_ATTRIBUTE_UNUSED | 848 | #ifndef _GL_ATTRIBUTE_UNUSED |
| 559 | # if _GL_HAS_ATTRIBUTE (unused) | 849 | # if _GL_HAS_ATTRIBUTE (unused) |
| @@ -578,6 +868,35 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 578 | # define _GL_UNUSED_LABEL | 868 | # define _GL_UNUSED_LABEL |
| 579 | # endif | 869 | # endif |
| 580 | #endif | 870 | #endif |
| 871 | |||
| 872 | /* The following attributes enable detection of multithread-safety problems | ||
| 873 | and resource leaks at compile-time, by clang ≥ 15, when the warning option | ||
| 874 | -Wthread-safety is enabled. For usage, see | ||
| 875 | <https://clang.llvm.org/docs/ThreadSafetyAnalysis.html>. */ | ||
| 876 | #ifndef _GL_ATTRIBUTE_CAPABILITY_TYPE | ||
| 877 | # if __clang_major__ >= 15 | ||
| 878 | # define _GL_ATTRIBUTE_CAPABILITY_TYPE(concept) \ | ||
| 879 | __attribute__ ((__capability__ (concept))) | ||
| 880 | # else | ||
| 881 | # define _GL_ATTRIBUTE_CAPABILITY_TYPE(concept) | ||
| 882 | # endif | ||
| 883 | #endif | ||
| 884 | #ifndef _GL_ATTRIBUTE_ACQUIRE_CAPABILITY | ||
| 885 | # if __clang_major__ >= 15 | ||
| 886 | # define _GL_ATTRIBUTE_ACQUIRE_CAPABILITY(resource) \ | ||
| 887 | __attribute__ ((__acquire_capability__ (resource))) | ||
| 888 | # else | ||
| 889 | # define _GL_ATTRIBUTE_ACQUIRE_CAPABILITY(resource) | ||
| 890 | # endif | ||
| 891 | #endif | ||
| 892 | #ifndef _GL_ATTRIBUTE_RELEASE_CAPABILITY | ||
| 893 | # if __clang_major__ >= 15 | ||
| 894 | # define _GL_ATTRIBUTE_RELEASE_CAPABILITY(resource) \ | ||
| 895 | __attribute__ ((__release_capability__ (resource))) | ||
| 896 | # else | ||
| 897 | # define _GL_ATTRIBUTE_RELEASE_CAPABILITY(resource) | ||
| 898 | # endif | ||
| 899 | #endif | ||
| 581 | ]) | 900 | ]) |
| 582 | AH_VERBATIM([c_linkage], | 901 | AH_VERBATIM([c_linkage], |
| 583 | [/* In C++, there is the concept of "language linkage", that encompasses | 902 | [/* In C++, there is the concept of "language linkage", that encompasses |
| @@ -628,8 +947,8 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
| 628 | -1 if n1 < n2 | 947 | -1 if n1 < n2 |
| 629 | The naïve code (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) produces a conditional | 948 | The naïve code (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) produces a conditional |
| 630 | jump with nearly all GCC versions up to GCC 10. | 949 | jump with nearly all GCC versions up to GCC 10. |
| 631 | This variant (n1 < n2 ? -1 : n1 > n2) produces a conditional with many | 950 | This variant (n1 < n2 ? -1 : n1 > n2) produces a conditional jump with |
| 632 | GCC versions up to GCC 9. | 951 | many GCC versions up to GCC 9. |
| 633 | The better code (n1 > n2) - (n1 < n2) from Hacker's Delight § 2-9 | 952 | The better code (n1 > n2) - (n1 < n2) from Hacker's Delight § 2-9 |
| 634 | avoids conditional jumps in all GCC versions >= 3.4. */ | 953 | avoids conditional jumps in all GCC versions >= 3.4. */ |
| 635 | #define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2))) | 954 | #define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2))) |
| @@ -1006,7 +1325,7 @@ AC_DEFUN([gl_CC_ALLOW_WARNINGS], | |||
| 1006 | AC_REQUIRE([AC_PROG_CC]) | 1325 | AC_REQUIRE([AC_PROG_CC]) |
| 1007 | AC_CACHE_CHECK([for C compiler option to allow warnings], | 1326 | AC_CACHE_CHECK([for C compiler option to allow warnings], |
| 1008 | [gl_cv_cc_wallow], | 1327 | [gl_cv_cc_wallow], |
| 1009 | [rm -f conftest* | 1328 | [rm -fr conftest* |
| 1010 | echo 'int dummy;' > conftest.c | 1329 | echo 'int dummy;' > conftest.c |
| 1011 | AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null | 1330 | AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null |
| 1012 | AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null | 1331 | AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null |
| @@ -1019,7 +1338,7 @@ AC_DEFUN([gl_CC_ALLOW_WARNINGS], | |||
| 1019 | else | 1338 | else |
| 1020 | gl_cv_cc_wallow=none | 1339 | gl_cv_cc_wallow=none |
| 1021 | fi | 1340 | fi |
| 1022 | rm -f conftest* | 1341 | rm -fr conftest* |
| 1023 | ]) | 1342 | ]) |
| 1024 | case "$gl_cv_cc_wallow" in | 1343 | case "$gl_cv_cc_wallow" in |
| 1025 | none) GL_CFLAG_ALLOW_WARNINGS='' ;; | 1344 | none) GL_CFLAG_ALLOW_WARNINGS='' ;; |
| @@ -1037,7 +1356,7 @@ AC_DEFUN([gl_CXX_ALLOW_WARNINGS], | |||
| 1037 | if test -n "$CXX" && test "$CXX" != no; then | 1356 | if test -n "$CXX" && test "$CXX" != no; then |
| 1038 | AC_CACHE_CHECK([for C++ compiler option to allow warnings], | 1357 | AC_CACHE_CHECK([for C++ compiler option to allow warnings], |
| 1039 | [gl_cv_cxx_wallow], | 1358 | [gl_cv_cxx_wallow], |
| 1040 | [rm -f conftest* | 1359 | [rm -fr conftest* |
| 1041 | echo 'int dummy;' > conftest.cc | 1360 | echo 'int dummy;' > conftest.cc |
| 1042 | AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null | 1361 | AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null |
| 1043 | AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null | 1362 | AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null |
| @@ -1050,7 +1369,7 @@ AC_DEFUN([gl_CXX_ALLOW_WARNINGS], | |||
| 1050 | else | 1369 | else |
| 1051 | gl_cv_cxx_wallow=none | 1370 | gl_cv_cxx_wallow=none |
| 1052 | fi | 1371 | fi |
| 1053 | rm -f conftest* | 1372 | rm -fr conftest* |
| 1054 | ]) | 1373 | ]) |
| 1055 | case "$gl_cv_cxx_wallow" in | 1374 | case "$gl_cv_cxx_wallow" in |
| 1056 | none) GL_CXXFLAG_ALLOW_WARNINGS='' ;; | 1375 | none) GL_CXXFLAG_ALLOW_WARNINGS='' ;; |
| @@ -1087,11 +1406,12 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS], | |||
| 1087 | dnl -Wno-type-limits >= 4.3 >= 3.9 | 1406 | dnl -Wno-type-limits >= 4.3 >= 3.9 |
| 1088 | dnl -Wno-undef >= 3 >= 3.9 | 1407 | dnl -Wno-undef >= 3 >= 3.9 |
| 1089 | dnl -Wno-unsuffixed-float-constants >= 4.5 | 1408 | dnl -Wno-unsuffixed-float-constants >= 4.5 |
| 1409 | dnl -Wno-unused-const-variable >= 4.4 >= 3.9 | ||
| 1090 | dnl -Wno-unused-function >= 3 >= 3.9 | 1410 | dnl -Wno-unused-function >= 3 >= 3.9 |
| 1091 | dnl -Wno-unused-parameter >= 3 >= 3.9 | 1411 | dnl -Wno-unused-parameter >= 3 >= 3.9 |
| 1092 | dnl | 1412 | dnl |
| 1093 | cat > conftest.c <<\EOF | 1413 | cat > conftest.c <<\EOF |
| 1094 | #if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3) | 1414 | #if (__GNUC__ >= 3 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) |
| 1095 | -Wno-cast-qual | 1415 | -Wno-cast-qual |
| 1096 | -Wno-conversion | 1416 | -Wno-conversion |
| 1097 | -Wno-float-equal | 1417 | -Wno-float-equal |
| @@ -1100,23 +1420,26 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS], | |||
| 1100 | -Wno-unused-function | 1420 | -Wno-unused-function |
| 1101 | -Wno-unused-parameter | 1421 | -Wno-unused-parameter |
| 1102 | #endif | 1422 | #endif |
| 1103 | #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) | 1423 | #if (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) |
| 1104 | -Wno-float-conversion | 1424 | -Wno-float-conversion |
| 1105 | #endif | 1425 | #endif |
| 1106 | #if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3) | 1426 | #if (__GNUC__ >= 7 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) |
| 1107 | -Wimplicit-fallthrough | 1427 | -Wimplicit-fallthrough |
| 1108 | #endif | 1428 | #endif |
| 1109 | #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) | 1429 | #if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) |
| 1110 | -Wno-pedantic | 1430 | -Wno-pedantic |
| 1111 | #endif | 1431 | #endif |
| 1112 | #if 3 < __clang_major__ + (9 <= __clang_minor__) | 1432 | #if 3 < __clang_major__ + (9 <= __clang_minor__) |
| 1113 | -Wno-tautological-constant-out-of-range-compare | 1433 | -Wno-tautological-constant-out-of-range-compare |
| 1114 | #endif | 1434 | #endif |
| 1115 | #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) | 1435 | #if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) |
| 1116 | -Wno-sign-conversion | 1436 | -Wno-sign-conversion |
| 1117 | -Wno-type-limits | 1437 | -Wno-type-limits |
| 1118 | #endif | 1438 | #endif |
| 1119 | #if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4 | 1439 | #if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) |
| 1440 | -Wno-unused-const-variable | ||
| 1441 | #endif | ||
| 1442 | #if (__GNUC__ + (__GNUC_MINOR__ >= 5) > 4 && !defined __clang__) | ||
| 1120 | -Wno-unsuffixed-float-constants | 1443 | -Wno-unsuffixed-float-constants |
| 1121 | #endif | 1444 | #endif |
| 1122 | EOF | 1445 | EOF |
| @@ -1240,13 +1563,25 @@ AC_DEFUN([gl_CHECK_FUNCS_CASE_FOR_MACOS], | |||
| 1240 | if test $[ac_cv_func_][$1] = yes; then | 1563 | if test $[ac_cv_func_][$1] = yes; then |
| 1241 | [gl_cv_onwards_func_][$1]=yes | 1564 | [gl_cv_onwards_func_][$1]=yes |
| 1242 | else | 1565 | else |
| 1566 | dnl This is a bit complicated, because here we need the behaviour | ||
| 1567 | dnl of AC_CHECK_DECL before the | ||
| 1568 | dnl commit e1bbc9b93cdff61d70719c224b37970e065008bb (2025-05-26). | ||
| 1569 | [ac_cv_have_decl_][$1][_saved]="$[ac_cv_have_decl_][$1]" | ||
| 1243 | unset [ac_cv_have_decl_][$1] | 1570 | unset [ac_cv_have_decl_][$1] |
| 1571 | ac_c_future_darwin_options_saved="$ac_c_future_darwin_options" | ||
| 1572 | ac_cxx_future_darwin_options_saved="$ac_cxx_future_darwin_options" | ||
| 1573 | ac_c_future_darwin_options= | ||
| 1574 | ac_cxx_future_darwin_options= | ||
| 1244 | AC_CHECK_DECL([$1], , , [$2]) | 1575 | AC_CHECK_DECL([$1], , , [$2]) |
| 1576 | ac_c_future_darwin_options="$ac_c_future_darwin_options_saved" | ||
| 1577 | ac_cxx_future_darwin_options="$ac_cxx_future_darwin_options_saved" | ||
| 1245 | if test $[ac_cv_have_decl_][$1] = yes; then | 1578 | if test $[ac_cv_have_decl_][$1] = yes; then |
| 1246 | [gl_cv_onwards_func_][$1]='future OS version' | 1579 | [gl_cv_onwards_func_][$1]='future OS version' |
| 1247 | else | 1580 | else |
| 1248 | [gl_cv_onwards_func_][$1]=no | 1581 | [gl_cv_onwards_func_][$1]=no |
| 1249 | fi | 1582 | fi |
| 1583 | [ac_cv_have_decl_][$1]="$[ac_cv_have_decl_][$1][_saved]" | ||
| 1584 | unset [ac_cv_have_decl_][$1][_saved] | ||
| 1250 | fi | 1585 | fi |
| 1251 | else | 1586 | else |
| 1252 | AC_CHECK_FUNC([$1]) | 1587 | AC_CHECK_FUNC([$1]) |
| @@ -1299,7 +1634,7 @@ dnl | |||
| 1299 | dnl This macro sets two variables: | 1634 | dnl This macro sets two variables: |
| 1300 | dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version" | 1635 | dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version" |
| 1301 | dnl - ac_cv_func_<func> to yes / no / no | 1636 | dnl - ac_cv_func_<func> to yes / no / no |
| 1302 | dnl The first variable allows to distinguish all three cases. | 1637 | dnl The first variable allows distinguishing all three cases. |
| 1303 | dnl The second variable is set, so that an invocation | 1638 | dnl The second variable is set, so that an invocation |
| 1304 | dnl gl_CHECK_FUNCS_ANDROID([func], [[#include <foo.h>]]) | 1639 | dnl gl_CHECK_FUNCS_ANDROID([func], [[#include <foo.h>]]) |
| 1305 | dnl can be used as a drop-in replacement for | 1640 | dnl can be used as a drop-in replacement for |
| @@ -1352,7 +1687,7 @@ dnl | |||
| 1352 | dnl This macro sets two variables: | 1687 | dnl This macro sets two variables: |
| 1353 | dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version" | 1688 | dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version" |
| 1354 | dnl - ac_cv_func_<func> to yes / no / no | 1689 | dnl - ac_cv_func_<func> to yes / no / no |
| 1355 | dnl The first variable allows to distinguish all three cases. | 1690 | dnl The first variable allows distinguishing all three cases. |
| 1356 | dnl The second variable is set, so that an invocation | 1691 | dnl The second variable is set, so that an invocation |
| 1357 | dnl gl_CHECK_FUNCS_MACOS([func], [[#include <foo.h>]]) | 1692 | dnl gl_CHECK_FUNCS_MACOS([func], [[#include <foo.h>]]) |
| 1358 | dnl can be used as a drop-in replacement for | 1693 | dnl can be used as a drop-in replacement for |
