1 // Copyright (c) Microsoft. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for
3 // full license information.
4 
5 #include <windows.h>
6 #include "seh.h"
7 
8 char test[] = "SEH0040.c";
9 
10 int main() {
11   ULONG Index1;
12   LONG Counter;
13 
14   Counter = 0;
15 
16   for (Index1 = 0; Index1 < 10; Index1 += 1) {
17     try {
18       try {
19         if ((Index1 & 0x1) == 1) {
20           /* end the loop when Index1 is 1 */
21           break;
22         } else {
23           /* add 1 to Counter if Index is 0 */
24           Counter += 1;
25         }
26       }
27       finally {
28         /*
29          * add 1 to Counter if Index is 0
30          * and after "break" when Index1 is 1
31          */
32         Counter += 2;
33       }
34       endtry
35       /* add 1 to Counter if Index is 0 */
36       Counter += 3;
37     }
38     finally {
39       /*
40        * add 1 to Counter if Index is 0
41        * and after "break" when Index1 is 1
42        */
43       Counter += 4;
44     }
45     endtry
46     /* add 1 to Counter if Index is 0 */
47     Counter += 5;
48   }
49 
50   if (Counter != 21) {
51     printf("TEST 40 FAILED. Counter = %d\n\r", Counter);
52     return -1;
53   }
54 
55   return 0;
56 }
57