summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2020-10-21 10:12:24 -0600
committerCharles Harris <charlesr.harris@gmail.com>2020-10-21 10:29:12 -0600
commit250ab1270ad54f133816956bc64de39b7533968c (patch)
tree87547307ef3ca7ff4f83ef0290cf1d67f14655e8
parent32f1359fc2d11014b240dee2270acea1784a34bb (diff)
downloadnumpy-250ab1270ad54f133816956bc64de39b7533968c.tar.gz
MAINT: Mark dead code as intentional for clang.
Clang is giving dead code warnings in places where we have intentionally marked code to be ignored by inserting a zero in an if statement.
-rw-r--r--numpy/core/src/multiarray/array_coercion.c2
-rw-r--r--numpy/core/src/npysort/selection.c.src3
-rw-r--r--numpy/core/src/umath/loops.c.src3
3 files changed, 5 insertions, 3 deletions
diff --git a/numpy/core/src/multiarray/array_coercion.c b/numpy/core/src/multiarray/array_coercion.c
index 4831dfca6..ffb9bdbe8 100644
--- a/numpy/core/src/multiarray/array_coercion.c
+++ b/numpy/core/src/multiarray/array_coercion.c
@@ -298,7 +298,7 @@ discover_dtype_from_pyobject(
Py_INCREF(DType);
Py_DECREF(legacy_descr);
/* TODO: Enable warning about subclass handling */
- if (0 && !((*flags) & GAVE_SUBCLASS_WARNING)) {
+ if ((0) && !((*flags) & GAVE_SUBCLASS_WARNING)) {
if (DEPRECATE_FUTUREWARNING(
"in the future NumPy will not automatically find the "
"dtype for subclasses of scalars known to NumPy (i.e. "
diff --git a/numpy/core/src/npysort/selection.c.src b/numpy/core/src/npysort/selection.c.src
index 4fd955200..0e285b320 100644
--- a/numpy/core/src/npysort/selection.c.src
+++ b/numpy/core/src/npysort/selection.c.src
@@ -323,7 +323,8 @@ NPY_NO_EXPORT int
store_pivot(kth, kth, pivots, npiv);
return 0;
}
- else if (@inexact@ && kth == num - 1) {
+ // Parenthesis around @inexact@ tells clang dead code as intentional
+ else if ((@inexact@) && kth == num - 1) {
/* useful to check if NaN present via partition(d, (x, -1)) */
npy_intp k;
npy_intp maxidx = low;
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index d9591ab33..ef3d5a21a 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -2647,7 +2647,8 @@ pairwise_sum_@TYPE@(@ftype@ *rr, @ftype@ * ri, char * a, npy_intp n,
NPY_NO_EXPORT void
@TYPE@_@kind@(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))
{
- if (IS_BINARY_REDUCE && @PW@) {
+ // Parenthesis around @PW@ tells clang dead code is intentional
+ if (IS_BINARY_REDUCE && (@PW@)) {
npy_intp n = dimensions[0];
@ftype@ * or = ((@ftype@ *)args[0]);
@ftype@ * oi = ((@ftype@ *)args[0]) + 1;