dnl it enables extra GCC specific warnings.
AC_DEFUN([SIM_AC_OPTION_WARNINGS],
[
-# NOTE: Don't add -Wall or -Wunused, they both include
-# -Wunused-parameter which reports bogus warnings.
-# NOTE: If you add to this list, remember to update
-# gdb/doc/gdbint.texinfo.
-build_warnings="-Wimplicit -Wreturn-type -Wcomment -Wtrigraphs \
--Wformat -Wparentheses -Wpointer-arith"
-# GCC supports -Wuninitialized only with -O or -On, n != 0.
-if test x${CFLAGS+set} = xset; then
- case "${CFLAGS}" in
- *"-O0"* ) ;;
- *"-O"* )
- build_warnings="${build_warnings} -Wuninitialized"
- ;;
- esac
-else
- build_warnings="${build_warnings} -Wuninitialized"
+AC_ARG_ENABLE(werror,
+ AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
+ [case "${enableval}" in
+ yes | y) ERROR_ON_WARNING="yes" ;;
+ no | n) ERROR_ON_WARNING="no" ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
+ esac])
+
+# Enable -Werror by default when using gcc
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+ ERROR_ON_WARNING=yes
+fi
+
+WERROR_CFLAGS=""
+if test "${ERROR_ON_WARNING}" = yes ; then
+# NOTE: Disabled in the sim dir due to most sims generating warnings.
+# WERROR_CFLAGS="-Werror"
+ true
fi
-# Up for debate: -Wswitch -Wcomment -trigraphs -Wtrigraphs
-# -Wunused-function -Wunused-label -Wunused-variable -Wunused-value
-# -Wchar-subscripts -Wtraditional -Wshadow -Wcast-qual
-# -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes
-# -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls
-# -Woverloaded-virtual -Winline -Werror"
+
+# The entries after -Wno-pointer-sign are disabled warnings which may
+# be enabled in the future, which can not currently be used to build
+# GDB.
+# NOTE: If you change this list, remember to update
+# gdb/doc/gdbint.texinfo.
+build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
+-Wformat-nonliteral -Wno-pointer-sign \
+-Wno-unused -Wunused-value -Wunused-function \
+-Wno-switch -Wno-char-subscripts -Wmissing-prototypes"
+
+# Enable -Wno-format by default when using gcc on mingw since many
+# GCC versions complain about %I64.
+case "${host}" in
+ *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;;
+esac
+
AC_ARG_ENABLE(build-warnings,
-[ --enable-build-warnings Enable build-time compiler warnings if gcc is used],
+AS_HELP_STRING([--enable-build-warnings], [enable build-time compiler warnings if gcc is used]),
[case "${enableval}" in
yes) ;;
no) build_warnings="-w";;
echo "Setting compiler warning flags = $build_warnings" 6>&1
fi])dnl
AC_ARG_ENABLE(sim-build-warnings,
-[ --enable-gdb-build-warnings Enable SIM specific build-time compiler warnings if gcc is used],
+AS_HELP_STRING([--enable-sim-build-warnings], [enable SIM specific build-time compiler warnings if gcc is used]),
[case "${enableval}" in
yes) ;;
no) build_warnings="-w";;
echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
fi])dnl
WARN_CFLAGS=""
-WERROR_CFLAGS=""
if test "x${build_warnings}" != x -a "x$GCC" = xyes
then
AC_MSG_CHECKING(compiler warning flags)
CFLAGS="$saved_CFLAGS"
esac
done
- AC_MSG_RESULT(${WARN_CFLAGS}${WERROR_CFLAGS})
+ AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
fi
])
AC_SUBST(WARN_CFLAGS)