diff options
Diffstat (limited to 'test/Analysis/dead-stores.cpp')
-rw-r--r-- | test/Analysis/dead-stores.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/test/Analysis/dead-stores.cpp b/test/Analysis/dead-stores.cpp index d442c621d87b..78cba161065f 100644 --- a/test/Analysis/dead-stores.cpp +++ b/test/Analysis/dead-stores.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -analyze -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -analyze -analyzer-store=region -analyzer-constraints=range -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fblocks -std=c++11 -analyze -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fblocks -std=c++11 -analyze -analyzer-store=region -analyzer-constraints=range -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s //===----------------------------------------------------------------------===// // Basic dead store checking (but in C++ mode). @@ -174,3 +174,31 @@ int radar_13213575() { return radar13213575_testit<true>(5) + radar13213575_testit<false>(3); } +template <class T> +void test_block_in_dependent_context(typename T::some_t someArray) { + ^{ + int i = someArray[0]; // no-warning + }(); +} + +void test_block_in_non_dependent_context(int *someArray) { + ^{ + int i = someArray[0]; // expected-warning {{Value stored to 'i' during its initialization is never read}} + }(); +} + + +//===----------------------------------------------------------------------===// +// Dead store checking involving lambdas. +//===----------------------------------------------------------------------===// + +int basicLambda(int i, int j) { + i = 5; // no warning + j = 6; // no warning + [i] { (void)i; }(); + [&j] { (void)j; }(); + i = 2; + j = 3; + return i + j; +} + |