aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/Wuninitialized-28.C
blob: 816249c2b9c85535814401cdc1cd529640f1c100 (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
// PR c++/19808
// { dg-do compile { target c++11 } }
// { dg-options "-Wuninitialized" }

struct S {
  int i, j, k, l;
  S() : i(j), // { dg-warning "member .S::j. is used uninitialized" }
	j(1),
	k(l + 1), // { dg-warning "member .S::l. is used uninitialized" }
	l(2) { }
};

struct A {
  int a, b, c;
  A() : a(b // { dg-warning "member .A::b. is used uninitialized" }
	  + c) { } // { dg-warning "member .A::c. is used uninitialized" }
};

struct B {
  int &r;
  int *p;
  int a;
  B() : r(a), p(&a), a(1) { }
};

struct C {
  const int &r1, &r2;
  C () : r1(r2), // { dg-warning "reference .C::r2. is not yet bound to a value when used here" }
	 r2(r1) { }
};

struct D {
  int a = 1;
  int b = 2;
  D() : a(b + 1), b(a + 1) { } // { dg-warning "member .D::b. is used uninitialized" }
};

struct E {
  int a = 1;
  E() : a(a + 1) { } // { dg-warning "member .E::a. is used uninitialized" }
};

struct F {
  int a = 1;
  int b;
  F() : b(a + 1) { }
};

struct bar {
  int a;
  bar() {}
  bar(bar&) {}
};

class foo {
  bar first;
  bar second;
public:
  foo() : first(second) {} // { dg-warning "member .foo::second. is used uninitialized" }
};