diff options
author | dim <dim@FreeBSD.org> | 2011-02-26 22:09:03 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-02-26 22:09:03 +0000 |
commit | a0fb00f9837bd0d2e5948f16f6a6b82a7a628f51 (patch) | |
tree | abae0246ec9156cc1a7cbb947b2b0dfe95fa3189 /test/Sema/exprs.c | |
parent | 39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df (diff) | |
download | FreeBSD-src-a0fb00f9837bd0d2e5948f16f6a6b82a7a628f51.zip FreeBSD-src-a0fb00f9837bd0d2e5948f16f6a6b82a7a628f51.tar.gz |
Vendor import of clang trunk r126547:
http://llvm.org/svn/llvm-project/cfe/trunk@126547
Diffstat (limited to 'test/Sema/exprs.c')
-rw-r--r-- | test/Sema/exprs.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c index e88f7fc..0d6c548 100644 --- a/test/Sema/exprs.c +++ b/test/Sema/exprs.c @@ -1,5 +1,31 @@ // 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; +} + +// PR 8183 - Handle null pointer constants on the left-side of the '&&', and reason about +// this when determining the reachability of the null pointer dereference on the right side. +void pr8183(unsigned long long test) +{ + (void)((((void*)0)) && (*((unsigned long long*)(((void*)0))) = ((unsigned long long)((test)) % (unsigned long long)((1000000000))))); // no-warning + (*((unsigned long long*)(((void*)0))) = ((unsigned long long)((test)) % (unsigned long long)((1000000000)))); // expected-warning {{indirection of non-volatile null pointer will be deleted, not trap}} expected-note {{consider using __builtin_trap() or qualifying pointer with 'volatile'}} +} + // PR1966 _Complex double test1() { return __extension__ 1.0if; |