2005-04-01 Raja R Harinath <rharinath@novell.com>
+ * TestRunner.cs (TestRunner): Make "KNOWN ISSUE" messages slightly
+ more verbose.
+ * cs0208-4.cs: New test from #74232.
+
* cs0267.cs: New. Mentioned in passing in #74309.
2005-03-29 Raja R Harinath <rharinath@novell.com>
case CompilerError.Wrong:
if (know_issues.Contains (file)) {
- LogLine ("KNOWN ISSUE");
+ LogLine ("KNOWN ISSUE (Wrong error reported)");
know_issues.Remove (file);
return false;
}
case CompilerError.Missing:
if (no_error_list.Contains (file)) {
- LogLine ("KNOW ISSUE");
+ LogLine ("KNOWN ISSUE (No error reported)");
no_error_list.Remove (file);
return false;
}
--- /dev/null
+// cs0208-4.cs: Cannot declare a pointer to a managed type ('System.Object')
+// Line: 11
+// Compiler options: -unsafe
+
+using System;
+using System.Runtime.InteropServices;
+
+class C
+{
+ [DllImport ("xml2")]
+ unsafe static extern object* valuePop (IntPtr context);
+ public static void Main ()
+ {
+ }
+}
cs0186.cs
cs0187-1.cs
cs0187-2.cs
+cs0208-4.cs
cs0229.cs
cs0249.cs
cs0266-2.cs
cs0157-5.cs NO ERROR
cs0192-2.cs
cs0201.cs
-cs0208-3.cs
cs0229.cs NO ERROR
cs0229-2.cs
cs0245.cs
cs1501-5.cs
cs1513.cs
cs1518.cs
+cs1521-2.cs # Probably not a real regression. The actual error message is correct
cs1525.cs
cs1528.cs
cs1535.cs
+2005-04-01 Raja R Harinath <rharinath@novell.com>
+
+ Fix #74232 and cs0208-3.cs.
+ * expression.cs (ComposedCast.DoResolveAsTypeStep): Add CS0208 check.
+ * typemanager.cs (IsUnmanagedType): Don't allow 'object' as an
+ unmanaged type. Don't use FieldBuilders when 't' is a
+ TypeBuilder. Use ModFlags and MemberType fields.
+ * class.cs (MemberBase.member_type): Rename from MemberType.
+ (MemberBase.MemberType): New property. Determines member_type on
+ demand.
+ (MemberBase.DoDefine): Don't initialize MemberType here.
+ (FieldMember.Define): Likewise.
+
2005-04-01 Marek Safar <marek.safar@seznam.cz>
Fix #74241
//
// The type of this property / indexer / event
//
- public Type MemberType;
+ Type member_type;
+ public Type MemberType {
+ get {
+ if (member_type == null && Type != null) {
+ EmitContext ec = Parent.EmitContext;
+ bool old_unsafe = ec.InUnsafe;
+ ec.InUnsafe = InUnsafe;
+ Type = Type.ResolveAsTypeTerminal (ec, false);
+ ec.InUnsafe = old_unsafe;
+
+ member_type = Type == null ? null : Type.Type;
+ }
+ return member_type;
+ }
+ }
//
// Whether this is an interface member.
flags = Modifiers.MethodAttr (ModFlags);
}
- // Lookup Type, verify validity
- bool old_unsafe = ec.InUnsafe;
- ec.InUnsafe = InUnsafe;
- Type = Type.ResolveAsTypeTerminal (ec, false);
- ec.InUnsafe = old_unsafe;
-
- if (Type == null)
+ if (MemberType == null)
return false;
- MemberType = Type.Type;
-
if ((Parent.ModFlags & Modifiers.SEALED) != 0){
if ((ModFlags & (Modifiers.VIRTUAL|Modifiers.ABSTRACT)) != 0){
Report.Error (549, Location, "Virtual method can not be contained in sealed class");
if (ec == null)
throw new InternalErrorException ("FieldMember.Define called too early");
- bool old_unsafe = ec.InUnsafe;
- ec.InUnsafe = InUnsafe;
- TypeExpr texpr = Type.ResolveAsTypeTerminal (ec, false);
- if (texpr == null)
+ if (MemberType == null)
return false;
- MemberType = texpr.ResolveType (ec);
-
- ec.InUnsafe = old_unsafe;
-
if (MemberType == TypeManager.void_type) {
Report.Error (1547, Location, "Keyword 'void' cannot be used in this context");
return false;
return null;
}
+ if (dim == "*" && !TypeManager.IsUnmanagedType (ltype)) {
+ Report.Error (208, loc, "Cannot declare a pointer to a managed type ('{0}')", ltype);
+ return null;
+ }
+
type = TypeManager.GetConstructedType (ltype, dim);
if (type == null) {
throw new InternalErrorException ("Couldn't create computed type " + ltype + dim);
//
public static bool IsUnmanagedType (Type t)
{
- if (IsBuiltinType (t) && t != TypeManager.string_type)
+ if (IsBuiltinType (t) && t != TypeManager.object_type && t != TypeManager.string_type)
return true;
if (IsEnumType (t))
if (t.IsPointer)
return true;
- if (IsValueType (t)){
- if (t is TypeBuilder){
- TypeContainer tc = LookupTypeContainer (t);
-
- if (tc.Fields != null){
- foreach (Field f in tc.Fields){
- if (f.FieldBuilder.IsStatic)
- continue;
- if (!IsUnmanagedType (f.FieldBuilder.FieldType))
- return false;
- }
- } else
- return true;
- } else {
- FieldInfo [] fields = t.GetFields ();
+ if (!IsValueType (t))
+ return false;
- foreach (FieldInfo f in fields){
- if (f.IsStatic)
- continue;
- if (!IsUnmanagedType (f.FieldType))
- return false;
- }
+ if (t is TypeBuilder){
+ TypeContainer tc = LookupTypeContainer (t);
+
+ if (tc.Fields == null)
+ return true;
+ foreach (Field f in tc.Fields){
+ // Avoid using f.FieldBuilder: f.Define () may not yet have been invoked.
+ if ((f.ModFlags & Modifiers.STATIC) != 0)
+ continue;
+ if (!IsUnmanagedType (f.MemberType))
+ return false;
}
return true;
}
-
- return false;
+
+ FieldInfo [] fields = t.GetFields ();
+
+ foreach (FieldInfo f in fields){
+ if (f.IsStatic)
+ continue;
+ if (!IsUnmanagedType (f.FieldType))
+ return false;
+ }
+ return true;
}
public static bool IsValueType (Type t)