Author: raja
Date: 2005-04-05 08:50:19 -0400 (Tue, 05 Apr 2005)
New Revision: 42559

Added:
   trunk/mcs/errors/cs0208-5.cs
   trunk/mcs/errors/cs0208-6.cs
Modified:
   trunk/mcs/errors/ChangeLog
   trunk/mcs/errors/gmcs-expect-no-error
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/typemanager.cs
Log:
In mcs:
2005-04-05  John Luke  <[EMAIL PROTECTED]>
            Raja R Harinath  <[EMAIL PROTECTED]>

        Fix #62232.
        * typemanager.cs (IsUnmanagedType): Check non-public fields of a
        struct too.  Return false quicker in a few cases.
        (VerifyUnManaged): Use it.

In errors:
        * cs0208-5.cs, cs0208-6.cs: New tests from #62232.


Modified: trunk/mcs/errors/ChangeLog
===================================================================
--- trunk/mcs/errors/ChangeLog  2005-04-05 12:48:03 UTC (rev 42558)
+++ trunk/mcs/errors/ChangeLog  2005-04-05 12:50:19 UTC (rev 42559)
@@ -1,3 +1,7 @@
+2005-04-05  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       * cs0208-5.cs, cs0208-6.cs: New tests from #62232.
+
 2005-04-04  Raja R Harinath  <[EMAIL PROTECTED]>
 
        * cs1521-2.cs: Change 'class' to a 'struct' to narrow down the

Added: trunk/mcs/errors/cs0208-5.cs
===================================================================
--- trunk/mcs/errors/cs0208-5.cs        2005-04-05 12:48:03 UTC (rev 42558)
+++ trunk/mcs/errors/cs0208-5.cs        2005-04-05 12:50:19 UTC (rev 42559)
@@ -0,0 +1,11 @@
+// cs0208-5.cs: Cannot declare a pointer to a managed type ('X')
+// Line: 8
+// Compiler options: -unsafe
+
+unsafe struct X {
+       string a;
+       static void Main () {
+               X* y;
+       }
+}
+

Added: trunk/mcs/errors/cs0208-6.cs
===================================================================
--- trunk/mcs/errors/cs0208-6.cs        2005-04-05 12:48:03 UTC (rev 42558)
+++ trunk/mcs/errors/cs0208-6.cs        2005-04-05 12:50:19 UTC (rev 42559)
@@ -0,0 +1,12 @@
+// cs0208-6.cs: Cannot take the address of a managed type ('System.Object')
+// Line: 8
+// Compiler options: -unsafe
+
+unsafe struct X {
+       string a;
+       static void Main () {
+               X x;
+               void* y = &x;
+       }
+}
+

Modified: trunk/mcs/errors/gmcs-expect-no-error
===================================================================
--- trunk/mcs/errors/gmcs-expect-no-error       2005-04-05 12:48:03 UTC (rev 
42558)
+++ trunk/mcs/errors/gmcs-expect-no-error       2005-04-05 12:50:19 UTC (rev 
42559)
@@ -21,6 +21,8 @@
 cs0187-1.cs
 cs0187-2.cs
 cs0208-4.cs
+cs0208-5.cs
+cs0208-6.cs
 cs0229.cs
 cs0249.cs
 cs0266-2.cs

Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2005-04-05 12:48:03 UTC (rev 42558)
+++ trunk/mcs/mcs/ChangeLog     2005-04-05 12:50:19 UTC (rev 42559)
@@ -1,3 +1,11 @@
+2005-04-05  John Luke  <[EMAIL PROTECTED]>
+           Raja R Harinath  <[EMAIL PROTECTED]>
+
+       Fix #62232.
+       * typemanager.cs (IsUnmanagedType): Check non-public fields of a
+       struct too.  Return false quicker in a few cases.
+       (VerifyUnManaged): Use it.
+
 2005-04-05  Raja R Harinath  <[EMAIL PROTECTED]>
 
        Fix #74041.

Modified: trunk/mcs/mcs/typemanager.cs
===================================================================
--- trunk/mcs/mcs/typemanager.cs        2005-04-05 12:48:03 UTC (rev 42558)
+++ trunk/mcs/mcs/typemanager.cs        2005-04-05 12:50:19 UTC (rev 42559)
@@ -1521,10 +1521,11 @@
        //
        public static bool IsUnmanagedType (Type t)
        {
-               if (IsBuiltinType (t) && t != TypeManager.object_type && t != 
TypeManager.string_type)
-                       return true;
+               // builtins that are not unmanaged types
+               if (t == TypeManager.object_type || t == 
TypeManager.string_type)
+                       return false;
 
-               if (IsEnumType (t))
+               if (IsBuiltinOrEnum (t))
                        return true;
 
                if (t.IsPointer)
@@ -1548,14 +1549,12 @@
                        return true;
                }
                
-               FieldInfo [] fields = t.GetFields ();
-               
-               foreach (FieldInfo f in fields){
-                       if (f.IsStatic)
-                               continue;
+               FieldInfo [] fields = t.GetFields (BindingFlags.Public | 
BindingFlags.NonPublic | BindingFlags.Instance);
+
+               foreach (FieldInfo f in fields)
                        if (!IsUnmanagedType (f.FieldType))
                                return false;
-               }
+
                return true;
        }
                
@@ -2251,18 +2250,11 @@
        /// </summary>
        public static bool VerifyUnManaged (Type t, Location loc)
        {
-               if (t.IsValueType || t.IsPointer){
-                       //
-                       // FIXME: this is more complex, we actually need to
-                       // make sure that the type does not contain any
-                       // classes itself
-                       //
+               if (IsUnmanagedType (t))
                        return true;
-               }
 
+               // We need this explicit check here to make it work when 
compiling corlib.
                if (!RootContext.StdLib && (t == TypeManager.decimal_type))
-                       // We need this explicit check here to make it work when
-                       // compiling corlib.
                        return true;
 
                Report.Error (

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

Reply via email to