andrew.w.kaylor added inline comments.
================ Comment at: lib/AST/Expr.cpp:1857 + if (!PExp->IgnoreParenCasts() + ->isNullPointerConstant(Ctx, Expr::NPC_ValueDependentIsNull)) + return false; ---------------- rsmith wrote: > If we get here with a value-dependent expression, we should treat it as > non-null (do not warn on `(char*)PtrTemplateParameter + N`). OK. I wasn't sure about that. So how do I test that? Is this right? ``` template<typename T, T *P> T* f(intptr_t offset) { return P + offset; } char *test(intptr_t offset) { return f<char, nullptr>(offset); } ``` ================ Comment at: lib/Sema/SemaExpr.cpp:8877 if (RHS.get()->getType()->isIntegerType()) { + // Subtracting from a null pointer should produce a warning. + // The last argument to the diagnose call says this doesn't match the ---------------- rsmith wrote: > Subtracting zero from a null pointer should not warn in C++. > > (Conversely, subtracting a non-null pointer from a pointer should warn in > C++, and subtracting any pointer from a null pointer should warn in C.) Is it OK if I just add a FIXME in the section below that handles pointer-pointer? https://reviews.llvm.org/D37042 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits