From 2fabd703401f376d53cf2c792a8f7ddcb4732a8c Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Tue, 17 Mar 2015 13:16:05 +1100 Subject: [PATCH] configure: check if compiler supports -Werror=vla Check if the compiler supports -Werror=vla before using it. -Wvla was introduced with GCC 4.3 and is not present in 4.2. Fixes the build on OpenBSD. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89433 Signed-off-by: Jonathan Gray --- configure.ac | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 8804f4c..5179b7d 100644 --- a/configure.ac +++ b/configure.ac @@ -278,10 +278,21 @@ if test "x$GCC" = xyes; then # - non-Linux/Posix OpenGL portions needs to build on MSVC 2013 (which # supports most of C99) # - the rest has no compiler compiler restrictions - MSVC2013_COMPAT_CFLAGS="-Werror=vla -Werror=pointer-arith" - MSVC2013_COMPAT_CXXFLAGS="-Werror=vla -Werror=pointer-arith" + MSVC2013_COMPAT_CFLAGS="-Werror=pointer-arith" + MSVC2013_COMPAT_CXXFLAGS="-Werror=pointer-arith" MSVC2008_COMPAT_CFLAGS="$MSVC2013_COMPAT_CFLAGS -Werror=declaration-after-statement" MSVC2008_COMPAT_CXXFLAGS="$MSVC2013_COMPAT_CXXFLAGS" + + # Enable -Werror=vla if compiler supports it + save_CFLAGS="$CFLAGS" + AC_MSG_CHECKING([whether $CC supports -Werror=vla]) + CFLAGS="$CFLAGS -Werror=vla" + AC_LINK_IFELSE([AC_LANG_PROGRAM()], + [MSVC2013_COMPAT_CFLAGS="$MSVC2013_COMPAT_CFLAGS -Werror=vla"; + MSVC2013_COMPAT_CXXFLAGS="$MSVC2013_COMPAT_CXXFLAGS -Werror=vla"; + AC_MSG_RESULT([yes])], + AC_MSG_RESULT([no])); + CFLAGS=$save_CFLAGS fi if test "x$GXX" = xyes; then CXXFLAGS="$CXXFLAGS -Wall" -- 2.3.0