Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wuninitialized-19.C

raw
1 // PR c++/19808
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-Wuninitialized" }
4 // Test we warn when initializing a base class.
5
6 struct A {
7 A(int) { }
8 };
9
10 struct B : public A {
11 int x;
12 B() : A(x) { } // { dg-warning "member .B::x. is used uninitialized" }
13 };
14
15 struct C : public A {
16 int x;
17 int y;
18 C() : A(y = 4), x(y) { }
19 };
20
21 struct D : public A {
22 int x;
23 D() : A{x} { } // { dg-warning "member .D::x. is used uninitialized" }
24 };
25
26 struct E : public A {
27 int x;
28 int y;
29 E() : A{y = 4}, x(y) { }
30 };
31
32 struct F {
33 F(int&) { }
34 };
35
36 struct G : F {
37 int x;
38 G() : F(x) { }
39 };
40
41 struct H {
42 H(int *) { }
43 };
44
45 struct I : H {
46 int x;
47 int arr[2];
48 I() : H(&x) { }
49 I(int) : H(arr) { }
50 };