diff options
Diffstat (limited to 'clang/test/Analysis')
| -rw-r--r-- | clang/test/Analysis/dead-stores.c | 41 | ||||
| -rw-r--r-- | clang/test/Analysis/unreachable-code-path.c | 4 |
2 files changed, 40 insertions, 5 deletions
diff --git a/clang/test/Analysis/dead-stores.c b/clang/test/Analysis/dead-stores.c index a07138e50d7..9e3f736d770 100644 --- a/clang/test/Analysis/dead-stores.c +++ b/clang/test/Analysis/dead-stores.c @@ -175,15 +175,37 @@ int f18() { x = 10; // expected-warning{{Value stored to 'x' is never read}} while (1) x = 10; // expected-warning{{Value stored to 'x' is never read}} + // unreachable. do - x = 10; // expected-warning{{Value stored to 'x' is never read}} + x = 10; // no-warning while (1); + return (x = 10); // no-warning +} - // Don't warn for dead stores in nested expressions. We have yet - // to see a real bug in this scenario. +int f18_a() { + int x = 0; // no-warning return (x = 10); // no-warning } +void f18_b() { + int x = 0; // no-warning + if (1) + x = 10; // expected-warning{{Value stored to 'x' is never read}} +} + +void f18_c() { + int x = 0; + while (1) + x = 10; // expected-warning{{Value stored to 'x' is never read}} +} + +void f18_d() { + int x = 0; // no-warning + do + x = 10; // expected-warning{{Value stored to 'x' is never read}} + while (1); +} + // PR 3514: false positive `dead initialization` warning for init to global // http://llvm.org/bugs/show_bug.cgi?id=3514 extern const int MyConstant; @@ -492,3 +514,16 @@ void rdar8320674(s_rdar8320674 *z, unsigned y, s2_rdar8320674 *st, int m) }while (--m); } +// Avoid dead stores resulting from an assignment (and use) being unreachable. +void rdar8405222_aux(int i); +void rdar8405222() { + const int show = 0; + int i = 0; + + if (show) + i = 5; // no-warning + + if (show) + rdar8405222_aux(i); +} + diff --git a/clang/test/Analysis/unreachable-code-path.c b/clang/test/Analysis/unreachable-code-path.c index acc30f43349..5e7a9872f93 100644 --- a/clang/test/Analysis/unreachable-code-path.c +++ b/clang/test/Analysis/unreachable-code-path.c @@ -114,9 +114,9 @@ void test10() { goto b; // expected-warning {{never executed}} goto a; // expected-warning {{never executed}} b: - i = 1; // expected-warning {{Value stored to 'i' is never read}} + i = 1; // no-warning a: - i = 2; // expected-warning {{Value stored to 'i' is never read}} + i = 2; // no-warning goto f; e: goto d; |

