Debian Codegraph @

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

raw
1 // PR c++/19808
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-Wuninitialized -Winit-self" }
4 // Test that we don't warn when initializing a reference, unless it's
5 // self-init.
6
7 struct R {
8 int &r;
9 };
10
11 struct S {
12 R r;
13 int a;
14 int &b;
15 int c;
16 };
17
18 struct X {
19 S s;
20 X() : s{ { s.a }, 1, s.c, 3} { }
21 };
22
23 struct A {
24 int &r;
25 A() : r{r} { } // { dg-warning ".A::r. is initialized with itself" }
26 };
27
28 struct B {
29 int &r;
30 int a;
31 B() : r{a} { }
32 };
33
34 struct C {
35 R x;
36 C() : x{x.r} { } // { dg-warning "member .C::x. is used uninitialized" }
37 };