Changeset 36dfdac
- Timestamp:
- Dec 11, 2024, 7:53:36 PM (6 days ago)
- Branches:
- master
- Children:
- bad15f7
- Parents:
- 5d3d281
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
r5d3d281 r36dfdac 218 218 __pass::resultNstmt<container_t> new_kids; 219 219 for ( auto value : enumerate( statements ) ) { 220 size_t i = value.idx; 221 const Stmt * stmt = value.val; 220 222 try { 221 size_t i = value.idx;222 const Stmt * stmt = value.val;223 223 __pedantic_pass_assert( stmt ); 224 224 const ast::Stmt * new_stmt = stmt->accept( *this ); … … 246 246 new_kids.take_all( stmts_after ); 247 247 } catch ( SemanticErrorException &e ) { 248 if ( auto dstmt = dynamic_cast<const DeclStmt *>( stmt ) ) { 249 assert( dstmt->decl->unique() ); 250 auto & declLink = const_cast< ptr<Decl> & >( dstmt->decl ); 251 if ( !__pass::on_error (core, declLink, 0) ) goto handled; 252 } 248 253 errors.append( e ); 254 handled:; 249 255 } 250 256 } -
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.