diff options
Diffstat (limited to 'clang/test/Analysis/dead-stores.c')
| -rw-r--r-- | clang/test/Analysis/dead-stores.c | 41 |
1 files changed, 38 insertions, 3 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); +} + |

