Fix cs0208-7.cs and cs0208-8.cs.
authorRaja R Harinath <harinath@hurrynot.org>
Fri, 15 Apr 2005 15:14:32 +0000 (15:14 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Fri, 15 Apr 2005 15:14:32 +0000 (15:14 -0000)
* typemanager.cs (IsUnmanagedType): Arrays are not allowed
(cf. ECMA standard, behaviour of CSC 1.1 and CSC 2.0).  Improve
error reporting to point out the reason a struct is not unmanaged.

svn path=/trunk/mcs/; revision=43047

mcs/mcs/ChangeLog
mcs/mcs/typemanager.cs

index 5e9de1c7690cb9aa923702ba032cc68cb1d35650..7bf851ba43ed8fca66ac4f516a9a1c62b7206cee 100644 (file)
@@ -1,3 +1,10 @@
+2005-04-15  Raja R Harinath  <rharinath@novell.com>
+
+       Fix cs0208-7.cs and cs0208-8.cs.
+       * typemanager.cs (IsUnmanagedType): Arrays are not allowed
+       (cf. ECMA standard, behaviour of CSC 1.1 and CSC 2.0).  Improve
+       error reporting to point out the reason a struct is not unmanaged.
+
 2005-04-13  Atsushi Enomoto  <atsushi@ximian.com>
 
        * doc.cs : In FindDocumentedType(), avoid TypeExpr.ResolveType() and 
index d5f860323461527e587322f8066516ee66f9feaf..fd65890fb391b17f5aef06a5cd21fa59ed520217 100644 (file)
@@ -1523,27 +1523,22 @@ public class TypeManager {
        public static bool IsUnmanagedType (Type t)
        {
                // builtins that are not unmanaged types
-               if (t == TypeManager.object_type || t == TypeManager.string_type){
-                       Console.WriteLine ("A fucking string");
+               if (t == TypeManager.object_type || t == TypeManager.string_type)
                        return false;
-               }
 
                if (IsBuiltinOrEnum (t))
                        return true;
 
+               // Someone did the work of checking if the ElementType of t is unmanaged.  Let's not repeat it.
                if (t.IsPointer)
                        return true;
 
+               // Arrays are disallowed, even if we mark them with [MarshalAs(UnmanagedType.ByValArray, ...)]
                if (t.IsArray)
-                       return IsUnmanagedType (t.GetElementType ());
-
-               if (IsDelegateType (t))
-                       return true;
+                       return false;
 
-               if (!IsValueType (t)){
-                       Console.WriteLine ("No value type: " + t.FullName);
+               if (!IsValueType (t))
                        return false;
-               }
 
                if (t is TypeBuilder){
                        TypeContainer tc = LookupTypeContainer (t);
@@ -1556,7 +1551,7 @@ public class TypeManager {
                                if (f.MemberType == null)
                                        continue;
                                if (!IsUnmanagedType (f.MemberType)){
-                                       Console.WriteLine ("RECU on F: " + f.MemberType.FullName + " On " + t.FullName);
+                                       Report.SymbolRelatedToPreviousError (f.Location, CSharpName (t) + "." + f.Name);
                                        return false;
                                }
                        }
@@ -1565,12 +1560,12 @@ public class TypeManager {
                
                FieldInfo [] fields = t.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
 
-               foreach (FieldInfo f in fields)
+               foreach (FieldInfo f in fields){
                        if (!IsUnmanagedType (f.FieldType)){
-                               Console.WriteLine ("No value type Field: " + f.FieldType.FullName);
-
+                               Report.SymbolRelatedToPreviousError (f);
                                return false;
                        }
+               }
 
                return true;
        }
@@ -2270,10 +2265,6 @@ public class TypeManager {
                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))
-                       return true;
-
                Report.Error (
                        208, loc,
                        "Cannot take the address or size of a variable of a managed type ('" +