[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 14 17:56:43 PDT 2016
ahatanak created this revision.
ahatanak added a reviewer: doug.gregor.
ahatanak added a subscriber: cfe-commits.
This patch makes clang issue a warning when a null constant is used in a context where a non null expression is expected. For example:
int * _Nonnull p0 = 0; // warning expected here
int * _Nonnull p1;
int * _Nonnull p2 = c ? p1 : 0; // warning expected here
A new function Sema::diagnoseNullPtrToNonnullCast is defined, which checks whether a null pointer constant is being cast to a _Nonnull pointer type, and called before ImplicitCastExprs are created.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 7519 bytes
Desc: not available
More information about the cfe-commits