dlr bug
[mcs.git] / tests / test-301.cs
blob7f97577ff908e26c8a03f024dc46f9c3e44fd7ef
1 // Compiler options: -unsafe
3 using System;
4 using System.Runtime.InteropServices;
6 class A
8 [StructLayout (LayoutKind.Sequential)]
9 struct S { int x; }
11 public class B
13 [StructLayout (LayoutKind.Sequential)]
14 struct S { int x; int y; }
15 S s;
17 public B () {
18 string error = "";
20 unsafe {
21 if (typeof (S *).GetElementType () != typeof (A.B.S))
22 error += " composed cast (pointer),";
24 if (sizeof (S) != sizeof (A.B.S))
25 error += " sizeof,";
27 S *p1 = stackalloc S [1];
29 if ((*p1).GetType () != typeof (A.B.S))
30 error += " local declaration, 'stackalloc' keyword,";
32 fixed (S *p2 = &s) {
33 if ((*p2).GetType () != typeof (A.B.S))
34 error += " class declaration, 'fixed' statement,";
38 if (error.Length != 0)
39 throw new Exception ("The following couldn't resolve S as A+B+S:" + error);
43 public static void Main()
45 object o = new A.B();