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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
using System;
using System.Reflection.Emit;
using Mono.Linker.Tests.Cases.Expectations.Assertions;
using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.UnreachableBlock
{
[SetupCompileArgument ("/optimize-")] // Relying on debug csc behaviour
public class ComplexConditions
{
public static void Main ()
{
Test_1 (null);
Test_2 (9);
}
[Kept]
#if !NETCOREAPP
[ExpectBodyModified]
#else
[ExpectedInstructionSequence (new [] {
"nop",
"ldarg.0",
"isinst",
"brtrue.s",
"call",
"pop",
"ldarg.0",
"isinst",
"ldnull",
"cgt.un",
"br.s",
"nop",
"br.s",
"ldc.i4.1",
"stloc.0",
"ldloc.0",
"brfalse.s",
"call",
"nop",
"ret"
})]
#endif
static void Test_1 (object type)
{
if (type is Type || (IsDynamicCodeSupported && type is TypeBuilder))
Reached_1 ();
}
[Kept]
#if !NETCOREAPP
[ExpectBodyModified]
#else
[ExpectedInstructionSequence (new [] {
"nop",
"call",
"stloc.1",
"ldloc.1",
"pop",
"ldc.i4.0",
"stloc.0",
"ldarg.0",
"ldc.i4.2",
"beq.s",
"ldarg.0",
"ldc.i4.3",
"ceq",
"br.s",
"ldc.i4.1",
"stloc.2",
"ldloc.2",
"brfalse.s",
"newobj",
"throw",
"newobj",
"throw"
})]
#endif
static void Test_2 (int a)
{
int zero;
if (IsDynamicCodeSupported)
zero = 0;
if (a == 2 || a == 3)
throw new ArgumentException ();
throw new ApplicationException ();
}
[Kept]
static bool IsDynamicCodeSupported {
[Kept]
get {
return true;
}
}
[Kept]
static void Reached_1 ()
{
}
}
}
|