yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
9ec6b9168
master
1//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): 2 3struct CLike 4{ 5 int x; 6 int y; 7 // compiler synthesizes: 8 // __init(int x, int y); 9} 10 11struct ExplicitCtor 12{ 13 int x; 14 int y; 15 __init(int x) 16 { 17 this.x = x; 18 this.y = 0; 19 } 20 // compiler does not synthesize any ctors. 21} 22 23struct DefaultMember { 24 int x = 0; 25 int y = 1; 26 // compiler synthesizes: 27 // __init(int x = 0, int y = 1); 28} 29 30struct PartialInit1 { 31 int x; 32 int y = 1; 33 // compiler synthesizes: 34 // __init(int x, int y = 1); 35} 36 37struct PartialInit2 { 38 int x = 1; 39 int y; // warning: not all members are initialized. 40 // compiler synthesizes: 41 // __init(int x, int y); 42} 43 44void func1(CLike c) 45{ 46} 47 48void func2(ExplicitCtor e) 49{ 50} 51 52void func3(DefaultMember d) 53{ 54} 55 56void func4(PartialInit1 p) 57{ 58} 59 60void func5(PartialInit2 p) 61{ 62} 63 64void test() 65{ 66 CLike c; // `c` is uninitialized. 67 // CHECK: warning 41016: use of uninitialized variable 'c' 68 func1(c); 69 70 ExplicitCtor e; // `e` is uninitialized. 71 // CHECK: warning 41016: use of uninitialized variable 'e' 72 func2(e); 73 74 DefaultMember d; // `d` is uninitialized. 75 // CHECK: warning 41016: use of uninitialized variable 'd' 76 func3(d); 77 78 PartialInit1 p1; // `p` is uninitialized. 79 // CHECK: warning 41016: use of uninitialized variable 'p1' 80 func4(p1); 81 82 PartialInit2 p2; // `p` is uninitialized. 83 // CHECK: warning 41016: use of uninitialized variable 'p2' 84 func5(p2); 85}