aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2014-05-02 15:30:29 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2014-05-02 15:30:29 -0400
commit693a82dddf9657eb4cda2293acc219ca79066ab5 (patch)
treedbbcaa399c54f77443ebd34ef643b57b07ea44fb
parente31193d495f668b2e2e98db290f36af83b6c70e8 (diff)
downloadpostgresql-693a82dddf9657eb4cda2293acc219ca79066ab5.tar.gz
postgresql-693a82dddf9657eb4cda2293acc219ca79066ab5.zip
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
-rw-r--r--config/c-compiler.m415
-rw-r--r--config/test_quiet_include.h5
-rwxr-xr-xconfigure2
3 files changed, 19 insertions, 3 deletions
diff --git a/config/c-compiler.m4 b/config/c-compiler.m4
index 4ba3236ef46..802f5539d34 100644
--- a/config/c-compiler.m4
+++ b/config/c-compiler.m4
@@ -19,7 +19,18 @@ fi])# PGAC_C_SIGNED
# PGAC_C_INLINE
# -------------
-# Check if the C compiler understands inline functions.
+# Check if the C compiler understands inline functions without being
+# noisy about unused static inline functions. Some older compilers
+# understand inline functions (as tested by AC_C_INLINE) but warn about
+# them if they aren't used in a translation unit.
+#
+# This test used to just define an inline function, but some compilers
+# (notably clang) got too smart and now warn about unused static
+# inline functions when defined inside a .c file, but not when defined
+# in an included header. Since the latter is what we want to use, test
+# to see if the warning appears when the function is in a header file.
+# Not pretty, but it works.
+#
# Defines: inline, PG_USE_INLINE
AC_DEFUN([PGAC_C_INLINE],
[AC_C_INLINE
@@ -28,7 +39,7 @@ AC_CACHE_CHECK([for quiet inline (no complaint if unreferenced)], pgac_cv_c_inli
if test "$ac_cv_c_inline" != no; then
pgac_c_inline_save_werror=$ac_c_werror_flag
ac_c_werror_flag=yes
- AC_LINK_IFELSE([AC_LANG_PROGRAM([static inline int fun () {return 0;}],[])],
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include "$srcdir/config/test_quiet_include.h"],[])],
[pgac_cv_c_inline_quietly=yes])
ac_c_werror_flag=$pgac_c_inline_save_werror
fi])
diff --git a/config/test_quiet_include.h b/config/test_quiet_include.h
new file mode 100644
index 00000000000..eb0515ede78
--- /dev/null
+++ b/config/test_quiet_include.h
@@ -0,0 +1,5 @@
+/*
+ * For the raison d'etre of this file, check the comment above the definition
+ * of the PGAC_C_INLINE macro in config/c-compiler.m4.
+ */
+static inline int fun () { return 0; }
diff --git a/configure b/configure
index bf8a0d46b4f..c5c1cb0c202 100755
--- a/configure
+++ b/configure
@@ -15345,7 +15345,7 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-static inline int fun () {return 0;}
+#include "$srcdir/config/test_quiet_include.h"
int
main ()
{