blob: 3622da889845477f7c9e9561bdc59abf70b358c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
namespace X
{
//@BEGINRENAME; Verify this renames
//@ENDRENAME; Verify this renames
using System;
class Y
{
//extern("msvcrt.dll:printf") int printf(const char *fmt, ...);
//UInt32 int _exception_code();
/*
public static int filt(UInt32 a)
{
Console.WriteLine("Exception code = " + a);
return 1;
}
public static int filt0(UInt32 a)
{
Console.WriteLine("Exception code = " + a);
return 0;
}
*/
public static void bomb()
{
char[] p = null;
p[0] = (char)0;
}
public static int Main(String[] args)
{
UInt32 ec, ec1;
ec = (UInt32)0;
ec1 = (UInt32)0;
try
{
try
{
bomb();
}
//except(filt(ec = _exception_code()))
catch (NullReferenceException e)
{
ec = (UInt32)1;
Console.WriteLine("Caught the exception once, now throwing again.");
throw e;
}
}
//except(filt(ec1 = _exception_code()))
catch (NullReferenceException /*e1*/)
{
ec1 = (UInt32)2;
Console.WriteLine("'Outer' catch handler");
Console.WriteLine("Caught the exception [code1 = " + ec + "] [code2 = " + ec1 + "]");
}
// printf("Caught the exception [code1 = %08X] [code2 = %08X]\n", ec, ec1);
if ((ec != 0) && (ec1 != 0))
{
Console.WriteLine("Passed.");
return 100;
}
Console.WriteLine("Failed.");
return 1;
}
}
}
|