Quellcode durchsuchen

Enable -Wno-narrowing when possible.

Fixes #112
Bryan Drewery vor 9 Jahren
Ursprung
Commit
c618fa4f60
2 geänderte Dateien mit 58 neuen und 0 gelöschten Zeilen
  1. 1 0
      build/autotools/configure.ac
  2. 57 0
      configure

+ 1 - 0
build/autotools/configure.ac

@@ -33,6 +33,7 @@ EGG_CHECK_CCPIPE
 CXX_FLAG_CHECK([CXXFLAGS], [-fcolor-diagnostics], [colordiagnostics])
 #CXX_FLAG_CHECK([CXXFLAGS], [-Qunused-arguments], [unusedarguments])
 CXX_FLAG_CHECK([CXXFLAGS], [-Wno-invalid-source-encoding], [invalid_source_encoding])
+CXX_FLAG_CHECK([CXXFLAGS], [-Wno-narrowing], [wnonarrowing])
 CXX_FLAG_CHECK([CXXFLAGS], [-fstack-protector], [stackprotector])
 CXX_FLAG_CHECK([CXXFLAGS], [-fstack-protector-strong], [stackprotectorstrong])
 if [[ "${ax_cv_prog_cc_stackprotectorstrong}" = "yes" ]]; then

+ 57 - 0
configure

@@ -3634,6 +3634,63 @@ EOF
   fi
 
 
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler understands -Wno-narrowing" >&5
+$as_echo_n "checking whether the compiler understands -Wno-narrowing... " >&6; }
+if ${ax_cv_prog_cc_wnonarrowing+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+    ac_saved_flags="$CXXFLAGS"
+    CXXFLAGS="-Werror -Wno-narrowing"
+    cat build/confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end build/confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ax_cv_prog_cc_wnonarrowing="yes"
+else
+  ax_cv_prog_cc_wnonarrowing="no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    CXXFLAGS="$ac_saved_flags"
+    ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_prog_cc_wnonarrowing" >&5
+$as_echo "$ax_cv_prog_cc_wnonarrowing" >&6; }
+
+  if [ "$ax_cv_prog_cc_wnonarrowing" = "yes" ]; then
+    CXXFLAGS="$CXXFLAGS -Wno-narrowing"
+  elif [ -n "" ]; then
+      cat << 'EOF' >&2
+configure: error:
+
+  Your OS or C++ compiler does not support -Wno-narrowing.
+  This compile flag is required.
+
+EOF
+    exit 1
+  fi
+
+
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler understands -fstack-protector" >&5
 $as_echo_n "checking whether the compiler understands -fstack-protector... " >&6; }
 if ${ax_cv_prog_cc_stackprotector+:} false; then :