blob: b8f2867eeda2efabc5896e56ff5e3534b0bc9dae (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):
struct CLike
{
int x;
int y;
// compiler synthesizes:
// __init(int x, int y);
}
struct ExplicitCtor
{
int x;
int y;
__init(int x)
{
this.x = x;
this.y = 0;
}
// compiler does not synthesize any ctors.
}
struct DefaultMember {
int x = 0;
int y = 1;
// compiler synthesizes:
// __init(int x = 0, int y = 1);
}
struct PartialInit1 {
int x;
int y = 1;
// compiler synthesizes:
// __init(int x, int y = 1);
}
struct PartialInit2 {
int x = 1;
int y; // warning: not all members are initialized.
// compiler synthesizes:
// __init(int x, int y);
}
void func1(CLike c)
{
}
void func2(ExplicitCtor e)
{
}
void func3(DefaultMember d)
{
}
void func4(PartialInit1 p)
{
}
void func5(PartialInit2 p)
{
}
void test()
{
CLike c; // `c` is uninitialized.
// CHECK: warning 41016: use of uninitialized variable 'c'
func1(c);
ExplicitCtor e; // `e` is uninitialized.
// CHECK: warning 41016: use of uninitialized variable 'e'
func2(e);
DefaultMember d; // `d` is uninitialized.
// CHECK: warning 41016: use of uninitialized variable 'd'
func3(d);
PartialInit1 p1; // `p` is uninitialized.
// CHECK: warning 41016: use of uninitialized variable 'p1'
func4(p1);
PartialInit2 p2; // `p` is uninitialized.
// CHECK: warning 41016: use of uninitialized variable 'p2'
func5(p2);
}
|