Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-928.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 290ee4d1fb3220513697625a67cf3a2e84bb1ef2 (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
// Compiler options: -unsafe

using System;
using System.Reflection;
using System.Linq;

unsafe class Program
{
	public static void Test ()
	{
		string s = "";
		unsafe {
			fixed (char *chars = s) {
			}
		}
	}

	public static bool StringNull (string s)
	{
		unsafe {
			fixed (char *a = s) {
				return a == null;
			}
		}
	}

	public static bool ArrayNull (int[] a)
	{
		unsafe {
			fixed (int *e = a) {
				return e == null;
			}
		}
	}

	public static int Main ()
	{
		Test ();

		var m = typeof (Program).GetMethod ("Test");
		var lv = m.GetMethodBody ().LocalVariables.Where (l => l.LocalType == typeof (char*)).Single ();
		if (lv.IsPinned)
			return 1;

		if (!StringNull (null))
			return 1;

		if (!ArrayNull (null))
			return 2;

		return 0;
	}
}