Author: raja
Date: 2005-04-01 09:27:58 -0500 (Fri, 01 Apr 2005)
New Revision: 42462

Added:
   trunk/mcs/errors/cs0208-4.cs
Modified:
   trunk/mcs/errors/ChangeLog
   trunk/mcs/errors/TestRunner.cs
   trunk/mcs/errors/gmcs-expect-no-error
   trunk/mcs/errors/known-issues-mcs
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/class.cs
   trunk/mcs/mcs/expression.cs
   trunk/mcs/mcs/typemanager.cs
Log:
In mcs:
2005-04-01  Raja R Harinath  <[EMAIL PROTECTED]>

        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.

In errors:
        * TestRunner.cs (TestRunner): Make "KNOWN ISSUE" messages slightly
        more verbose.
        * cs0208-4.cs: New test from #74232.


Modified: trunk/mcs/errors/ChangeLog
===================================================================
--- trunk/mcs/errors/ChangeLog  2005-04-01 14:09:39 UTC (rev 42461)
+++ trunk/mcs/errors/ChangeLog  2005-04-01 14:27:58 UTC (rev 42462)
@@ -1,5 +1,9 @@
 2005-04-01  Raja R Harinath  <[EMAIL PROTECTED]>
 
+       * 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  <[EMAIL PROTECTED]>

Modified: trunk/mcs/errors/TestRunner.cs
===================================================================
--- trunk/mcs/errors/TestRunner.cs      2005-04-01 14:09:39 UTC (rev 42461)
+++ trunk/mcs/errors/TestRunner.cs      2005-04-01 14:27:58 UTC (rev 42462)
@@ -273,7 +273,7 @@
 
                                case CompilerError.Wrong:
                                        if (know_issues.Contains (file)) {
-                                               LogLine ("KNOWN ISSUE");
+                                               LogLine ("KNOWN ISSUE (Wrong 
error reported)");
                                                know_issues.Remove (file);
                                                return false;
                                        }
@@ -289,7 +289,7 @@
 
                                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;
                                        }

Added: trunk/mcs/errors/cs0208-4.cs
===================================================================
--- trunk/mcs/errors/cs0208-4.cs        2005-04-01 14:09:39 UTC (rev 42461)
+++ trunk/mcs/errors/cs0208-4.cs        2005-04-01 14:27:58 UTC (rev 42462)
@@ -0,0 +1,15 @@
+// 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 ()
+       {
+       }
+}

Modified: trunk/mcs/errors/gmcs-expect-no-error
===================================================================
--- trunk/mcs/errors/gmcs-expect-no-error       2005-04-01 14:09:39 UTC (rev 
42461)
+++ trunk/mcs/errors/gmcs-expect-no-error       2005-04-01 14:27:58 UTC (rev 
42462)
@@ -20,6 +20,7 @@
 cs0186.cs
 cs0187-1.cs
 cs0187-2.cs
+cs0208-4.cs
 cs0229.cs
 cs0249.cs
 cs0266-2.cs

Modified: trunk/mcs/errors/known-issues-mcs
===================================================================
--- trunk/mcs/errors/known-issues-mcs   2005-04-01 14:09:39 UTC (rev 42461)
+++ trunk/mcs/errors/known-issues-mcs   2005-04-01 14:27:58 UTC (rev 42462)
@@ -19,7 +19,6 @@
 cs0157-5.cs NO ERROR
 cs0192-2.cs
 cs0201.cs
-cs0208-3.cs
 cs0229.cs NO ERROR
 cs0229-2.cs
 cs0245.cs
@@ -48,6 +47,7 @@
 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

Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2005-04-01 14:09:39 UTC (rev 42461)
+++ trunk/mcs/mcs/ChangeLog     2005-04-01 14:27:58 UTC (rev 42462)
@@ -1,3 +1,16 @@
+2005-04-01  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       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  <[EMAIL PROTECTED]>
 
        Fix #74241

Modified: trunk/mcs/mcs/class.cs
===================================================================
--- trunk/mcs/mcs/class.cs      2005-04-01 14:09:39 UTC (rev 42461)
+++ trunk/mcs/mcs/class.cs      2005-04-01 14:27:58 UTC (rev 42462)
@@ -4870,8 +4870,22 @@
                //
                // 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.
                //
@@ -4986,17 +5000,9 @@
                                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");
@@ -5306,16 +5312,9 @@
                        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;

Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2005-04-01 14:09:39 UTC (rev 42461)
+++ trunk/mcs/mcs/expression.cs 2005-04-01 14:27:58 UTC (rev 42462)
@@ -8542,6 +8542,11 @@
                                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);

Modified: trunk/mcs/mcs/typemanager.cs
===================================================================
--- trunk/mcs/mcs/typemanager.cs        2005-04-01 14:09:39 UTC (rev 42461)
+++ trunk/mcs/mcs/typemanager.cs        2005-04-01 14:27:58 UTC (rev 42462)
@@ -1521,7 +1521,7 @@
        //
        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))
@@ -1530,33 +1530,33 @@
                if (t.IsPointer)
                        return true;
 
-               if (IsValueType (t)){
-                       if (t is TypeBuilder){
-                               TypeContainer tc = LookupTypeContainer (t);
+               if (!IsValueType (t))
+                       return false;
 
-                               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 ();
-
-                               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)

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

Reply via email to