[cfe-commits] r167358 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/Sema/warn-type-safety-mpi-hdf5.c test/Sema/warn-type-safety.c test/Sema/warn-type-safety.cpp
Eli Friedman
eli.friedman at gmail.com
Sat Nov 3 14:54:02 PDT 2012
On Sat, Nov 3, 2012 at 9:07 AM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> Author: gribozavr
> Date: Sat Nov 3 11:07:49 2012
> New Revision: 167358
>
> URL: http://llvm.org/viewvc/llvm-project?rev=167358&view=rev
> Log:
> Handle CK_NullToPointer casts in -Wtype-safety properly. Fixes PR14249.
>
> Modified:
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/test/Sema/warn-type-safety-mpi-hdf5.c
> cfe/trunk/test/Sema/warn-type-safety.c
> cfe/trunk/test/Sema/warn-type-safety.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=167358&r1=167357&r2=167358&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Sat Nov 3 11:07:49 2012
> @@ -6189,7 +6189,9 @@
> if (IsPointerAttr) {
> // Skip implicit cast of pointer to `void *' (as a function argument).
> if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(ArgumentExpr))
> - if (ICE->getType()->isVoidPointerType())
> + if (ICE->getType()->isVoidPointerType() &&
> + ICE->getCastKind() != CK_NullToPointer &&
> + ICE->getCastKind() != CK_NullToMemberPointer)
We generally prefer to check what a cast kind is, not what it isn't...
there are so many kinds of casts, it's very easy to miss one. Please
check "getCastKind() == CK_Bitcast" instead.
-Eli
More information about the cfe-commits
mailing list