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[] = "SEH0028.c";
9*fe36f081STimo Kreuzer
addtwo(long First,long Second,long * Place)10*fe36f081STimo Kreuzer void addtwo(long First, long Second, long *Place) {
11*fe36f081STimo Kreuzer RaiseException(EXCEPTION_INT_OVERFLOW, 0, /*no flags*/ 0, 0);
12*fe36f081STimo Kreuzer /* not executed due to exception being raised */
13*fe36f081STimo Kreuzer *Place = First + Second;
14*fe36f081STimo Kreuzer return;
15*fe36f081STimo Kreuzer }
16*fe36f081STimo Kreuzer
main()17*fe36f081STimo Kreuzer int main() {
18*fe36f081STimo Kreuzer LONG Counter;
19*fe36f081STimo Kreuzer
20*fe36f081STimo Kreuzer Counter = 0;
21*fe36f081STimo Kreuzer
22*fe36f081STimo Kreuzer try {
23*fe36f081STimo Kreuzer /* set counter = 1 */
24*fe36f081STimo Kreuzer Counter += 1;
25*fe36f081STimo Kreuzer addtwo(0x7fff0000, 0x10000, &Counter);
26*fe36f081STimo Kreuzer }
27*fe36f081STimo Kreuzer except((GetExceptionCode() == (STATUS_INTEGER_OVERFLOW)) ? 1 : 0)
28*fe36f081STimo Kreuzer /* 1==EXECUTE HANDLER after unwinding */
29*fe36f081STimo Kreuzer {
30*fe36f081STimo Kreuzer /* set counter = 2 */
31*fe36f081STimo Kreuzer Counter += 1;
32*fe36f081STimo Kreuzer }
33*fe36f081STimo Kreuzer endtry
34*fe36f081STimo Kreuzer
35*fe36f081STimo Kreuzer if (Counter != 2) {
36*fe36f081STimo Kreuzer printf("TEST 28 FAILED. Counter = %d\n\r", Counter);
37*fe36f081STimo Kreuzer return -1;
38*fe36f081STimo Kreuzer }
39*fe36f081STimo Kreuzer
40*fe36f081STimo Kreuzer return 0;
41*fe36f081STimo Kreuzer }
42