- AC_SUBST([WERROR_CFLAGS])
- gl_WARN_ADD([-Wall])
- gl_WARN_ADD([-Wextra -Wno-sign-compare])
- gl_WARN_ADD([-Wcast-align])
- gl_WARN_ADD([-Wcast-qual])
- gl_WARN_ADD([-Wformat])
- gl_WARN_ADD([-Wpointer-arith])
- gl_WARN_ADD([-Wwrite-strings])
- AC_SUBST([WARN_CXXFLAGS], [$WARN_CFLAGS])
- # The following warnings are not suitable for C++.
- gl_WARN_ADD([-Wbad-function-cast])
- gl_WARN_ADD([-Wmissing-declarations])
- gl_WARN_ADD([-Wmissing-prototypes])
- gl_WARN_ADD([-Wshadow])
- gl_WARN_ADD([-Wstrict-prototypes])
- AC_SUBST([WARN_CFLAGS])
- AC_DEFINE([lint], 1, [Define to 1 if the compiler is checking for lint.])
+
+ # Warnings for the test suite, and maybe for bison if GCC is modern
+ # enough.
+ gl_WARN_ADD([-Wmissing-declarations], [WARN_CFLAGS_TEST])
+ gl_WARN_ADD([-Wmissing-prototypes], [WARN_CFLAGS_TEST])
+ test $lv_cv_gcc_pragma_push_works = yes &&
+ AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
+
+ # Warnings for the test suite only.
+ for i in $warn_tests;
+ do
+ gl_WARN_ADD([$i], [WARN_CFLAGS_TEST])
+ done
+ CFLAGS=$save_CFLAGS
+ AC_LANG_POP([C])
+
+ AC_LANG_PUSH([C++])
+ save_CXXFLAGS=$CXXFLAGS
+ gl_WARN_ADD([-Werror=unknown-warning-option], [CXXFLAGS])
+ for i in $warn_common $warn_cxx;
+ do
+ gl_WARN_ADD([$i], [WARN_CXXFLAGS])
+ done
+ gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
+ [AC_LANG_PROGRAM([], [nullptr])])
+ gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
+ # Warnings for the test suite only.
+ for i in $warn_tests;
+ do
+ gl_WARN_ADD([$i], [WARN_CXXFLAGS_TEST])
+ done
+ # Clang++ 3.2+ reject C code generated by Flex.
+ gl_WARN_ADD([-Wno-null-conversion], [FLEX_SCANNER_CXXFLAGS])
+ # So does G++ 4.8...
+ gl_WARN_ADD([-Wno-sign-compare], [FLEX_SCANNER_CXXFLAGS])
+ # ... possiby in std=c++11 mode.
+ gl_WARN_ADD([-Wno-zero-as-null-pointer-constant], [FLEX_SCANNER_CXXFLAGS])
+ CXXFLAGS=$save_CXXFLAGS
+ AC_LANG_POP([C++])