dead-stores.c revision f87821c086a46411883b385c743996a35cc8e154
1// RUN: clang -warn-dead-stores -verify %s
2
3void f1() {
4  int k, y;
5  int abc=1;
6  long idx=abc+3*5; // expected-warning {{value stored to variable is never used}}
7}
8
9void f2(void *b) {
10 char *c = (char*)b; // no-warning
11 char *d = b+1; // expected-warning {{value stored to variable is never used}}
12 printf("%s", c);
13}
14
15void f3() {
16  int r;
17  if ((r = f()) != 0) { // no-warning
18    int y = r; // no-warning
19    printf("the error is: %d\n", y);
20  }
21}
22
23void f4(int k) {
24
25  k = 1;
26
27  if (k)
28    f1();
29
30  k = 2;  // expected-warning {{value stored to variable is never used}}
31}
32
33void f5() {
34
35  int x = 4; // no-warning
36  int *p = &x; // expected-warning{{value stored to variable is never used}}
37
38}