Hi
I'm testing __attribute__((nonnull)) and -Wnonnull.
It seems like it does warn before constant/vrp propagations.
Example code does not warn for first 2 calls to f(NULL),
but warns for last 2 calls to f(NULL).
Couldn't this checker be improved/extended to do checks also after some basic
optimizations like constant propagation pass?
(This could improve possibilities for static code analysis in compile time.)
#include <stdio.h>
static void f(const char *s) __attribute__((nonnull(1)));
int main(void)
{
const char *p = NULL;
f(p); /* No warning? */
f(p = NULL); /* No warning? */
f((const char*)NULL); /* gives warning */
f(NULL); /* gives warning */
return 0;
}
static void f(const char *s)
{
printf("%s",s);
}
Thanks & Best Regards
Fredrik Hederstierna