| Last change
 on this file since 16a843b was             4be0117, checked in by Andrew Beach <ajbeach@…>, 8 months ago | 
        
          | 
Cleaned the warnings from exceptions tests. Mostly explicit fallthrough which we do need for now. There was an error in defaults, although not one that mattered.
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            888 bytes | 
      
      
| Rev | Line |  | 
|---|
| [0a6d2045] | 1 | // Control Flow out of Termination Handler Clauses | 
|---|
|  | 2 |  | 
|---|
|  | 3 | exception zen {}; | 
|---|
|  | 4 |  | 
|---|
|  | 5 | vtable(zen) zen_vt; | 
|---|
|  | 6 |  | 
|---|
|  | 7 | void test_loop() { | 
|---|
|  | 8 | do { | 
|---|
|  | 9 | try { | 
|---|
|  | 10 | throw (zen){&zen_vt}; | 
|---|
|  | 11 | } catch (zen *) { | 
|---|
|  | 12 | printf("Continue\n"); | 
|---|
|  | 13 | continue; | 
|---|
|  | 14 | } | 
|---|
|  | 15 | printf("Reached end of loop.\n."); | 
|---|
|  | 16 | } while (false); | 
|---|
|  | 17 | printf("After Loop\n"); | 
|---|
|  | 18 |  | 
|---|
|  | 19 | while (true) { | 
|---|
|  | 20 | try { | 
|---|
|  | 21 | throw (zen){&zen_vt}; | 
|---|
|  | 22 | } catch (zen *) { | 
|---|
|  | 23 | printf("Break\n"); | 
|---|
|  | 24 | break; | 
|---|
|  | 25 | } | 
|---|
|  | 26 | printf("Reached end of loop.\n."); | 
|---|
|  | 27 | } | 
|---|
|  | 28 | printf("After Loop\n"); | 
|---|
|  | 29 | } | 
|---|
|  | 30 |  | 
|---|
|  | 31 | void test_switch() { | 
|---|
|  | 32 | switch (0) { | 
|---|
|  | 33 | case 0: | 
|---|
|  | 34 | try { | 
|---|
|  | 35 | throw (zen){&zen_vt}; | 
|---|
|  | 36 | } catch (zen *) { | 
|---|
|  | 37 | printf("Break\n"); | 
|---|
|  | 38 | break; | 
|---|
|  | 39 | } | 
|---|
| [4be0117] | 40 | fallthrough; | 
|---|
| [0a6d2045] | 41 | default: | 
|---|
|  | 42 | printf("Reached default.\n"); | 
|---|
|  | 43 | } | 
|---|
|  | 44 | printf("After Switch\n"); | 
|---|
|  | 45 | } | 
|---|
|  | 46 |  | 
|---|
|  | 47 | int test_return() { | 
|---|
|  | 48 | try { | 
|---|
|  | 49 | throw (zen){&zen_vt}; | 
|---|
|  | 50 | } catch (zen *) { | 
|---|
|  | 51 | return 1; | 
|---|
|  | 52 | } | 
|---|
|  | 53 | return 0; | 
|---|
|  | 54 | } | 
|---|
|  | 55 |  | 
|---|
| [d3cf623] | 56 | int main() { | 
|---|
| [0a6d2045] | 57 | test_loop(); | 
|---|
|  | 58 | test_switch(); | 
|---|
|  | 59 | printf("Result of test_return: %d\n", test_return()); | 
|---|
|  | 60 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.