rsmith added inline comments.

================
Comment at: lib/AST/Expr.cpp:1857
+  if (!PExp->IgnoreParenCasts()
+          ->isNullPointerConstant(Ctx, Expr::NPC_ValueDependentIsNull))
+    return false;
----------------
If we get here with a value-dependent expression, we should treat it as 
non-null (do not warn on `(char*)PtrTemplateParameter + N`).


================
Comment at: lib/Sema/SemaExpr.cpp:8804
+  if (PExp->IgnoreParenCasts()->isNullPointerConstant(
+          Context, Expr::NPC_ValueDependentIsNull)) {
+    // In C++ adding zero to a null pointer is defined.
----------------
Likewise here, we should treat a value-dependent expression as non-null.


================
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
----------------
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.)


================
Comment at: lib/Sema/SemaExpr.cpp:8881
+      if (LHS.get()->IgnoreParenCasts()->isNullPointerConstant(Context,
+                                           Expr::NPC_ValueDependentIsNull))
+        diagnoseArithmeticOnNullPointer(*this, Loc, LHS.get(), false);
----------------
Likewise.


https://reviews.llvm.org/D37042



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to