Currently when a function annotated with attribute((nonnull)) is called in an unevaluated context with a null argument a -Wnonnull warning is emitted.
This warning seems like a false positive unless the call expression is potentially evaluated. Change this behavior so that the non-null warnings use DiagRuntimeBehavior so they wont emit when they won't be evaluated.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
This seems reasonable.
I wonder if it might be better to also suppress warnings for dynamically-unreachable code (you can do this by changing the Diag calls inside CheckNonNullArguments to DiagRuntimeBehavior instead of the current patch). That would help for a case like:
#define SAFE_FOO(x) if (x) foo(x) SAFE_FOO(0);
... but admittedly that's pretty contrived.
Anyway, this looks fine as far as it goes.