Merge pull request #5636 from BrzVlad/fix-xmm-scan
[mono.git] / mcs / tests / test-120.cs
1 //
2 // This tests checks that the compiler catches the special attributes
3 // for in a struct for CharSet, and turns the right bit on the TypeAttribute
4 //
5 using System;
6 using System.Reflection;
7 using System.Runtime.InteropServices;
8
9 [StructLayout(LayoutKind.Explicit, Size=32,CharSet=CharSet.Unicode)]
10 struct MyUnicode
11 {
12         [FieldOffset(0)] public float fh_float;
13         [FieldOffset(0)] public int fh_int;
14 }
15
16 [StructLayout(LayoutKind.Explicit, Size=32,CharSet=CharSet.Ansi)]
17 struct MyAnsi
18 {
19         [FieldOffset(0)] public float fh_float;
20         [FieldOffset(0)] public int fh_int;
21 }
22 [StructLayout(LayoutKind.Explicit, Size=32,CharSet=CharSet.Auto)]
23 struct MyAuto
24 {
25         [FieldOffset(0)] public float fh_float;
26         [FieldOffset(0)] public int fh_int;
27 }
28
29 class test
30 {
31         
32         public static int Main ()
33         {
34                 int errors = 0;
35                 Type t = typeof (MyUnicode);
36
37                 if ((t.Attributes & TypeAttributes.StringFormatMask) != TypeAttributes.UnicodeClass){
38                         Console.WriteLine ("Class MyUnicode does not have Unicode bit set");
39                         errors += 1;
40                 }
41
42                 t = typeof (MyAuto);
43                 if ((t.Attributes & TypeAttributes.StringFormatMask) != TypeAttributes.AutoClass){
44                         Console.WriteLine ("Class MyAuto does not have Auto bit set");
45                         errors += 2;
46                 }
47
48                 t = typeof (MyAnsi);
49
50                 if ((t.Attributes & TypeAttributes.StringFormatMask) != TypeAttributes.AnsiClass){
51                         Console.WriteLine ("Class MyUnicode does not have Ansi bit set");
52                         errors += 4;
53                 }
54
55                 return errors;
56         }
57 }