[mcs] Fixes regression introduced by a0fc3f4dcf571edc997f53066c09671650e96670 to...
authorMarek Safar <marek.safar@gmail.com>
Tue, 20 Jun 2017 22:14:05 +0000 (00:14 +0200)
committerMarek Safar <marek.safar@gmail.com>
Tue, 20 Jun 2017 22:14:05 +0000 (00:14 +0200)
mcs/mcs/class.cs
mcs/tests/test-943.cs
mcs/tests/ver-il-net_4_x.xml

index d1aedad9971215c790a12e6adb52a332cdd52c79..ee417ec7ad5d2e297019767f451d0f61dde6f3e9 100644 (file)
@@ -2227,7 +2227,7 @@ namespace Mono.CSharp
                                Module.PredefinedAttributes.CompilerGenerated.EmitAttribute (TypeBuilder);
 
 #if STATIC
-                       if (Kind == MemberKind.Struct && HasInstanceField) {
+                       if (Kind == MemberKind.Struct && !HasStructLayout && HasInstanceField) {
                                TypeBuilder.__SetLayout (0, 0);
                        }
 
index 088e2f74742f2cd71643b4e30ebde7cd4a4da1e4..ace5ef940b4f795d2efdf830dce8b22524dc05ce 100644 (file)
@@ -1,10 +1,18 @@
 using System;
+using System.Runtime.InteropServices;
 
 public struct MyStruct
 {
        public int X { get; set; }
 }
 
+[StructLayout (LayoutKind.Sequential, Pack = 1)]
+public struct MyStruct2
+{
+    public IntPtr handle;
+    public uint type_reference;
+}
+
 class X
 {
        public static int Main ()
@@ -14,6 +22,14 @@ class X
                if (s.StructLayoutAttribute.Size != 0)
                        return 1;
 
+               var s2 = typeof (MyStruct2);
+
+               if (s2.StructLayoutAttribute.Size != 0)
+                       return 2;
+
+               if (s2.StructLayoutAttribute.Pack != 1)
+                       return 3;
+
                return 0;
        }
 }
\ No newline at end of file
index 5b1f686ddd765817d716aebf3bdc031df02dba1f..460fe02f0e126c5c93eb077380f6403f8ba1b625 100644 (file)
     </type>
     <type name="X">
       <method name="Int32 Main()" attrs="150">
-        <size>44</size>
+        <size>102</size>
       </method>
       <method name="Void .ctor()" attrs="6278">
         <size>7</size>