diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index 15feda18f018a3459b8970073d5c0af54f805854..60319f992f5a55fb135c10fc5bb0d053ed648b75 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -1190,6 +1190,7 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations): def visit_CallNode(self, node): self.visit(node.function) if not self.parallel_directive: + self.visitchildren(node, exclude=('function',)) return node # We are a parallel directive, replace this node with the diff --git a/tests/run/parallel.pyx b/tests/run/parallel.pyx index c3526556f0f2d1905f4ed49e5d61c892333d699a..c3739b10bcebdbf831df4f0b616f21af47e6625c 100644 --- a/tests/run/parallel.pyx +++ b/tests/run/parallel.pyx @@ -8,6 +8,9 @@ from libc.stdlib cimport malloc, free openmp.omp_set_nested(1) +cdef int forward(int x) nogil: + return x + def test_parallel(): """ >>> test_parallel() @@ -20,6 +23,9 @@ def test_parallel(): with nogil, cython.parallel.parallel(): buf[threadid()] = threadid() + # Recognise threadid() also when it's used in a function argument. + # See https://github.com/cython/cython/issues/3594 + buf[forward(cython.parallel.threadid())] = forward(threadid()) for i in range(maxthreads): assert buf[i] == i