Author: raja
Date: 2005-07-07 05:50:44 -0400 (Thu, 07 Jul 2005)
New Revision: 47030

Added:
   trunk/mcs/errors/cs0282.cs
Modified:
   trunk/mcs/errors/ChangeLog
   trunk/mcs/errors/known-issues-gmcs
   trunk/mcs/errors/known-issues-mcs
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/class.cs
Log:
In mcs:
        Fix #75486.
        * class.cs (TypeContainer.first_nonstatic_field): Rename from
        has_nonstatic_fields.  Make into a FieldBase pointer.
        (TypeContainer.AddField): Add CS0282 check.
        (TypeContainer.EmitType): Update.

In errors:
        * cs0282.cs: New test from #75486.


Modified: trunk/mcs/errors/ChangeLog
===================================================================
--- trunk/mcs/errors/ChangeLog  2005-07-07 09:33:29 UTC (rev 47029)
+++ trunk/mcs/errors/ChangeLog  2005-07-07 09:50:44 UTC (rev 47030)
@@ -1,3 +1,7 @@
+2005-07-07  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       * cs0282.cs: New test from #75486.
+
 2005-07-05  Raja R Harinath  <[EMAIL PROTECTED]>
 
        * cs0212-2.cs: New test from #72729.

Added: trunk/mcs/errors/cs0282.cs
===================================================================
--- trunk/mcs/errors/cs0282.cs  2005-07-07 09:33:29 UTC (rev 47029)
+++ trunk/mcs/errors/cs0282.cs  2005-07-07 09:50:44 UTC (rev 47030)
@@ -0,0 +1,11 @@
+// cs0282.cs: struct instance field `S.y' found in different declaration from 
instance field `S.x'
+// Line: 8
+// Compiler options: -warn:4 -warnaserror
+
+partial struct S {
+       int x;
+}
+partial struct S {
+       int y;
+       static void Main () {}
+}

Modified: trunk/mcs/errors/known-issues-gmcs
===================================================================
--- trunk/mcs/errors/known-issues-gmcs  2005-07-07 09:33:29 UTC (rev 47029)
+++ trunk/mcs/errors/known-issues-gmcs  2005-07-07 09:50:44 UTC (rev 47030)
@@ -25,6 +25,7 @@
 cs0266.cs
 cs0266-2.cs NO ERROR
 cs0266-3.cs
+cs0282.cs
 cs0420.cs
 cs0420-2.cs
 cs0428.cs

Modified: trunk/mcs/errors/known-issues-mcs
===================================================================
--- trunk/mcs/errors/known-issues-mcs   2005-07-07 09:33:29 UTC (rev 47029)
+++ trunk/mcs/errors/known-issues-mcs   2005-07-07 09:50:44 UTC (rev 47030)
@@ -17,12 +17,9 @@
 cs0202.cs
 cs0229.cs NO ERROR
 cs0229-2.cs
-cs0245.cs
 cs0266.cs
 cs0266-2.cs NO ERROR
 cs0266-3.cs
-cs0420.cs
-cs0420-2.cs
 cs0428.cs
 cs0525.cs
 cs0526.cs

Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2005-07-07 09:33:29 UTC (rev 47029)
+++ trunk/mcs/mcs/ChangeLog     2005-07-07 09:50:44 UTC (rev 47030)
@@ -1,3 +1,11 @@
+2005-07-07  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       Fix #75486.
+       * class.cs (TypeContainer.first_nonstatic_field): Rename from
+       has_nonstatic_fields.  Make into a FieldBase pointer.
+       (TypeContainer.AddField): Add CS0282 check.
+       (TypeContainer.EmitType): Update.
+
 2005-07-06  Miguel de Icaza  <[EMAIL PROTECTED]>
 
        * cs-tokenizer.cs (consume_identifier): Do not create strings to

Modified: trunk/mcs/mcs/class.cs
===================================================================
--- trunk/mcs/mcs/class.cs      2005-07-07 09:33:29 UTC (rev 47029)
+++ trunk/mcs/mcs/class.cs      2005-07-07 09:50:44 UTC (rev 47030)
@@ -442,11 +442,14 @@
                protected Constructor default_static_constructor;
 
                //
-               // Whether we have at least one non-static field
+               // Points to the first non-static field added to the container.
                //
-               bool have_nonstatic_fields = false;
-               
+               // This is an arbitrary choice.  We are interested in looking 
at _some_ non-static field,
+               // and the first one's as good as any.
                //
+               FieldBase first_nonstatic_field = null;
+
+               //
                // This one is computed after we can distinguish interfaces
                // from classes from the arraylist `type_bases' 
                //
@@ -607,14 +610,28 @@
 
                        if (fields == null)
                                fields = new MemberCoreArrayList ();
-                       
+
                        fields.Add (field);
 
                        if (field.HasInitializer)
                                RegisterFieldForInitialization (field);
                        
-                       if ((field.ModFlags & Modifiers.STATIC) == 0)
-                               have_nonstatic_fields = true;
+                       if ((field.ModFlags & Modifiers.STATIC) != 0)
+                               return;
+
+                       if (first_nonstatic_field == null) {
+                               first_nonstatic_field = field;
+                               return;
+                       }
+
+                       if (Kind == Kind.Struct &&
+                           first_nonstatic_field.Parent != field.Parent &&
+                           RootContext.WarningLevel >= 3) {
+                               Report.SymbolRelatedToPreviousError 
(first_nonstatic_field.Parent);
+                               Report.Warning (282, field.Location,
+                                       "struct instance field `{0}' found in 
different declaration from instance field `{1}'",
+                                       field.GetSignatureForError (), 
first_nonstatic_field.GetSignatureForError ());
+                       }
                }
 
                public void AddProperty (Property prop)
@@ -2092,7 +2109,7 @@
                        // be specified.
                        //
 
-                       if ((Kind == Kind.Struct) && !have_nonstatic_fields){
+                       if (Kind == Kind.Struct && first_nonstatic_field == 
null){
                                FieldBuilder fb = TypeBuilder.DefineField 
("$PRIVATE$", TypeManager.byte_type,
                                                                           
FieldAttributes.Private);
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to