ソースを参照

Resolved compiler warning when compiling rAthena with clang++

Jittapan Pluemsumran 8 年 前
コミット
bd33f01e53
2 ファイル変更104 行追加101 行削除
  1. 96 93
      configure
  2. 8 8
      configure.in

+ 96 - 93
configure

@@ -5527,10 +5527,59 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 
 
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-maybe-uninitialized" >&5
-$as_echo_n "checking whether $CC supports -Wno-maybe-uninitialized... " >&6; }
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wempty-body" >&5
+$as_echo_n "checking whether $CC supports -Wempty-body... " >&6; }
 		OLD_CFLAGS="$CFLAGS"
-		CFLAGS="$CFLAGS -Werror -Wno-maybe-uninitialized"
+		CFLAGS="$CFLAGS -Werror -Wempty-body"
+		cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int foo;
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+				CFLAGS="$OLD_CFLAGS -Wempty-body"
+				# Optionally, run a test
+				if test "x" != "x"; then
+					{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wempty-body" >&5
+$as_echo_n "checking whether $CC can actually use -Wempty-body... " >&6; }
+					CFLAGS="$OLD_CFLAGS -Werror -Wempty-body"
+					cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+							{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+							CFLAGS="$OLD_CFLAGS"
+
+
+							{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+							CFLAGS="$OLD_CFLAGS -Wempty-body"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+				fi
+
+else
+
+				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+				CFLAGS="$OLD_CFLAGS"
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-switch" >&5
+$as_echo_n "checking whether $CC supports -Wno-switch... " >&6; }
+		OLD_CFLAGS="$CFLAGS"
+		CFLAGS="$CFLAGS -Werror -Wno-switch"
 		cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int foo;
@@ -5540,7 +5589,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
 				# Recent versions of gcc don't fail if -Wno-foo is not recognized
 				# (unless there are also other warnings), so we also check for -Wfoo
 				# which always fails if not supported
-				CFLAGS="$OLD_CFLAGS -Werror -Wmaybe-uninitialized"
+				CFLAGS="$OLD_CFLAGS -Werror -Wswitch"
 				cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int foo;
@@ -5549,12 +5598,12 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
 
 						{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-						CFLAGS="$OLD_CFLAGS -Wno-maybe-uninitialized"
+						CFLAGS="$OLD_CFLAGS -Wno-switch"
 						# Optionally, run a test
 						if test "x" != "x"; then
-							{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wno-maybe-uninitialized" >&5
-$as_echo_n "checking whether $CC can actually use -Wno-maybe-uninitialized... " >&6; }
-							CFLAGS="$OLD_CFLAGS -Werror -Wmaybe-uninitialized"
+							{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wno-switch" >&5
+$as_echo_n "checking whether $CC can actually use -Wno-switch... " >&6; }
+							CFLAGS="$OLD_CFLAGS -Werror -Wswitch"
 							cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -5567,7 +5616,7 @@ $as_echo "not needed but enabled" >&6; }
 
 else
 
-									CFLAGS="$OLD_CFLAGS -Werror -Wno-maybe-uninitialized"
+									CFLAGS="$OLD_CFLAGS -Werror -Wno-switch"
 									cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -5576,7 +5625,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
 
 											{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-											CFLAGS="$OLD_CFLAGS -Wno-maybe-uninitialized"
+											CFLAGS="$OLD_CFLAGS -Wno-switch"
 
 else
 
@@ -5615,10 +5664,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 
 
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-clobbered" >&5
-$as_echo_n "checking whether $CC supports -Wno-clobbered... " >&6; }
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-missing-field-initializers" >&5
+$as_echo_n "checking whether $CC supports -Wno-missing-field-initializers... " >&6; }
 		OLD_CFLAGS="$CFLAGS"
-		CFLAGS="$CFLAGS -Werror -Wno-clobbered"
+		CFLAGS="$CFLAGS -Werror -Wno-missing-field-initializers"
 		cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int foo;
@@ -5628,7 +5677,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
 				# Recent versions of gcc don't fail if -Wno-foo is not recognized
 				# (unless there are also other warnings), so we also check for -Wfoo
 				# which always fails if not supported
-				CFLAGS="$OLD_CFLAGS -Werror -Wclobbered"
+				CFLAGS="$OLD_CFLAGS -Werror -Wmissing-field-initializers"
 				cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int foo;
@@ -5637,12 +5686,12 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
 
 						{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-						CFLAGS="$OLD_CFLAGS -Wno-clobbered"
+						CFLAGS="$OLD_CFLAGS -Wno-missing-field-initializers"
 						# Optionally, run a test
 						if test "x" != "x"; then
-							{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wno-clobbered" >&5
-$as_echo_n "checking whether $CC can actually use -Wno-clobbered... " >&6; }
-							CFLAGS="$OLD_CFLAGS -Werror -Wclobbered"
+							{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wno-missing-field-initializers" >&5
+$as_echo_n "checking whether $CC can actually use -Wno-missing-field-initializers... " >&6; }
+							CFLAGS="$OLD_CFLAGS -Werror -Wmissing-field-initializers"
 							cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -5655,7 +5704,7 @@ $as_echo "not needed but enabled" >&6; }
 
 else
 
-									CFLAGS="$OLD_CFLAGS -Werror -Wno-clobbered"
+									CFLAGS="$OLD_CFLAGS -Werror -Wno-missing-field-initializers"
 									cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -5664,7 +5713,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
 
 											{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-											CFLAGS="$OLD_CFLAGS -Wno-clobbered"
+											CFLAGS="$OLD_CFLAGS -Wno-missing-field-initializers"
 
 else
 
@@ -5702,66 +5751,19 @@ fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wempty-body" >&5
-$as_echo_n "checking whether $CC supports -Wempty-body... " >&6; }
-		OLD_CFLAGS="$CFLAGS"
-		CFLAGS="$CFLAGS -Werror -Wempty-body"
-		cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-int foo;
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-
-				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-				CFLAGS="$OLD_CFLAGS -Wempty-body"
-				# Optionally, run a test
-				if test "x" != "x"; then
-					{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wempty-body" >&5
-$as_echo_n "checking whether $CC can actually use -Wempty-body... " >&6; }
-					CFLAGS="$OLD_CFLAGS -Werror -Wempty-body"
-					cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-
-							{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-							CFLAGS="$OLD_CFLAGS"
-
-
-							{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-							CFLAGS="$OLD_CFLAGS -Wempty-body"
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-				fi
-
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler is clang" >&5
+$as_echo_n "checking whether compiler is clang... " >&6; }
+if test -n "`$CC --version | grep -i clang`" ; then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, skipping some flags.." >&5
+$as_echo "yes, skipping some flags.." >&6; }
 else
-
-				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-				CFLAGS="$OLD_CFLAGS"
-
 
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-
-#AC_CHECK_COMPILER_WFLAG(newline-eof)
-#AC_CHECK_COMPILER_WFLAG(int-conversion)
-#AC_CHECK_COMPILER_WFLAG(enum-conversion)
-#AC_CHECK_COMPILER_WFLAG(shorten-64-to-32)
-#AC_CHECK_COMPILER_WFLAG(constant-conversion)
-#AC_CHECK_COMPILER_WFLAG(bool-conversion)
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-switch" >&5
-$as_echo_n "checking whether $CC supports -Wno-switch... " >&6; }
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-maybe-uninitialized" >&5
+$as_echo_n "checking whether $CC supports -Wno-maybe-uninitialized... " >&6; }
 		OLD_CFLAGS="$CFLAGS"
-		CFLAGS="$CFLAGS -Werror -Wno-switch"
+		CFLAGS="$CFLAGS -Werror -Wno-maybe-uninitialized"
 		cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int foo;
@@ -5771,7 +5773,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
 				# Recent versions of gcc don't fail if -Wno-foo is not recognized
 				# (unless there are also other warnings), so we also check for -Wfoo
 				# which always fails if not supported
-				CFLAGS="$OLD_CFLAGS -Werror -Wswitch"
+				CFLAGS="$OLD_CFLAGS -Werror -Wmaybe-uninitialized"
 				cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int foo;
@@ -5780,12 +5782,12 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
 
 						{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-						CFLAGS="$OLD_CFLAGS -Wno-switch"
+						CFLAGS="$OLD_CFLAGS -Wno-maybe-uninitialized"
 						# Optionally, run a test
 						if test "x" != "x"; then
-							{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wno-switch" >&5
-$as_echo_n "checking whether $CC can actually use -Wno-switch... " >&6; }
-							CFLAGS="$OLD_CFLAGS -Werror -Wswitch"
+							{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wno-maybe-uninitialized" >&5
+$as_echo_n "checking whether $CC can actually use -Wno-maybe-uninitialized... " >&6; }
+							CFLAGS="$OLD_CFLAGS -Werror -Wmaybe-uninitialized"
 							cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -5798,7 +5800,7 @@ $as_echo "not needed but enabled" >&6; }
 
 else
 
-									CFLAGS="$OLD_CFLAGS -Werror -Wno-switch"
+									CFLAGS="$OLD_CFLAGS -Werror -Wno-maybe-uninitialized"
 									cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -5807,7 +5809,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
 
 											{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-											CFLAGS="$OLD_CFLAGS -Wno-switch"
+											CFLAGS="$OLD_CFLAGS -Wno-maybe-uninitialized"
 
 else
 
@@ -5846,10 +5848,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 
 
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-missing-field-initializers" >&5
-$as_echo_n "checking whether $CC supports -Wno-missing-field-initializers... " >&6; }
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-clobbered" >&5
+$as_echo_n "checking whether $CC supports -Wno-clobbered... " >&6; }
 		OLD_CFLAGS="$CFLAGS"
-		CFLAGS="$CFLAGS -Werror -Wno-missing-field-initializers"
+		CFLAGS="$CFLAGS -Werror -Wno-clobbered"
 		cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int foo;
@@ -5859,7 +5861,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
 				# Recent versions of gcc don't fail if -Wno-foo is not recognized
 				# (unless there are also other warnings), so we also check for -Wfoo
 				# which always fails if not supported
-				CFLAGS="$OLD_CFLAGS -Werror -Wmissing-field-initializers"
+				CFLAGS="$OLD_CFLAGS -Werror -Wclobbered"
 				cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int foo;
@@ -5868,12 +5870,12 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
 
 						{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-						CFLAGS="$OLD_CFLAGS -Wno-missing-field-initializers"
+						CFLAGS="$OLD_CFLAGS -Wno-clobbered"
 						# Optionally, run a test
 						if test "x" != "x"; then
-							{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wno-missing-field-initializers" >&5
-$as_echo_n "checking whether $CC can actually use -Wno-missing-field-initializers... " >&6; }
-							CFLAGS="$OLD_CFLAGS -Werror -Wmissing-field-initializers"
+							{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wno-clobbered" >&5
+$as_echo_n "checking whether $CC can actually use -Wno-clobbered... " >&6; }
+							CFLAGS="$OLD_CFLAGS -Werror -Wclobbered"
 							cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -5886,7 +5888,7 @@ $as_echo "not needed but enabled" >&6; }
 
 else
 
-									CFLAGS="$OLD_CFLAGS -Werror -Wno-missing-field-initializers"
+									CFLAGS="$OLD_CFLAGS -Werror -Wno-clobbered"
 									cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -5895,7 +5897,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
 
 											{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-											CFLAGS="$OLD_CFLAGS -Wno-missing-field-initializers"
+											CFLAGS="$OLD_CFLAGS -Wno-clobbered"
 
 else
 
@@ -5933,6 +5935,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 
+fi
 
 # Certain versions of gcc make -Wshadow completely useless by making it flood
 # you with unnecessary warnings <https://lkml.org/lkml/2006/11/28/239>

+ 8 - 8
configure.in

@@ -697,17 +697,17 @@ AC_DEFUN(AC_CHECK_COMPILER_WNOFLAG,
 )
 
 AC_CHECK_COMPILER_WNOFLAG(unused-parameter, [int foo(int bar) { return 0; }])
-AC_CHECK_COMPILER_WNOFLAG(maybe-uninitialized)
-AC_CHECK_COMPILER_WNOFLAG(clobbered)
 AC_CHECK_COMPILER_WFLAG(empty-body)
-#AC_CHECK_COMPILER_WFLAG(newline-eof)
-#AC_CHECK_COMPILER_WFLAG(int-conversion)
-#AC_CHECK_COMPILER_WFLAG(enum-conversion)
-#AC_CHECK_COMPILER_WFLAG(shorten-64-to-32)
-#AC_CHECK_COMPILER_WFLAG(constant-conversion)
-#AC_CHECK_COMPILER_WFLAG(bool-conversion)
 AC_CHECK_COMPILER_WNOFLAG(switch)
 AC_CHECK_COMPILER_WNOFLAG(missing-field-initializers)
+AC_MSG_CHECKING([whether compiler is clang])
+if test -n "`$CC --version | grep -i clang`" ; then
+	AC_MSG_RESULT([yes, skipping some flags..])
+else
+	AC_MSG_RESULT([no])
+	AC_CHECK_COMPILER_WNOFLAG(maybe-uninitialized)
+	AC_CHECK_COMPILER_WNOFLAG(clobbered)
+fi
 
 # Certain versions of gcc make -Wshadow completely useless by making it flood
 # you with unnecessary warnings <https://lkml.org/lkml/2006/11/28/239>