summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/Wunused-var-12.C
blob: 3300cbe3d8ad5a70e020423c8974aaa8086db4e1 (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
// PR c++/44444
// { dg-do compile }
// { dg-options "-Wunused" }

struct S
{
  const int &u;
  const int &v;
  S (const int &a, const int &b) : u(a), v(b) { }
};

bool
f1 ()
{
  bool t = false;
  S z = S (1, 2);
  t |= z.u == 1;
  t |= z.v == 2;
  return t;
}

void
f2 ()
{
  S z = S (1, 2);
  z.u;		// { dg-warning "no effect" }
}

int i;

void
f3 ()
{
  S z = S (1, 2);
  i++, z.u;	// { dg-warning "no effect" }
}