blob: 1670613dec82b3e8fcad4f803fde37915190c91b [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -warn-dead-stores -verify %s
2// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -warn-dead-stores -verify %s
3// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=basic -analyzer-constraints=range -warn-dead-stores -verify %s
4// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -analyzer-constraints=basic -warn-dead-stores -verify %s
5// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -analyzer-constraints=range -warn-dead-stores -verify %s
Mike Stump8dd1b6b2009-07-22 22:56:04 +00006
Ted Kremenek29f38082009-12-15 04:12:12 +00007//===----------------------------------------------------------------------===//
8// Basic dead store checking (but in C++ mode).
9//===----------------------------------------------------------------------===//
10
Mike Stump8dd1b6b2009-07-22 22:56:04 +000011int j;
12void f1() {
13 int x = 4;
14
15 ++x; // expected-warning{{never read}}
16
17 switch (j) {
18 case 1:
19 throw 1;
20 (void)x;
21 break;
22 }
23}
Ted Kremenek29f38082009-12-15 04:12:12 +000024
25//===----------------------------------------------------------------------===//
26// Dead store checking involving constructors.
27//===----------------------------------------------------------------------===//
28
29class Test1 {
30 int &x;
31public:
32 Test1(int &y) : x(y) {}
33 ~Test1() { ++x; }
34};
35
36int test_ctor_1(int x) {
37 { Test1 a(x); } // no-warning
38 return x;
39}