[mini] Fix test compiling when running !MOBILE
[mono.git] / mcs / tests / test-301.cs
1 // Compiler options: -unsafe
2
3 using System;
4 using System.Runtime.InteropServices;
5
6 class A
7 {
8         [StructLayout (LayoutKind.Sequential)]
9         struct S { int x; }
10
11         public class B
12         {
13                 [StructLayout (LayoutKind.Sequential)]
14                 struct S { int x; int y; }
15                 S s;
16
17                 public B () {
18                         string error = "";
19
20                         unsafe {
21                                 if (typeof (S *).GetElementType () != typeof (A.B.S))
22                                         error += " composed cast (pointer),";
23
24                                 if (sizeof (S) != sizeof (A.B.S))
25                                         error += " sizeof,";
26
27                                 S *p1 = stackalloc S [1];
28
29                                 if ((*p1).GetType () != typeof (A.B.S))
30                                         error += " local declaration, 'stackalloc' keyword,";
31
32                                 fixed (S *p2 = &s) {
33                                         if ((*p2).GetType () != typeof (A.B.S))
34                                                 error += " class declaration, 'fixed' statement,";
35                                 }
36                         }
37
38                         if (error.Length != 0)
39                                 throw new Exception ("The following couldn't resolve S as A+B+S:" + error);
40                 }
41         }
42
43         public static void Main()
44         {
45                 object o = new A.B();
46         }
47 }