[jit] Fix the saving of the 'cfg->ret_var_set' flag when inlining, it was set to...
[mono.git] / mcs / mcs / field.cs
index 824b5c781cd35c1ae8594baccd1240de36f31eda..da337a8261ab40ed86f89ad0d63b53e2aec3c2cc 100644 (file)
@@ -244,6 +244,10 @@ namespace Mono.CSharp
                                Module.PredefinedAttributes.Dynamic.EmitAttribute (FieldBuilder, member_type, Location);
                        }
 
+                       if (member_type.HasNamedTupleElement) {
+                               Module.PredefinedAttributes.TupleElementNames.EmitAttribute (FieldBuilder, member_type, Location);
+                       }
+
                        if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
                                Module.PredefinedAttributes.CompilerGenerated.EmitAttribute (FieldBuilder);
                        if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0)
@@ -257,7 +261,8 @@ namespace Mono.CSharp
                                Report.Error (625, Location, "`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) must have a FieldOffset attribute", GetSignatureForError ());
                        }
 
-                       ConstraintChecker.Check (this, member_type, type_expr.Location);
+                       if (!IsCompilerGenerated)
+                               ConstraintChecker.Check (this, member_type, type_expr.Location);
 
                        base.Emit ();
                }
@@ -311,7 +316,7 @@ namespace Mono.CSharp
                        }
                }
 
-#endregion
+               #endregion
 
                public FieldInfo GetMetaInfo ()
                {
@@ -394,7 +399,7 @@ namespace Mono.CSharp
                //
                // Explicit struct layout set by parent
                //
-               public CharSet? CharSet {
+               public CharSet? CharSetValue {
                        get; set;
                }               
 
@@ -493,8 +498,32 @@ namespace Mono.CSharp
                        }
 
                        AttributeEncoder encoder;
+                       MethodSpec ctor;
+
+                       var char_set = CharSetValue ?? Module.DefaultCharSet ?? 0;
+#if STATIC
+                       //
+                       // Set struct layout without resolving StructLayoutAttribute which is not always available
+                       //
 
-                       var ctor = Module.PredefinedMembers.StructLayoutAttributeCtor.Resolve (Location);
+                       TypeAttributes attribs = TypeAttributes.SequentialLayout;
+                       switch (char_set) {
+                       case CharSet.None:
+                       case CharSet.Ansi:
+                               attribs |= TypeAttributes.AnsiClass;
+                               break;
+                       case CharSet.Auto:
+                               attribs |= TypeAttributes.AutoClass;
+                               break;
+                       case CharSet.Unicode:
+                               attribs |= TypeAttributes.UnicodeClass;
+                               break;
+                       }
+
+                       fixed_buffer_type.__SetAttributes (fixed_buffer_type.Attributes | attribs);
+                       fixed_buffer_type.__SetLayout (0, buffer_size * type_size);
+#else
+                       ctor = Module.PredefinedMembers.StructLayoutAttributeCtor.Resolve (Location);
                        if (ctor == null)
                                return;
 
@@ -503,8 +532,6 @@ namespace Mono.CSharp
                        if (field_size == null || field_charset == null)
                                return;
 
-                       var char_set = CharSet ?? Module.DefaultCharSet ?? 0;
-
                        encoder = new AttributeEncoder ();
                        encoder.Encode ((short)LayoutKind.Sequential);
                        encoder.EncodeNamedArguments (
@@ -516,7 +543,7 @@ namespace Mono.CSharp
                        );
 
                        fixed_buffer_type.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ());
-
+#endif
                        //
                        // Don't emit FixedBufferAttribute attribute for private types
                        //