Changeset 9d6317f
- Timestamp:
- Jan 22, 2020, 3:40:27 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 69e398f
- Parents:
- 5518719
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/LabelFixer.cc
r5518719 r9d6317f 45 45 void LabelFixer::postvisit( FunctionDecl * functionDecl ) { 46 46 PassVisitor<MultiLevelExitMutator> mlem( resolveJumps(), generator ); 47 functionDecl->acceptMutator( mlem ); 47 // We start in the body so we can stop when we hit another FunctionDecl. 48 maybeMutate( functionDecl->statements, mlem ); 48 49 } 49 50 -
src/ControlStruct/MLEMutator.cc
r5518719 r9d6317f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Jan 21 10:33:00 202013 // Update Count : 22 212 // Last Modified On : Wed Jan 22 11:50:00 2020 13 // Update Count : 223 14 14 // 15 15 … … 60 60 } 61 61 } // namespace 62 63 void MultiLevelExitMutator::premutate( FunctionDecl * ) { 64 visit_children = false; 65 } 62 66 63 67 // break labels have to come after the statement they break out of, so mutate a statement, then if they inform us … … 352 356 }); 353 357 enclosingControlStructures = std::list<Entry>(); 358 GuardValue( inFinally ); 359 inFinally = true; 360 } 361 362 void MultiLevelExitMutator::premutate( ReturnStmt *returnStmt ) { 363 if ( inFinally ) { 364 SemanticError( returnStmt->location, "'return' may not appear in a finally clause" ); 365 } 354 366 } 355 367 -
src/ControlStruct/MLEMutator.h
r5518719 r9d6317f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Jan 21 10:33:00 202013 // Update Count : 4 712 // Last Modified On : Wed Jan 22 11:50:00 2020 13 // Update Count : 48 14 14 // 15 15 … … 38 38 ~MultiLevelExitMutator(); 39 39 40 void premutate( FunctionDecl * ); 41 40 42 void premutate( CompoundStmt *cmpndStmt ); 41 43 Statement * postmutate( BranchStmt *branchStmt ) throw ( SemanticErrorException ); … … 49 51 void premutate( SwitchStmt *switchStmt ); 50 52 Statement * postmutate( SwitchStmt *switchStmt ); 53 void premutate( ReturnStmt *returnStmt ); 51 54 void premutate( TryStmt *tryStmt ); 52 55 Statement * postmutate( TryStmt *tryStmt ); … … 113 116 Label breakLabel; 114 117 LabelGenerator *generator; 118 bool inFinally = false; 115 119 116 120 template< typename LoopClass > -
tests/.expect/except-finally-error.txt
r5518719 r9d6317f 11 11 except-finally-error.cfa:111:1 error: 'fallthrough' must be enclosed in a 'switch' or 'choose' 12 12 except-finally-error.cfa:124:1 error: 'fallthrough' must be enclosed in a 'switch' or 'choose' 13 except-finally-error.cfa:133:1 error: 'return' may not appear in a finally clause 14 except-finally-error.cfa:139:1 error: 'return' may not appear in a finally clause 15 except-finally-error.cfa:148:1 error: 'break' outside a loop, 'switch', or labelled block -
tests/except-finally-error.cfa
r5518719 r9d6317f 142 142 } 143 143 144 // Checked in the same place, make sure it does't break. 145 void break_in_function() { 146 while (true) { 147 void inner() { 148 break; 149 } 150 } 151 } 152 144 153 void main() { 145 154 // Should not compile.
Note: See TracChangeset
for help on using the changeset viewer.