aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/Wuninitialized-19.C
blob: e4d53d4bfbaea75bada7989d0a8c04aa49f6d2ad (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
// PR c++/19808
// { dg-do compile { target c++11 } }
// { dg-options "-Wuninitialized" }
// Test we warn when initializing a base class.

struct A {
  A(int) { }
};

struct B : public A {
  int x;
  B() : A(x) { } // { dg-warning "member .B::x. is used uninitialized" }
};

struct C : public A {
  int x;
  int y;
  C() : A(y = 4), x(y) { }
};

struct D : public A {
  int x;
  D() : A{x} { } // { dg-warning "member .D::x. is used uninitialized" }
};

struct E : public A {
  int x;
  int y;
  E() : A{y = 4}, x(y) { }
};

struct F {
  F(int&) { }
};

struct G : F {
  int x;
  G() : F(x) { }
};

struct H {
  H(int *) { }
};

struct I : H {
  int x;
  int arr[2];
  I() : H(&x) { }
  I(int) : H(arr) { }
};