diff options
author | Bruno Haible <bruno@clisp.org> | 2022-09-20 23:31:19 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2022-09-20 23:31:19 +0200 |
commit | 5210250cccb00c9906a96d27212016ee578e8f29 (patch) | |
tree | aa24a4c719624567bd712f07e36a0954762b8b84 | |
parent | 101b00c5aabc8b99c301a818da20f2cefa2ce176 (diff) | |
download | gnulib-5210250cccb00c9906a96d27212016ee578e8f29.tar.gz |
snippet/warn-on-use: Don't cause wrong AC_CHECK_DECL results with clang.
* m4/warn-on-use.m4 (gl_WARN_ON_USE_PREPARE): Use the clang command-line
option that disables implicit built-in function declarations in clang.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | m4/warn-on-use.m4 | 21 |
2 files changed, 23 insertions, 4 deletions
@@ -1,3 +1,9 @@ +2022-09-20 Bruno Haible <bruno@clisp.org> + + snippet/warn-on-use: Don't cause wrong AC_CHECK_DECL results with clang. + * m4/warn-on-use.m4 (gl_WARN_ON_USE_PREPARE): Use the clang command-line + option that disables implicit built-in function declarations in clang. + 2022-09-19 Bruno Haible <bruno@clisp.org> stdbool, stdbool-c99 tests: Fix compilation error with clang/MSVC. diff --git a/m4/warn-on-use.m4 b/m4/warn-on-use.m4 index d43355ab17..a81731f31c 100644 --- a/m4/warn-on-use.m4 +++ b/m4/warn-on-use.m4 @@ -1,4 +1,4 @@ -# warn-on-use.m4 serial 9 +# warn-on-use.m4 serial 10 dnl Copyright (C) 2010-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -32,17 +32,30 @@ AC_DEFUN([gl_WARN_ON_USE_PREPARE], undefining macros.])])dnl for gl_func in m4_flatten([$2]); do AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl + dnl As a workaround to implicit built-in function declarations in + dnl clang (e.g. strndup), reference ac_compile_for_check_decl instead + dnl of ac_compile. If, for whatever reason, the override of AC_PROG_CC + dnl in zzgnulib.m4 is inactive, use the original ac_compile. + ac_save_ac_compile="$ac_compile" + if test -n "$ac_compile_for_check_decl"; then + ac_compile="$ac_compile_for_check_decl" + fi AC_CACHE_CHECK([whether $gl_func is declared without a macro], [gl_Symbol], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1], [[#undef $gl_func (void) $gl_func;]])], [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])]) + ac_compile="$ac_save_ac_compile" AS_VAR_IF([gl_Symbol], [yes], [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) - dnl shortcut - if the raw declaration exists, then set a cache - dnl variable to allow skipping any later AC_CHECK_DECL efforts - eval ac_cv_have_decl_$gl_func=yes]) + dnl Shortcut for an AC_CHECK_DECL invocation that may come later: + dnl If the raw declaration exists with the given includes, then + dnl AC_CHECK_DECL with its many includes would see it as well. + dnl So, set a cache variable to allow skipping any later + dnl AC_CHECK_DECL invocation for $gl_func. + eval "ac_cv_have_decl_$gl_func=yes" + ]) AS_VAR_POPDEF([gl_Symbol])dnl done ]) |