diff --git a/configure.ac b/configure.ac index cda2a04be95..6b834a2f655 100644 --- a/configure.ac +++ b/configure.ac @@ -965,6 +965,17 @@ AC_DEFUN([gl_GCC_VERSION_IFELSE], ] ) +# clang is unduly picky about some things. +AC_CACHE_CHECK([whether the compiler is clang], [emacs_cv_clang], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #ifndef __clang__ + error "not clang"; + #endif + ]])], + [emacs_cv_clang=yes], + [emacs_cv_clang=no])]) + AC_ARG_ENABLE([gcc-warnings], [AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@], [control generation of GCC warnings. The TYPE 'yes' @@ -984,7 +995,11 @@ AC_ARG_ENABLE([gcc-warnings], # just a release imported into Git for patch management. gl_gcc_warnings=no if test -e "$srcdir"/.git && test ! -f "$srcdir"/.tarball-version; then - gl_GCC_VERSION_IFELSE([5], [3], [gl_gcc_warnings=warn-only]) + # Clang typically identifies itself as GCC 4.2 or something similar + # even if it is recent enough to accept the warnings we enable. + AS_IF([test "$emacs_cv_clang" = yes], + [gl_gcc_warnings=warn-only], + [gl_GCC_VERSION_IFELSE([5], [3], [gl_gcc_warnings=warn-only])]) fi]) AC_ARG_ENABLE([check-lisp-object-type], @@ -996,17 +1011,6 @@ if test "$enable_check_lisp_object_type" = yes; then [Define to enable compile-time checks for the Lisp_Object data type.]) fi -# clang is unduly picky about some things. -AC_CACHE_CHECK([whether the compiler is clang], [emacs_cv_clang], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[ - #ifndef __clang__ - error "not clang"; - #endif - ]])], - [emacs_cv_clang=yes], - [emacs_cv_clang=no])]) - WERROR_CFLAGS= # When compiling with GCC, prefer -isystem to -I when including system # include files, to avoid generating useless diagnostics for the files.