Skip to content

Commit 4c8aa8b

Browse files
committed
Fix "quiet inline" configure test for newer clang compilers.
This test used to just define an unused static inline function and check whether that causes a warning. But newer clang versions warn about unused static inline functions when defined inside a .c file, but not when defined in an included header, which is the case we care about. Change the test to cope. Andres Freund
1 parent 3f8c8e3 commit 4c8aa8b

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

config/c-compiler.m4

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,18 @@ fi])# PGAC_C_SIGNED
1919

2020
# PGAC_C_INLINE
2121
# -------------
22-
# Check if the C compiler understands inline functions.
22+
# Check if the C compiler understands inline functions without being
23+
# noisy about unused static inline functions. Some older compilers
24+
# understand inline functions (as tested by AC_C_INLINE) but warn about
25+
# them if they aren't used in a translation unit.
26+
#
27+
# This test used to just define an inline function, but some compilers
28+
# (notably clang) got too smart and now warn about unused static
29+
# inline functions when defined inside a .c file, but not when defined
30+
# in an included header. Since the latter is what we want to use, test
31+
# to see if the warning appears when the function is in a header file.
32+
# Not pretty, but it works.
33+
#
2334
# Defines: inline, PG_USE_INLINE
2435
AC_DEFUN([PGAC_C_INLINE],
2536
[AC_C_INLINE
@@ -28,7 +39,7 @@ AC_CACHE_CHECK([for quiet inline (no complaint if unreferenced)], pgac_cv_c_inli
2839
if test "$ac_cv_c_inline" != no; then
2940
pgac_c_inline_save_werror=$ac_c_werror_flag
3041
ac_c_werror_flag=yes
31-
AC_LINK_IFELSE([AC_LANG_PROGRAM([static inline int fun () {return 0;}],[])],
42+
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include "$srcdir/config/test_quiet_include.h"],[])],
3243
[pgac_cv_c_inline_quietly=yes])
3344
ac_c_werror_flag=$pgac_c_inline_save_werror
3445
fi])

config/test_quiet_include.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/*
2+
* For the raison d'etre of this file, check the comment above the definition
3+
* of the PGAC_C_INLINE macro in config/c-compiler.m4.
4+
*/
5+
static inline int fun () { return 0; }

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9725,7 +9725,7 @@ else
97259725
ac_c_werror_flag=yes
97269726
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
97279727
/* end confdefs.h. */
9728-
static inline int fun () {return 0;}
9728+
#include "$srcdir/config/test_quiet_include.h"
97299729
int
97309730
main ()
97319731
{

0 commit comments

Comments
 (0)