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