Don't check target is running in remote_target::mourn_inferior
[deliverable/binutils-gdb.git] / gdb / warning.m4
index 55f1eb362c9e0a9e64fcbdea90a1f0fec79ccbd1..00bcdfa7ea505b9117f651f1174b7b8adc7d4ba0 100644 (file)
@@ -1,5 +1,5 @@
 dnl Autoconf configure script for GDB, the GNU debugger.
-dnl Copyright (C) 1995-2016 Free Software Foundation, Inc.
+dnl Copyright (C) 1995-2020 Free Software Foundation, Inc.
 dnl
 dnl This file is part of GDB.
 dnl
@@ -35,27 +35,37 @@ if test "${ERROR_ON_WARNING}" = yes ; then
     WERROR_CFLAGS="-Werror"
 fi
 
-# These options work in either C or C++ modes.
+# The options we'll try to enable.
 build_warnings="-Wall -Wpointer-arith \
--Wno-unused -Wunused-value -Wunused-function \
+-Wno-unused -Wunused-value -Wunused-variable -Wunused-function \
 -Wno-switch -Wno-char-subscripts \
--Wempty-body"
+-Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable \
+-Wno-sign-compare -Wno-error=maybe-uninitialized \
+-Wno-mismatched-tags \
+-Wno-error=deprecated-register \
+-Wsuggest-override \
+-Wimplicit-fallthrough=3 \
+-Wduplicated-cond \
+-Wshadow=local \
+-Wdeprecated-copy \
+-Wdeprecated-copy-dtor \
+-Wredundant-move"
 
-# Now add in C and C++ specific options, depending on mode.
-if test "$enable_build_with_cxx" = "yes"; then
-   build_warnings="$build_warnings -Wno-sign-compare -Wno-write-strings \
--Wno-narrowing"
-else
-   build_warnings="$build_warnings -Wpointer-sign -Wmissing-prototypes \
--Wdeclaration-after-statement -Wmissing-parameter-type \
--Wold-style-declaration -Wold-style-definition"
-fi
-
-# 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" ;;
-  *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
+  *-*-mingw32*)
+    # Enable -Wno-format by default when using gcc on mingw since many
+    # GCC versions complain about %I64.
+    build_warnings="$build_warnings -Wno-format" ;;
+  *-*-solaris*)
+    # Solaris 11.4 <python2.7/ceval.h> uses #pragma no_inline that GCC
+    # doesn't understand.
+    build_warnings="$build_warnings -Wno-unknown-pragmas"
+    # Solaris 11 <unistd.h> marks vfork deprecated.
+    build_warnings="$build_warnings -Wno-deprecated-declarations" ;;
+  *)
+    # Note that gcc requires -Wformat for -Wformat-nonliteral to work,
+    # but there's a special case for this below.
+    build_warnings="$build_warnings -Wformat-nonliteral" ;;
 esac
 
 AC_ARG_ENABLE(build-warnings,
@@ -89,9 +99,7 @@ fi])dnl
 
 # The set of warnings supported by a C++ compiler is not the same as
 # of the C compiler.
-if test "$enable_build_with_cxx" = "yes"; then
-    AC_LANG_PUSH([C++])
-fi
+AC_LANG_PUSH([C++])
 
 WARN_CFLAGS=""
 if test "x${build_warnings}" != x -a "x$GCC" = xyes
@@ -105,6 +113,12 @@ then
        case $w in
        -Wno-*)
                wtest=`echo $w | sed 's/-Wno-/-W/g'` ;;
+        -Wformat-nonliteral)
+               # gcc requires -Wformat before -Wformat-nonliteral
+               # will work, so stick them together.
+               w="-Wformat $w"
+               wtest="$w"
+               ;;
        *)
                wtest=$w ;;
        esac
@@ -114,10 +128,23 @@ then
        *)
            # Check whether GCC accepts it.
            saved_CFLAGS="$CFLAGS"
-           CFLAGS="$CFLAGS $wtest"
+           CFLAGS="$CFLAGS -Werror $wtest"
            saved_CXXFLAGS="$CXXFLAGS"
-           CXXFLAGS="$CXXFLAGS $wtest"
-           AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
+           CXXFLAGS="$CXXFLAGS -Werror $wtest"
+           if test "x$w" = "x-Wunused-variable"; then
+             # Check for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38958,
+             # fixed in GCC 4.9.  This test is derived from the gdb
+             # source code that triggered this bug in GCC.
+             AC_TRY_COMPILE(
+               [struct scoped_restore_base {};
+                 struct scoped_restore_tmpl : public scoped_restore_base {
+                  ~scoped_restore_tmpl() {}
+                };],
+               [const scoped_restore_base &b = scoped_restore_tmpl();],
+               WARN_CFLAGS="${WARN_CFLAGS} $w",)
+           else
+             AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
+           fi
            CFLAGS="$saved_CFLAGS"
            CXXFLAGS="$saved_CXXFLAGS"
        esac
@@ -127,7 +154,5 @@ fi
 AC_SUBST(WARN_CFLAGS)
 AC_SUBST(WERROR_CFLAGS)
 
-if test "$enable_build_with_cxx" = "yes"; then
-   AC_LANG_POP([C++])
-fi
+AC_LANG_POP([C++])
 ])
This page took 0.027847 seconds and 4 git commands to generate.