Vitja Makarov, 29.07.2011 08:38:
2011/7/29 Vitja Makarov:
2011/7/29 Stefan Behnel:
Nikolaus Rath, 13.06.2011 16:59:
$ gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall
-Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c test.c -o test.o
-D_FILE_OFFSET_BITS=64 -I/usr/include/fuse -Werror -Wall -Wextra
-Wconversion -Wno-unused-parameter -Wno-sign-conversion -fno-strict-aliasing
test.c:
test.c:454:13: warning: variable ‘__pyx_v_exc’ set but not used
[-Wunused-but-set-variable]
test.c:453:13: warning: variable ‘__pyx_v_fn’ set but not used
[-Wunused-but-set-variable]
test.c:452:13: warning: variable ‘__pyx_v_self’ set but not used
[-Wunused-but-set-variable]
http://trac.cython.org/cython_trac/ticket/704
I think this is something that the control flow analysis could deal with.
Basically, every parameter that turns out to be unused in the function (and
this most likely only happens with parameters) could be ignored, unless it
requires a type conversion with potential side effects. In that (unlikely)
case, we could still drop the final assignment to the variable itself.
There is entry.cf_unused flag it's set when the whole entry is not used.
((6af313c...)) vitja@vitja-laptop:~/work/cython-vitek$ python
cython.py -X warn.unused_arg=True test.pyx
warning: test.pyx:2:19: Unused argument 'self'
warning: test.pyx:2:25: Unused argument 'fn'
warning: test.pyx:2:29: Unused argument 'exc'
Cool. That's what I expected. :)
Want to give it a try? The argument unpacking code has traditionally been
my domain, and it's somewhat complex, but it should still be easy to stick
this in. Note that there is more than one place where this needs to be
handled, as the code is structured into different cases based on the type
of signature.
Otherwise, I can see if I find a bit of time over the weekend.
Stefan
_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel