Commit 8762e524 authored by Jan Djärv's avatar Jan Djärv
Browse files

Suppress some unhelpful warnings when using clang.

* configure.ac: With clang, check for and use -Wno-switch,
-Wno-tautological-constant-out-of-range-compare and -Wno-pointer-sign.

* conf_post.h(assume): Use __builtin_unreachable for clang.

* src/filelock.c (lock_file_1): Rearrange to remove compiler warning
about excess arguments to snprintf.
parent 33215353
2013-09-23 Jan Djärv <jan.h.d@swipnet.se>
* configure.ac: With clang, check for and use -Wno-switch,
-Wno-tautological-constant-out-of-range-compare and -Wno-pointer-sign.
2013-09-23 Daniel Colascione <dancol@dancol.org>
* configure.ac: Check for valgrind headers.
......
......@@ -787,10 +787,28 @@ 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])])
# When compiling with GCC, prefer -isystem to -I when including system
# include files, to avoid generating useless diagnostics for the files.
if test "$gl_gcc_warnings" != yes; then
isystem='-I'
if test "$emacs_cv_clang" = yes
then
# Turn off some warnings if supported.
gl_WARN_ADD([-Wno-switch])
gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
gl_WARN_ADD([-Wno-pointer-sign])
fi
else
isystem='-isystem '
......@@ -840,16 +858,6 @@ else
nw="$nw -Wtype-limits"
nw="$nw -Wunused-parameter"
# 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])])
if test $emacs_cv_clang = yes; then
nw="$nw -Wcast-align"
fi
......
2013-09-23 Jan Djärv <jan.h.d@swipnet.se>
* filelock.c (lock_file_1): Rearrange to remove compiler warning
about excess arguments to snprintf.
* conf_post.h(assume): Use __builtin_unreachable for clang.
2013-09-23 Juanma Barranquero <lekktu@gmail.com>
* w32console.c (initialize_w32_display): Remove unused variable hlinfo.
......
......@@ -248,12 +248,20 @@ extern void _DebPrint (const char *fmt, ...);
# define FLEXIBLE_ARRAY_MEMBER 1
#endif
#ifdef __clang__
# ifndef __has_builtin
# define __has_builtin(x) 0
# endif
#endif
/* assume(cond) tells the compiler (and lint) that a certain condition
* will always hold, and that it should optimize (or check) accordingly. */
#if defined lint
# define assume(cond) ((cond) ? (void) 0 : abort ())
#elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || __GNUC__ > 4
# define assume(cond) ((cond) || (__builtin_unreachable(), 0))
#elif defined (__clang__) && __has_builtin (__builtin_unreachable)
# define assume(cond) ((cond) || (__builtin_unreachable(), 0))
#elif defined __MSC_VER
# define assume(cond) __assume ((cond))
#else
......
......@@ -459,10 +459,18 @@ lock_file_1 (char *lfname, bool force)
char lock_info_str[MAX_LFINFO + 1];
printmax_t pid = getpid ();
if (sizeof lock_info_str
<= snprintf (lock_info_str, sizeof lock_info_str,
boot ? "%s@%s.%"pMd":%"pMd : "%s@%s.%"pMd,
user_name, host_name, pid, boot))
if (boot)
{
if (sizeof lock_info_str
<= snprintf (lock_info_str, sizeof lock_info_str,
"%s@%s.%"pMd":%"pMd,
user_name, host_name, pid, boot))
return ENAMETOOLONG;
}
else if (sizeof lock_info_str
<= snprintf (lock_info_str, sizeof lock_info_str,
"%s@%s.%"pMd,
user_name, host_name, pid))
return ENAMETOOLONG;
return create_lock_file (lfname, lock_info_str, force);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment