+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
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);
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;
}
}
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;
}
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 ('" +