]> granicus.if.org Git - python/commitdiff
Issue #28152: Fix -Wunreachable-code warnings on Clang
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 5 Dec 2016 16:56:36 +0000 (17:56 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 5 Dec 2016 16:56:36 +0000 (17:56 +0100)
Don't declare dead code when the code is declared with Clang.

Modules/faulthandler.c
Modules/posixmodule.c

index 1c1e4fb7d177600e8535ea28f26df88f2bf8d334..ac6ab7ed0fa0dc0d0f79dfa5449ea73c501e4e80 100644 (file)
@@ -980,12 +980,21 @@ faulthandler_sigsegv(PyObject *self, PyObject *args)
 static void
 faulthandler_fatal_error_thread(void *plock)
 {
+#ifndef __clang__
     PyThread_type_lock *lock = (PyThread_type_lock *)plock;
+#endif
 
     Py_FatalError("in new thread");
 
+#ifndef __clang__
+    /* Issue #28152: Py_FatalError() is declared with
+       __attribute__((__noreturn__)).  GCC emits a warning without
+       "PyThread_release_lock()" (compiler bug?), but Clang is smarter and
+       emits a warning on the return. */
+
     /* notify the caller that we are done */
     PyThread_release_lock(lock);
+#endif
 }
 
 static PyObject *
index 2e9eb9e126cb97988f814d7c1de0e589e123abb6..bec7699b553e9409a0fb14789af4b8f8ff370344 100644 (file)
@@ -10337,8 +10337,13 @@ os_abort_impl(PyObject *module)
 {
     abort();
     /*NOTREACHED*/
+#ifndef __clang__
+    /* Issue #28152: abort() is declared with __attribute__((__noreturn__)).
+       GCC emits a warning without "return NULL;" (compiler bug?), but Clang
+       is smarter and emits a warning on the return. */
     Py_FatalError("abort() called from Python code didn't abort!");
     return NULL;
+#endif
 }
 
 #ifdef MS_WINDOWS