aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/Wunused-var-1.c
blob: ef8f6d4546a0c0a848dbf519dc0ece1dc4436e08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/* { dg-do compile } */
/* { dg-options "-Wunused" } */

void
f1 (void)
{
  int a;	/* { dg-warning "set but not used" } */
  int b;
  int c;
  c = 1;
  a = b = c;
}

void
f2 (int x)
{
  int a;	/* { dg-warning "set but not used" } */
  int b;
  int c;	/* { dg-warning "set but not used" } */
  c = (a = x, b = x);
}

int
f3 (int x)
{
  int a;
  return a = x;
}

int
f4 (int x)
{
  int a;
  a = x;
  return a;
}

void
f5 (int x)
{
  int a[2];	/* { dg-warning "set but not used" } */
  int b;
  int *c, d[2];
  c = d;
  b = x;
  a[b] = 1;
  c[b] = 1;
}

int
f6 (int x)
{
  int a[2];
  int b;
  b = x;
  a[b] = 1;
  return a[b];
}

void
f7 (int x, int *p)
{
  int *a[2];
  a[x] = p;
  a[x][x] = x;
}

struct S { int i; };

void
f8 (void)
{
  struct S s;	/* { dg-warning "set but not used" } */
  s.i = 6;
}

int
f9 (void)
{
  struct S s;
  s.i = 6;
  return s.i;
}

struct S
f10 (void)
{
  struct S s;
  s.i = 6;
  return s;
}

extern int foo11 (int *);

void
f11 (void)
{
  int a[2];
  foo11 (a);
}

void
f12 (void)
{
  int a;
  a = 1;
  a;	/* { dg-warning "no effect" } */
}

void
f13 (void (*x) (void))
{
  void (*a) (void);
  a = x;
  a ();
}

void
f14 (void (*x) (void))
{
  void (*a) (void);	/* { dg-warning "set but not used" } */
  a = x;
}

extern void foo15 (int *);

void
f15 (void)
{
  int a[10];
  int *b = a + 2;
  foo15 (b);
}

extern void foo16 (int **);

void
f16 (void)
{
  int a[10];
  int *b[] = { a, a + 2 };
  foo16 (b);
}

void
f17 (int x)
{
  long a;	/* { dg-warning "set but not used" } */
  int b;
  a = b = x;
}

void
f18 (int x)
{
  int a;	/* { dg-warning "set but not used" } */
  int b;
  a = (char) (b = x);
}

int
f19 (int x, int y, int z)
{
  int a;
  int b;
  a = x;
  b = y;
  return z ? a : b;
}

int *
f20 (int x)
{
  static int a[] = { 3, 4, 5, 6 };
  static int b[] = { 4, 5, 6, 7 };
  static int c[] = { 5, 6, 7, 8 };	/* { dg-warning "set but not used" } */
  c[1] = 1;
  return x ? a : b;
}