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[] = "SEH0019.c";
9*fe36f081STimo Kreuzer 
fret(PLONG Counter)10*fe36f081STimo Kreuzer void fret(PLONG Counter) {
11*fe36f081STimo Kreuzer   try {
12*fe36f081STimo Kreuzer     try {
13*fe36f081STimo Kreuzer       /* set counter = 2 */
14*fe36f081STimo Kreuzer       *Counter += 1;
15*fe36f081STimo Kreuzer     }
16*fe36f081STimo Kreuzer     finally {
17*fe36f081STimo Kreuzer       /* set counter = 3 */
18*fe36f081STimo Kreuzer       *Counter += 1;
19*fe36f081STimo Kreuzer #ifdef _MSC_VER
20*fe36f081STimo Kreuzer       return;
21*fe36f081STimo Kreuzer #endif
22*fe36f081STimo Kreuzer     }
23*fe36f081STimo Kreuzer     endtry
24*fe36f081STimo Kreuzer #ifndef _MSC_VER
25*fe36f081STimo Kreuzer     return;
26*fe36f081STimo Kreuzer #endif
27*fe36f081STimo Kreuzer   }
28*fe36f081STimo Kreuzer   finally {
29*fe36f081STimo Kreuzer     /* set counter = 4 */
30*fe36f081STimo Kreuzer     *Counter += 1;
31*fe36f081STimo Kreuzer   }
32*fe36f081STimo Kreuzer   endtry
33*fe36f081STimo Kreuzer   return;
34*fe36f081STimo Kreuzer }
35*fe36f081STimo Kreuzer 
main()36*fe36f081STimo Kreuzer int main() {
37*fe36f081STimo Kreuzer   LONG Counter;
38*fe36f081STimo Kreuzer 
39*fe36f081STimo Kreuzer   Counter = 0;
40*fe36f081STimo Kreuzer 
41*fe36f081STimo Kreuzer   try {
42*fe36f081STimo Kreuzer     /* set counter = 1 */
43*fe36f081STimo Kreuzer     Counter += 1;
44*fe36f081STimo Kreuzer     fret(&Counter);
45*fe36f081STimo Kreuzer   }
46*fe36f081STimo Kreuzer   finally {
47*fe36f081STimo Kreuzer     /* set counter = 5 */
48*fe36f081STimo Kreuzer     Counter += 1;
49*fe36f081STimo Kreuzer   }
50*fe36f081STimo Kreuzer   endtry
51*fe36f081STimo Kreuzer 
52*fe36f081STimo Kreuzer   if (Counter != 5) {
53*fe36f081STimo Kreuzer     printf("TEST 19 FAILED. Counter = %d\n\r", Counter);
54*fe36f081STimo Kreuzer     return -1;
55*fe36f081STimo Kreuzer   }
56*fe36f081STimo Kreuzer 
57*fe36f081STimo Kreuzer   return 0;
58*fe36f081STimo Kreuzer }
59