You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2014/03/04 19:50:57 UTC

svn commit: r1574174 - /subversion/trunk/subversion/libsvn_subr/error.c

Author: breser
Date: Tue Mar  4 18:50:56 2014
New Revision: 1574174

URL: http://svn.apache.org/r1574174
Log:
Stop trading one compiler warning for another.

* subversion/libsvn_subr/error.c
  (err_abort): Disable the unused-variable warning via pramgas when e can
    rather than using the variable by setting it to itself, which creates
    another warning.  Leave the old method in place for compilers that
    don't support this method.

Modified:
    subversion/trunk/subversion/libsvn_subr/error.c

Modified: subversion/trunk/subversion/libsvn_subr/error.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/error.c?rev=1574174&r1=1574173&r2=1574174&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/error.c (original)
+++ subversion/trunk/subversion/libsvn_subr/error.c Tue Mar  4 18:50:56 2014
@@ -86,15 +86,32 @@ svn_error__locate(const char *file, long
 /* Cleanup function for errors.  svn_error_clear () removes this so
    errors that are properly handled *don't* hit this code. */
 #if defined(SVN_DEBUG)
+/* GCC >= 4.6 has support for diagnostic pragmas that let us
+ * turn off warnings.  clang also supports the same pragmas */
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) \
+     || defined(__clang__))
+  #define IGNORING_UNUSED_WARNING
+  #pragma GCC diagnostic push
+  #pragma GCC diagnostic ignored "-Wunused-variable"
+#endif /* supports diagnostic pragmas */
 static apr_status_t err_abort(void *data)
 {
   svn_error_t *err = data;  /* For easy viewing in a debugger */
-  err = err; /* Fake a use for the variable to avoid compiler warnings */
+#ifndef IGNORING_UNUSED_WARNING
+  /* Fake a use for the variable to avoid compiler warnings if we can't turn
+   * them off via pragmas. */
+  err = err;
+#endif /* IGNORING_UNUSED_WARNING */
 
   if (!getenv("SVN_DBG_NO_ABORT_ON_ERROR_LEAK"))
     abort();
   return APR_SUCCESS;
 }
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) \
+     || defined(__clang__))
+  #undef IGNORING_UNUSED_WARNING
+  #pragma GCC diagnostic pop
+#endif /* supports diagnostic pragmas */
 #endif