Changeset 36dfdac for tests/raii
- Timestamp:
- Dec 11, 2024, 7:53:36 PM (7 days ago)
- Branches:
- master
- Children:
- bad15f7
- Parents:
- 5d3d281
- Location:
- tests/raii
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/raii/.expect/partial.txt
r5d3d281 r36dfdac 1 ====== Top-level declarations ====== 1 2 test1 2 3 custom ctor … … 15 16 custom ctor 16 17 custom dtor 18 ====== Function-nested declarations ====== 19 test1 20 custom ctor 21 test2 22 custom ctor 23 custom dtor 24 custom dtor 25 test3 26 test4 27 custom ctor 28 custom dtor 29 test5 30 custom ctor 31 custom dtor 32 test6 33 custom ctor 34 custom dtor -
tests/raii/partial.cfa
r5d3d281 r36dfdac 7 7 #define BAD(...) 8 8 #endif 9 10 void testAllNested() { 11 12 // Declaring your own empty ctor leaves an autogen dtor usable 13 struct thing1 {}; 14 void ?{}( thing1 & this ) { printf( "custom ctor\n"); } 15 void test1() { 16 printf("test1\n"); 17 thing1 x; 18 } 19 20 // Declaring your own empty ctor and dtor leaves an autogen copy ctor usable 21 struct thing2 {}; 22 void ?{}( thing2 & this ) { printf( "custom ctor\n"); } 23 void ^?{}( thing2 & this ) { printf( "custom dtor\n"); } 24 void test2() { 25 printf("test2\n"); 26 thing2 x; 27 thing2 y = x; 28 } 29 30 // Deleting the autogen copy ctor also deletes the autogen empty ctor 31 struct thing3 {}; 32 void ?{}( thing3 &, thing3 ) = void; 33 void test3() { 34 printf("test3\n"); 35 BAD( thing3 x; ) // Unique best alternative includes deleted identifier 36 } 37 38 struct thing456 {}; 39 void ?{}( thing456 & this ) { printf( "custom ctor\n"); } 40 void ?{}( thing456 &, thing456 ) = void; 41 thing456 & ?=?( thing456 &, thing456 ) = void; 42 void ^?{}( thing456 & this ) { printf( "custom dtor\n"); } 43 44 struct wrapper1 { thing456 x; }; 45 struct wrapper2 { wrapper1 x; }; 46 47 // Deleting some autogens and declaring your own for the others leaves yours usable 48 // and the deleted ones cleanly deleted 49 void test4() { 50 printf("test4\n"); 51 thing456 x; 52 BAD( thing456 y = x; ) // Unique best alternative includes deleted identifier 53 } 54 55 // Wrapping v4 leaves yours usable via autogen 56 // and the autogen-lifts of your deleted ones are not usable 57 void test5() { 58 printf("test5\n"); 59 wrapper1 x; 60 BAD( wrapper1 y = x; ) // Unique best alternative includes deleted identifier 61 } 62 63 // Wrapping again works similarly 64 void test6() { 65 printf("test6\n"); 66 wrapper2 x; 67 BAD( wrapper2 y = x; ) // Unique best alternative includes deleted identifier 68 } 69 70 test1(); 71 test2(); 72 test3(); 73 test4(); 74 test5(); 75 test6(); 76 } 77 78 // ===== Repeat, now as top-level declarations 9 79 10 80 // Declaring your own empty ctor leaves an autogen dtor usable … … 67 137 68 138 int main() { 139 printf("====== Top-level declarations ======\n"); 69 140 test1(); 70 141 test2(); … … 73 144 test5(); 74 145 test6(); 146 printf("====== Function-nested declarations ======\n"); 147 testAllNested(); 75 148 }
Note: See TracChangeset
for help on using the changeset viewer.