Issue #28152: Fix -Wunreachable-code warnings on Clang

Don't declare dead code when the code is declared with Clang.
This commit is contained in:
Victor Stinner 2016-12-05 17:56:36 +01:00
parent 7bfb42d5b7
commit 9a2329f9e1
2 changed files with 14 additions and 0 deletions

View File

@ -980,12 +980,21 @@ faulthandler_sigsegv(PyObject *self, PyObject *args)
static void static void
faulthandler_fatal_error_thread(void *plock) faulthandler_fatal_error_thread(void *plock)
{ {
#ifndef __clang__
PyThread_type_lock *lock = (PyThread_type_lock *)plock; PyThread_type_lock *lock = (PyThread_type_lock *)plock;
#endif
Py_FatalError("in new thread"); 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 */ /* notify the caller that we are done */
PyThread_release_lock(lock); PyThread_release_lock(lock);
#endif
} }
static PyObject * static PyObject *

View File

@ -10337,8 +10337,13 @@ os_abort_impl(PyObject *module)
{ {
abort(); abort();
/*NOTREACHED*/ /*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!"); Py_FatalError("abort() called from Python code didn't abort!");
return NULL; return NULL;
#endif
} }
#ifdef MS_WINDOWS #ifdef MS_WINDOWS