2010-04-13 Sebastien Pouliot <sebastien@ximian.com>
[mono-project.git] / mcs / tests / test-305.cs
blob7f170f3aed3a3b7e68a42cddbe7a8ab6e135b1a3
1 // Compiler options: -unsafe
3 using System;
4 using System.Runtime.InteropServices;
6 using S = A.T;
8 class A
10 [StructLayout (LayoutKind.Sequential)]
11 public struct T { int x; }
13 public class B
15 [StructLayout (LayoutKind.Sequential)]
16 struct S { int x; int y; }
17 S s;
19 public B () {
20 string error = "";
22 unsafe {
23 if (typeof (S *).GetElementType () != typeof (A.B.S))
24 error += " composed cast (pointer),";
26 if (sizeof (S) != sizeof (A.B.S))
27 error += " sizeof,";
29 S *p1 = stackalloc S [1];
31 if ((*p1).GetType () != typeof (A.B.S))
32 error += " local declaration, 'stackalloc' keyword,";
34 fixed (S *p2 = &s) {
35 if ((*p2).GetType () != typeof (A.B.S))
36 error += " class declaration, 'fixed' statement,";
40 if (error.Length != 0)
41 throw new Exception ("The following couldn't resolve S as A+B+S:" + error);
45 public static void Main()
47 object o = new A.B();