diff options
Diffstat (limited to 'test/Analysis/dead-stores.cpp')
-rw-r--r-- | test/Analysis/dead-stores.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/test/Analysis/dead-stores.cpp b/test/Analysis/dead-stores.cpp index 86d84f0..d442c62 100644 --- a/test/Analysis/dead-stores.cpp +++ b/test/Analysis/dead-stores.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-store=region -analyzer-constraints=range -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s +// 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 //===----------------------------------------------------------------------===// // Basic dead store checking (but in C++ mode). @@ -149,3 +149,28 @@ void test_6b() { } catch (void *) {} } + + +void testCXX11Using() { + using Int = int; + Int value; + value = 1; // expected-warning {{never read}} +} + +//===----------------------------------------------------------------------===// +// Dead stores in template instantiations (do not warn). +//===----------------------------------------------------------------------===// + +template <bool f> int radar13213575_testit(int i) { + int x = 5+i; // warning: Value stored to 'x' during its initialization is never read + int y = 7; + if (f) + return x; + else + return y; +} + +int radar_13213575() { + return radar13213575_testit<true>(5) + radar13213575_testit<false>(3); +} + |