[PATCH] D19851: Warn on binding reference to null in copy initialization

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri May 13 18:42:49 PDT 2016


rsmith accepted this revision.

================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5369
@@ -5368,1 +5368,3 @@
+def warn_binding_null_to_reference : Warning<
+  "binding null pointer to reference has undefined behavior">, InGroup<NullDereference>;
 def note_indirection_through_null : Note<
----------------
Maybe "binding dereferenced null pointer [...]"?

================
Comment at: lib/Sema/SemaInit.cpp:6203
@@ +6202,3 @@
+        UO->getSubExpr()->IgnoreParenCasts()->
+	isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull)) {
+    S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
----------------
Something fishy in the indentation here?


http://reviews.llvm.org/D19851





More information about the cfe-commits mailing list