diff options
author | Raja R Harinath <harinath@hurrynot.org> | 2004-10-05 15:33:05 +0400 |
---|---|---|
committer | Raja R Harinath <harinath@hurrynot.org> | 2004-10-05 15:33:05 +0400 |
commit | 62f2bd39d9931d45fe61f6a1f22337b0eb524f13 (patch) | |
tree | ad46892af33359f6786f474857016a1f28c58f41 /mcs/tests/test-301.cs | |
parent | fca6d5f5bc287af303a2dc254bcdb003eca8320e (diff) |
New testcases for type-resolution.
svn path=/trunk/mcs/; revision=34716
Diffstat (limited to 'mcs/tests/test-301.cs')
-rw-r--r-- | mcs/tests/test-301.cs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/mcs/tests/test-301.cs b/mcs/tests/test-301.cs new file mode 100644 index 00000000000..7f97577ff90 --- /dev/null +++ b/mcs/tests/test-301.cs @@ -0,0 +1,47 @@ +// Compiler options: -unsafe + +using System; +using System.Runtime.InteropServices; + +class A +{ + [StructLayout (LayoutKind.Sequential)] + struct S { int x; } + + public class B + { + [StructLayout (LayoutKind.Sequential)] + struct S { int x; int y; } + S s; + + public B () { + string error = ""; + + unsafe { + if (typeof (S *).GetElementType () != typeof (A.B.S)) + error += " composed cast (pointer),"; + + if (sizeof (S) != sizeof (A.B.S)) + error += " sizeof,"; + + S *p1 = stackalloc S [1]; + + if ((*p1).GetType () != typeof (A.B.S)) + error += " local declaration, 'stackalloc' keyword,"; + + fixed (S *p2 = &s) { + if ((*p2).GetType () != typeof (A.B.S)) + error += " class declaration, 'fixed' statement,"; + } + } + + if (error.Length != 0) + throw new Exception ("The following couldn't resolve S as A+B+S:" + error); + } + } + + public static void Main() + { + object o = new A.B(); + } +} |