Changeset 6437ce4
- Timestamp:
- Jul 6, 2020, 4:54:56 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 4d23dd2, b56f55c
- Parents:
- ac9ba12 (diff), 381132b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified libcfa/src/exception.c ¶
rac9ba12 r6437ce4 85 85 __cfadbg_print_safe(exception, "Throwing resumption exception\n"); 86 86 87 __attribute__((cleanup(reset_top_resume))) 88 struct __cfaehm_try_resume_node * original_head = context->top_resume; 89 struct __cfaehm_try_resume_node * current = context->top_resume; 90 91 for ( ; current ; current = current->next) { 92 context->top_resume = current->next; 93 if (current->handler(except)) { 94 return; 87 { 88 __attribute__((cleanup(reset_top_resume))) 89 struct __cfaehm_try_resume_node * original_head = context->top_resume; 90 struct __cfaehm_try_resume_node * current = context->top_resume; 91 92 for ( ; current ; current = current->next) { 93 context->top_resume = current->next; 94 if (current->handler(except)) { 95 return; 96 } 95 97 } 96 } 98 } // End the search and return to the top of the stack. 97 99 98 100 // No handler found, fall back to the default operation. -
TabularUnified tests/exceptions/.expect/defaults.txt ¶
rac9ba12 r6437ce4 3 3 jump default handler. 4 4 Catch unhandled_exception. 5 cross terminate throw 6 cross terminate default 7 cross terminate catch 8 cross resume throw 9 cross resume default 10 cross resume catch -
TabularUnified tests/exceptions/defaults.cfa ¶
rac9ba12 r6437ce4 30 30 throwResume (log_message){(char *)"Should be printed.\n"}; 31 31 } catchResume (log_message * this) { 32 printf( this->virtual_table->msg(this));32 printf("%s", this->virtual_table->msg(this)); 33 33 } 34 34 // But we don't have to: … … 69 69 } 70 70 71 TRIVIAL_EXCEPTION(second); 72 73 void cross_test(void) { 74 void defaultTerminationHandler(first &) { 75 printf("cross terminate default\n"); 76 throw (second){}; 77 } 78 void defaultResumptionHandler(first &) { 79 printf("cross resume default\n"); 80 throwResume (second){}; 81 } 82 try { 83 printf("cross terminate throw\n"); 84 throw (first){}; 85 } catch (second *) { 86 printf("cross terminate catch\n"); 87 } 88 try { 89 printf("cross resume throw\n"); 90 throwResume (first){}; 91 } catchResume (second *) { 92 printf("cross resume catch\n"); 93 } 94 } 95 71 96 int main(int argc, char * argv[]) { 72 97 log_test(); 73 98 jump_test(); 74 99 unhandled_test(); 100 cross_test(); 75 101 }
Note: See TracChangeset
for help on using the changeset viewer.