-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathConsistency.cs
More file actions
67 lines (57 loc) · 1.52 KB
/
Consistency.cs
File metadata and controls
67 lines (57 loc) · 1.52 KB
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
using System;
class Consistency
{
int Field;
void Splitting(bool b)
{
try
{
if (b) throw new System.Exception();
}
finally
{
var i = 1;
Use(i);
}
}
void DoubleDef()
{
// This is, in principle, a double definition of `c.Field`: one for the
// qualifier `c`, and one for `Field` via the call to `Out`. The SSA library
// makes the choice to only include the former definition
Out(out Consistency c);
Use(c.Field);
Use(c.Field);
}
void Out(out Consistency c)
{
c = new Consistency();
c.Field = 0;
}
void CapturedDeclNoInit()
{
int i; // Should not get an SSA definition
Action a = () => { i = 0; Use(i); };
}
void StructDeclNoInit()
{
S s; // Should get an SSA definition
s.I = 0;
Use(s);
}
ref int GetElement(int[] a, int i) => ref a[i];
void Ref(int[] a)
{
var i = GetElement(a, 0); // Should *not* get an SSA definition
i = 0; // Should *not* get an SSA definition
ref var j = ref GetElement(a, 0); // Should *not* get an SSA definition
ref var k = ref GetElement(a, 0); // Should get an SSA definition
k = 0; // Should get an SSA definition
k = 1; // Should get an SSA definition
}
void Use<T>(T x) { }
}
struct S
{
public int I;
}