emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r114437: Suppress some unhelpful warnings when using


From: Jan D.
Subject: [Emacs-diffs] trunk r114437: Suppress some unhelpful warnings when using clang.
Date: Mon, 23 Sep 2013 07:12:03 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114437
revision-id: address@hidden
parent: address@hidden
committer: Jan Djärv <address@hidden>
branch nick: trunk
timestamp: Mon 2013-09-23 09:12:01 +0200
message:
  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.
modified:
  ChangeLog                      changelog-20091113204419-o5vbwnq5f7feedwu-1538
  configure.ac                   
configure.in-20091113204419-o5vbwnq5f7feedwu-783
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/conf_post.h                conf_post.h-20120730211826-q0qbxxwh2emw52hd-1
  src/filelock.c                 filelock.c-20091113204419-o5vbwnq5f7feedwu-179
=== modified file 'ChangeLog'
--- a/ChangeLog 2013-09-23 02:34:52 +0000
+++ b/ChangeLog 2013-09-23 07:12:01 +0000
@@ -1,3 +1,8 @@
+2013-09-23  Jan Djärv  <address@hidden>
+
+       * 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  <address@hidden>
 
        * configure.ac: Check for valgrind headers.

=== modified file 'configure.ac'
--- a/configure.ac      2013-09-23 02:34:52 +0000
+++ b/configure.ac      2013-09-23 07:12:01 +0000
@@ -787,10 +787,28 @@
   ]
 )
 
+# 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 @@
   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

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-09-23 03:30:55 +0000
+++ b/src/ChangeLog     2013-09-23 07:12:01 +0000
@@ -1,3 +1,10 @@
+2013-09-23  Jan Djärv  <address@hidden>
+
+       * 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  <address@hidden>
 
        * w32console.c (initialize_w32_display): Remove unused variable hlinfo.

=== modified file 'src/conf_post.h'
--- a/src/conf_post.h   2013-09-22 11:07:17 +0000
+++ b/src/conf_post.h   2013-09-23 07:12:01 +0000
@@ -248,12 +248,20 @@
 # 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

=== modified file 'src/filelock.c'
--- a/src/filelock.c    2013-08-11 01:30:20 +0000
+++ b/src/filelock.c    2013-09-23 07:12:01 +0000
@@ -459,10 +459,18 @@
   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 ? "address@hidden"pMd":%"pMd : "address@hidden"pMd,
-                  user_name, host_name, pid, boot))
+  if (boot)
+    {
+      if (sizeof lock_info_str
+          <= snprintf (lock_info_str, sizeof lock_info_str,
+                       "address@hidden"pMd":%"pMd,
+                       user_name, host_name, pid, boot))
+        return ENAMETOOLONG;
+    }
+  else if (sizeof lock_info_str
+           <= snprintf (lock_info_str, sizeof lock_info_str,
+                        "address@hidden"pMd,
+                        user_name, host_name, pid))
     return ENAMETOOLONG;
 
   return create_lock_file (lfname, lock_info_str, force);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]