[cfe-commits] r126294 - /cfe/trunk/test/Sema/exprs.c

Ted Kremenek kremenek at apple.com
Tue Feb 22 18:15:20 PST 2011


Author: kremenek
Date: Tue Feb 22 20:15:19 2011
New Revision: 126294

URL: http://llvm.org/viewvc/llvm-project?rev=126294&view=rev
Log:
Add test case (from PR 8876) for suppressing 'indirection of non-volatile null pointer...' warning due to reachability analysis.

Modified:
    cfe/trunk/test/Sema/exprs.c

Modified: cfe/trunk/test/Sema/exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/exprs.c?rev=126294&r1=126293&r2=126294&view=diff
==============================================================================
--- cfe/trunk/test/Sema/exprs.c (original)
+++ cfe/trunk/test/Sema/exprs.c Tue Feb 22 20:15:19 2011
@@ -1,5 +1,23 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 
+// PR 8876 - don't warn about trivially unreachable null derefs.  Note that
+// we put this here because the reachability analysis only kicks in for
+// suppressing false positives when code has no errors.
+#define PR8876(err_ptr) do {\
+    if (err_ptr) *(int*)(err_ptr) = 1;\
+  } while (0)
+
+#define PR8876_pos(err_ptr) do {\
+    if (!err_ptr) *(int*)(err_ptr) = 1;\
+  } while (0)
+
+
+int test_pr8876() {
+  PR8876(0); // no-warning
+  PR8876_pos(0); // expected-warning{{indirection of non-volatile null pointer will be deleted, not trap}} expected-note{{consider using __builtin_trap() or qualifying pointer with 'volatile'}}
+  return 0;
+}
+
 // PR1966
 _Complex double test1() {
   return __extension__ 1.0if;





More information about the cfe-commits mailing list