gcc-python-plugin [1] now provides a gcc-with-cpychecker harness that
runs gcc with an additional pass that checks CPython API calls
(internally, it's using the gcc python plugin to run a python script
that does the work).
I tried rebuilding the plugin using
make CC=../other-build/gcc-with-cpychecker
and it found a genuine bug in itself: within this code:
350 PyObject *
351 gcc_Pass_get_by_name(PyObject *cls, PyObject *args, PyObject *kwargs)
352 {
353 const char *name;
354 char *keywords[] = {"name",
355 NULL};
356 struct opt_pass *result;
357
358 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
359 "s|get_by_name", keywords,
360 &name)) {
361 return NULL;
362 }
363 [...snip...]
it found this problem:
gcc-python-pass.c: In function ‘gcc_Pass_get_by_name’:
gcc-python-pass.c:358:37: error: unknown format char in "s|get_by_name": 'g' [-fpermissive]
It turned out that I'd typo-ed the format code: I was erroneously using
"|" (signifying that optional args follow), when I meant to use
":" (signifying that the rest of the string is the name of the function,
for use in error messages) [2].
Fixed in git; there are a few false positives, which I'm working on
fixing now.
I'm in two minds about whether this (minor) milestone is one I should
mention in public, but I guess it's proof that having a static checker
for this kind of mistake is worthwhile :)
Dave
[1] https://fedorahosted.org/gcc-python-plugin/
[2] fwiw, the API that it's checking is here:
http://docs.python.org/c-api/arg.html