EricWF updated the summary for this revision.
EricWF updated this revision to Diff 36910.

http://reviews.llvm.org/D13408

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/non-null-warning.c

Index: test/Sema/non-null-warning.c
===================================================================
--- test/Sema/non-null-warning.c
+++ test/Sema/non-null-warning.c
@@ -37,6 +37,9 @@
   return 0; // expected-warning {{null returned from function that requires a 
non-null return value}}
 }
 
+#define SAFE_CALL(X) if (X) foo(X)
 int main () {
   foo(0); // expected-warning {{null passed to a callee that requires a 
non-null argument}}
+  (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
+  SAFE_CALL(0); // expect no diagnostic for unreachable code.
 }
Index: lib/Sema/SemaChecking.cpp
===================================================================
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1151,7 +1151,8 @@
                                  const Expr *ArgExpr,
                                  SourceLocation CallSiteLoc) {
   if (CheckNonNullExpr(S, ArgExpr))
-    S.Diag(CallSiteLoc, diag::warn_null_arg) << ArgExpr->getSourceRange();
+    S.DiagRuntimeBehavior(CallSiteLoc, ArgExpr,
+           S.PDiag(diag::warn_null_arg) << ArgExpr->getSourceRange());
 }
 
 bool Sema::GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx) {


Index: test/Sema/non-null-warning.c
===================================================================
--- test/Sema/non-null-warning.c
+++ test/Sema/non-null-warning.c
@@ -37,6 +37,9 @@
   return 0; // expected-warning {{null returned from function that requires a non-null return value}}
 }
 
+#define SAFE_CALL(X) if (X) foo(X)
 int main () {
   foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
+  SAFE_CALL(0); // expect no diagnostic for unreachable code.
 }
Index: lib/Sema/SemaChecking.cpp
===================================================================
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1151,7 +1151,8 @@
                                  const Expr *ArgExpr,
                                  SourceLocation CallSiteLoc) {
   if (CheckNonNullExpr(S, ArgExpr))
-    S.Diag(CallSiteLoc, diag::warn_null_arg) << ArgExpr->getSourceRange();
+    S.DiagRuntimeBehavior(CallSiteLoc, ArgExpr,
+           S.PDiag(diag::warn_null_arg) << ArgExpr->getSourceRange());
 }
 
 bool Sema::GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to