>From 06b20b158ced12812586d94205609435ef29e3db Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Thu, 3 Apr 2014 17:12:39 +0200 Subject: [PATCH 2/3] Fix configure to test more thoroughly for the compiler's capabilities. The old version of the _Static_assert(), variadic macros, FLEXIBLE_ARRAY_MEMBER tests succeeded, even if the compiler warned about the usage of the functionality. That lead to very noisy builds for compilers instructed to warn about nonstandard functionality being used. --- config/c-compiler.m4 | 28 +++++++++++++++++++++++++--- configure | 15 +++++++++++++-- configure.in | 2 +- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/config/c-compiler.m4 b/config/c-compiler.m4 index 4ba3236..5c59d37 100644 --- a/config/c-compiler.m4 +++ b/config/c-compiler.m4 @@ -130,14 +130,18 @@ fi])# PGAC_C_FUNCNAME_SUPPORT # gcc-style compound expressions to be able to wrap the thing into macros. AC_DEFUN([PGAC_C_STATIC_ASSERT], [AC_CACHE_CHECK(for _Static_assert, pgac_cv__static_assert, -[AC_TRY_LINK([], +[ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes +AC_TRY_LINK([], [({ _Static_assert(1, "foo"); })], [pgac_cv__static_assert=yes], [pgac_cv__static_assert=no])]) if test x"$pgac_cv__static_assert" = xyes ; then AC_DEFINE(HAVE__STATIC_ASSERT, 1, [Define to 1 if your compiler understands _Static_assert.]) -fi])# PGAC_C_STATIC_ASSERT +fi +ac_c_werror_flag=$ac_save_c_werror_flag +])# PGAC_C_STATIC_ASSERT @@ -205,12 +209,15 @@ fi])# PGAC_C_BUILTIN_UNREACHABLE # and define HAVE__VA_ARGS if so. AC_DEFUN([PGAC_C_VA_ARGS], [AC_CACHE_CHECK(for __VA_ARGS__, pgac_cv__va_args, -[AC_TRY_COMPILE([#include ], +[ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes +AC_TRY_COMPILE([#include ], [#define debug(...) fprintf(stderr, __VA_ARGS__) debug("%s", "blarg"); ], [pgac_cv__va_args=yes], [pgac_cv__va_args=no])]) +ac_c_werror_flag=$ac_save_c_werror_flag if test x"$pgac_cv__va_args" = xyes ; then AC_DEFINE(HAVE__VA_ARGS, 1, [Define to 1 if your compiler understands __VA_ARGS__ in macros.]) @@ -289,3 +296,18 @@ if test x"$Ac_cachevar" = x"yes"; then fi undefine([Ac_cachevar])dnl ])# PGAC_PROG_CC_LDFLAGS_OPT + + +# PGAC_C_FLEXIBLE_ARRAY_MEMBER +# ------------------------ +# Check whether the compiler supports flexible array members. In +# contrast to the autoconf version we don't accept any warnings +# because using flexible array members in compilers that warn about +# them will just result in a very noisy compile. +AC_DEFUN([PGAC_C_FLEXIBLE_ARRAY_MEMBER], +[ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes +dnl Just use the autoconf test after forcing -Werror +AC_C_FLEXIBLE_ARRAY_MEMBER() +ac_c_werror_flag=$ac_save_c_werror_flag +])# PGAC_C_FLEXIBLE_ARRAY_MEMBER diff --git a/configure b/configure index 122ace7..1f3ed0f 100755 --- a/configure +++ b/configure @@ -9751,6 +9751,8 @@ _ACEOF fi +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes { $as_echo "$as_me:${as_lineno-$LINENO}: checking for flexible array members" >&5 $as_echo_n "checking for flexible array members... " >&6; } @@ -9793,6 +9795,8 @@ $as_echo "#define FLEXIBLE_ARRAY_MEMBER /**/" >>confdefs.h fi +ac_c_werror_flag=$ac_save_c_werror_flag + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for signed types" >&5 $as_echo_n "checking for signed types... " >&6; } if ${pgac_cv_c_signed+:} false; then : @@ -9889,7 +9893,9 @@ $as_echo_n "checking for _Static_assert... " >&6; } if ${pgac_cv__static_assert+:} false; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -9915,6 +9921,8 @@ if test x"$pgac_cv__static_assert" = xyes ; then $as_echo "#define HAVE__STATIC_ASSERT 1" >>confdefs.h fi +ac_c_werror_flag=$ac_save_c_werror_flag + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_types_compatible_p" >&5 $as_echo_n "checking for __builtin_types_compatible_p... " >&6; } if ${pgac_cv__types_compatible+:} false; then : @@ -10011,7 +10019,9 @@ $as_echo_n "checking for __VA_ARGS__... " >&6; } if ${pgac_cv__va_args+:} false; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -10033,6 +10043,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__va_args" >&5 $as_echo "$pgac_cv__va_args" >&6; } +ac_c_werror_flag=$ac_save_c_werror_flag if test x"$pgac_cv__va_args" = xyes ; then $as_echo "#define HAVE__VA_ARGS 1" >>confdefs.h diff --git a/configure.in b/configure.in index 0f3e0cc..d1651f2 100644 --- a/configure.in +++ b/configure.in @@ -1092,7 +1092,7 @@ fi m4_defun([AC_PROG_CC_STDC], []) dnl We don't want that. AC_C_BIGENDIAN PGAC_C_INLINE -AC_C_FLEXIBLE_ARRAY_MEMBER +PGAC_C_FLEXIBLE_ARRAY_MEMBER PGAC_C_SIGNED PGAC_C_FUNCNAME_SUPPORT PGAC_C_STATIC_ASSERT -- 1.8.5.rc2.dirty