Ticket #3134: fix cflags check when using clang compiler.

With clang invalid cflags usage result in exit 0, we expect exit 1.

$ clang -c -Wmaybe-uninitialized conftest.c ; echo $?
warning: unknown warning option '-Wmaybe-uninitialized'; did you mean '-Wuninitialized'? [-Wunknown-warning-option]
1 warning generated.
0

solution with -Werror on cflags check

$ clang -c -Werror -Wmaybe-uninitialized conftest.c ; echo $?
error: unknown warning option '-Wmaybe-uninitialized'; did you mean '-Wuninitialized'? [-Werror,-Wunknown-warning-option]
1

(Tested with clang 3.6.)

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andreas Mohr 2015-04-05 09:43:47 +03:00 committed by Andrew Borodin
parent 850073cbbb
commit 495b4d662f
1 changed files with 9 additions and 1 deletions

View File

@ -12,7 +12,15 @@ AC_DEFUN([MC_CHECK_ONE_CFLAG],[
AC_MSG_CHECKING([whether ${CC} accepts $1])
safe_CFLAGS=$CFLAGS
CFLAGS="$1"
case "$CC" in
clang*)
CFLAGS="-Werror $1"
;;
*)
CFLAGS="$1"
;;
esac
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[return 0;]])],