Просмотр исходного кода

*** Merged revisions from mcs: 50790

svn path=/trunk/mcs/; revision=51177
Raja R Harinath 20 лет назад
Родитель
Сommit
da245c00f8

+ 18 - 24
mcs/errors/known-issues-gmcs

@@ -11,15 +11,25 @@
 # csXXXX.cs NO ERROR	: error test case doesn't report any error. An exception is considered
 #			  as NO ERROR and CS5001 is automatically ignored.
 
+cs0029.cs
+cs0030-2.cs
 cs0201.cs
 cs0202.cs # new in GMCS
-cs0212-3.cs NO ERROR
 cs0229-2.cs
 cs0229.cs NO ERROR
 cs0266-2.cs NO ERROR
 cs0266-3.cs
+cs0266-4.cs
+cs0266-5.cs
+cs0266-6.cs
+cs0266-7.cs
 cs0266.cs
 cs0428.cs
+cs0443.cs
+cs0445-2.cs
+cs0445.cs
+cs0446-2.cs
+cs0446.cs NO ERROR
 cs0525.cs
 cs0526.cs
 cs0547-2.cs # new in GMCS; grammar issue
@@ -28,9 +38,16 @@ cs0548-4.cs
 cs0548.cs
 cs0560.cs
 cs0567.cs
+cs0612-2.cs NO ERROR
+cs0619-12.cs NO ERROR
+cs0619-4.cs  NO ERROR
+cs0619-42.cs
+cs0619-7.cs NO ERROR
+cs0619-8.cs NO ERROR
 cs0647-15.cs NO ERROR # corlib bug 73143
 cs1013.cs # new in GMCS; grammar issue
 cs1041.cs # new in GMCS; grammar issue
+cs1057.cs NO ERROR
 cs1501-5.cs
 cs1513.cs
 cs1518.cs
@@ -43,27 +60,4 @@ cs1586.cs
 cs1638.cs NO ERROR
 cs1641.cs
 cs1666.cs NO ERROR
-cs2007.cs
-
-cs0612-2.cs NO ERROR
-cs0619-42.cs
-cs0619-43.cs NO ERROR
-cs0619-45.cs NO ERROR
-cs0619-46.cs NO ERROR
-cs0619-31.cs NO ERROR
 cs1674-2.cs
-
-cs0134.cs NO ERROR
-cs0443.cs
-cs0445-2.cs
-cs0445.cs
-cs0446-2.cs
-cs0446.cs NO ERROR
-cs1057.cs NO ERROR
-
-cs0029.cs
-cs0030-2.cs
-cs0266-4.cs
-cs0266-5.cs
-cs0266-6.cs
-cs0266-7.cs

+ 31 - 0
mcs/gmcs/ChangeLog

@@ -1,3 +1,34 @@
+2005-09-26  Marek Safar  <[email protected]>
+
+	* attribute.cs (Attribute.Resolve): Check Obsolete attribute for
+	attributes.
+	
+	* class.cs (GeneratedBaseInitializer): New class for customization
+	compiler generated initializers.
+	(MemberBase.DoDefine): Check Obsolete attribute here.
+	(FieldMember.DoDefine): Ditto.
+	
+	* const.cs (ExternalConstant.CreateDecimal): Builder for decimal
+	constants.
+	
+	* decl.cs (MemberCore.EmitContext): Returns valid current ec.
+	(MemberCore.GetObsoleteAttribute): Removed argument.
+	(MemberCore.CheckObsoleteness): Obsolete attributes are hierarchic.
+	(MemberCore.CheckObsoleteType): New helper.
+	
+	* delegate.cs,
+	* enum.cs,
+	* statement.cs: Updates after MemberCore changes.
+	
+	* ecore.cs (TypeExpr.ResolveType): Check type obsoleteness here.
+	(FieldExpr.ResolveMemberAccess): Fixed decimal constants checks.
+	
+	* expression.cs (ComposedCast.DoResolveAsTypeStep): Don't check
+	obsolete attribute for compiler construct.
+	(As.DoResolve): Cache result.
+	
+	* iterators.cs (Define_Constructor): Use GeneratedBaseInitializer.
+
 2005-10-01  Miguel de Icaza  <[email protected]>
 
 	* expression.cs (Probe): instead of having a "Type probe_type"

+ 22 - 3
mcs/gmcs/attribute.cs

@@ -304,6 +304,11 @@ namespace Mono.CSharp {
 				return null;
 			}
 
+			ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (Type);
+			if (obsolete_attr != null) {
+				AttributeTester.Report_ObsoleteMessage (obsolete_attr, TypeManager.CSharpName (Type), Location);
+			}
+
 			if (Arguments == null) {
 				object o = att_cache [Type];
 				if (o != null) {
@@ -313,8 +318,14 @@ namespace Mono.CSharp {
 			}
 
 			ConstructorInfo ctor = ResolveArguments (ec);
-			if (ctor == null)
+			if (ctor == null) {
+				if (Type is TypeBuilder && 
+				    TypeManager.LookupDeclSpace (Type).MemberCache == null)
+					// The attribute type has been DefineType'd, but not Defined.  Let's not treat it as an error.
+					// It'll be resolved again when the attached-to entity is emitted.
+					resolve_error = false;
 				return null;
+			}
 
 			CustomAttributeBuilder cb;
 
@@ -509,6 +520,13 @@ namespace Mono.CSharp {
 				BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly,
                                 Location);
 
+			if (mg == null) {
+				// FIXME: Punt the issue for now.
+				if (Type is TypeBuilder)
+					return null;
+				throw new InternalErrorException ("Type " + Type + " doesn't have constructors");
+			}
+
 			MethodBase constructor = Invocation.OverloadResolve (
 				ec, (MethodGroupExpr) mg, pos_args, false, Location);
 
@@ -1677,11 +1695,12 @@ namespace Mono.CSharp {
 					if (attribute.Length == 1)
 						result = (ObsoleteAttribute)attribute [0];
 				} else {
-					result = type_ds.GetObsoleteAttribute (type_ds);
+					result = type_ds.GetObsoleteAttribute ();
 				}
 			}
 
-			analyzed_types_obsolete.Add (type, result == null ? FALSE : result);
+			// Cannot use .Add because of corlib bootstrap
+			analyzed_types_obsolete [type] = result == null ? FALSE : result;
 			return result;
 		}
 

+ 49 - 55
mcs/gmcs/class.cs

@@ -944,7 +944,7 @@ namespace Mono.CSharp {
 
 			c = new Constructor (constructor_parent, MemberName.Name, mods,
 					     Parameters.EmptyReadOnlyParameters,
-					     new ConstructorBaseInitializer (null, Location),
+					     new GeneratedBaseInitializer (Location),
 					     Location);
 			
 			AddConstructor (c);
@@ -1302,6 +1302,9 @@ namespace Mono.CSharp {
 				}
 			}
 
+			// Avoid attributes check when parent is not set
+			TypeResolveEmitContext.TestObsoleteMethodUsage = false;
+
 			if (base_type != null) {
 				// FIXME: I think this should be ...ResolveType (Parent.EmitContext).
 				//        However, if Parent == RootContext.Tree.Types, its NamespaceEntry will be null.
@@ -1328,8 +1331,17 @@ namespace Mono.CSharp {
 				return null;
 			}
 
-			if (ptype != null)
+			if (ptype != null) {
 				TypeBuilder.SetParent (ptype);
+			}
+
+			// Attribute is undefined at the begining of corlib compilation
+			if (TypeManager.obsolete_attribute_type != null) {
+				TypeResolveEmitContext.TestObsoleteMethodUsage = GetObsoleteAttribute () == null;
+				if (ptype != null && TypeResolveEmitContext.TestObsoleteMethodUsage) {
+					CheckObsoleteType (base_type);
+				}
+			}
 
 			// add interfaces that were not added at type creation
 			if (iface_exprs != null) {
@@ -1417,7 +1429,7 @@ namespace Mono.CSharp {
 					return false;
 				}
 
-				CurrentType = current_type.Type;
+				CurrentType = current_type.ResolveType (ec);
 			}
 
 			return true;
@@ -2596,18 +2608,6 @@ namespace Mono.CSharp {
 			return false;
 		}
 
-		protected override void VerifyObsoleteAttribute()
-		{
-			CheckUsageOfObsoleteAttribute (TypeBuilder.BaseType);
-
-			if (ifaces == null)
-				return;
-
-			foreach (Type iface in ifaces) {
-				CheckUsageOfObsoleteAttribute (iface);
-			}
-		}
-
 		//
 		// IMemberContainer
 		//
@@ -3371,6 +3371,10 @@ namespace Mono.CSharp {
 				return parameter_info;
 			}
 		}
+
+		public override EmitContext EmitContext {
+			get { return ds.EmitContext; }
+		}
 		
 		public ToplevelBlock Block {
 			get {
@@ -3903,17 +3907,6 @@ namespace Mono.CSharp {
 			get { return "M:"; }
 		}
 
-		protected override void VerifyObsoleteAttribute()
-		{
-			base.VerifyObsoleteAttribute ();
-
-			if (parameter_types == null)
-				return;
-
-			foreach (Type type in parameter_types) {
-				CheckUsageOfObsoleteAttribute (type);
-			}
-		}
 	}
 
 	public class SourceMethod : ISourceMethod
@@ -4393,11 +4386,6 @@ namespace Mono.CSharp {
 			return ec;
 		}
 
-		public ObsoleteAttribute GetObsoleteAttribute ()
-		{
-			return GetObsoleteAttribute (ds);
-		}
-
 		/// <summary>
 		/// Returns true if method has conditional attribute and the conditions is not defined (method is excluded).
 		/// </summary>
@@ -4538,7 +4526,7 @@ namespace Mono.CSharp {
 			return true;
 		}
 
-		public void Emit (EmitContext ec)
+		public virtual void Emit (EmitContext ec)
 		{
 			if (base_constructor != null){
 				ec.Mark (loc, false);
@@ -4557,6 +4545,21 @@ namespace Mono.CSharp {
 		}
 	}
 
+	class GeneratedBaseInitializer: ConstructorBaseInitializer {
+		public GeneratedBaseInitializer (Location loc):
+			base (null, loc)
+		{
+		}
+
+		public override void Emit(EmitContext ec)
+		{
+			bool old = ec.TestObsoleteMethodUsage;
+			ec.TestObsoleteMethodUsage = false;
+			base.Emit (ec);
+			ec.TestObsoleteMethodUsage = old;
+		}
+	}
+
 	public class ConstructorThisInitializer : ConstructorInitializer {
 		public ConstructorThisInitializer (ArrayList argument_list, Location l) :
 			base (argument_list, l)
@@ -4759,7 +4762,7 @@ namespace Mono.CSharp {
 
 			if ((ModFlags & Modifiers.STATIC) == 0){
 				if (Parent.Kind == Kind.Class && Initializer == null)
-					Initializer = new ConstructorBaseInitializer (null, Location);
+					Initializer = new GeneratedBaseInitializer (Location);
 
 
 				//
@@ -4793,7 +4796,7 @@ namespace Mono.CSharp {
 				}
 			}
 			if (Initializer != null) {
-				if (GetObsoleteAttribute () != null || Parent.GetObsoleteAttribute (Parent) != null)
+				if (GetObsoleteAttribute () != null || Parent.GetObsoleteAttribute () != null)
 					ec.TestObsoleteMethodUsage = false;
 
 				Initializer.Emit (ec);
@@ -4895,11 +4898,6 @@ namespace Mono.CSharp {
 			return new EmitContext (Parent, Location, ig_, null, ModFlags, true);
 		}
 
-		public ObsoleteAttribute GetObsoleteAttribute ()
-		{
-			return GetObsoleteAttribute (Parent);
-		}
-
 		public bool IsExcluded(EmitContext ec)
 		{
 			return false;
@@ -5224,7 +5222,7 @@ namespace Mono.CSharp {
 			else
 				ec = method.CreateEmitContext (container, null);
 
-			if (method.GetObsoleteAttribute () != null || container.GetObsoleteAttribute (container) != null)
+			if (method.GetObsoleteAttribute () != null || container.GetObsoleteAttribute () != null)
 				ec.TestObsoleteMethodUsage = false;
 
 			Attributes OptAttributes = method.OptAttributes;
@@ -5348,8 +5346,9 @@ namespace Mono.CSharp {
 					ec.InUnsafe = InUnsafe;
 					Type = Type.ResolveAsTypeTerminal (ec);
 					ec.InUnsafe = old_unsafe;
-
-					member_type = Type == null ? null : Type.Type;
+					if (Type != null) {
+						member_type = Type.Type;
+					}
 				}
 				return member_type;
 			}
@@ -5478,7 +5477,7 @@ namespace Mono.CSharp {
 				if (iface_texpr == null)
 					return false;
 
-				InterfaceType = iface_texpr.Type;
+				InterfaceType = iface_texpr.ResolveType (ec);
 
 				if (!InterfaceType.IsInterface) {
 					Report.Error (538, Location, "'{0}' in explicit interface declaration is not an interface", TypeManager.CSharpName (InterfaceType));
@@ -5505,6 +5504,8 @@ namespace Mono.CSharp {
 			if (MemberType == null)
 				return false;
 
+			CheckObsoleteType (Type);
+
 			if ((Parent.ModFlags & Modifiers.SEALED) != 0 && 
 				(ModFlags & (Modifiers.VIRTUAL|Modifiers.ABSTRACT)) != 0) {
 					Report.Error (549, Location, "New virtual member `{0}' is declared in a sealed class `{1}'",
@@ -5591,10 +5592,6 @@ namespace Mono.CSharp {
 			return false;
 		}
 
-		protected override void VerifyObsoleteAttribute()
-		{
-			CheckUsageOfObsoleteAttribute (MemberType);
-		}
 	}
 
 	//
@@ -5806,9 +5803,11 @@ namespace Mono.CSharp {
 			if (ec == null)
 				throw new InternalErrorException ("FieldMember.Define called too early");
 
-			if (MemberType == null)
+			if (MemberType == null || Type == null)
 				return false;
 			
+			CheckObsoleteType (Type);
+
 			if (MemberType == TypeManager.void_type) {
 				Report.Error (1547, Location, "Keyword 'void' cannot be used in this context");
 				return false;
@@ -6237,7 +6236,6 @@ namespace Mono.CSharp {
 			}
 		}
 
-		public abstract ObsoleteAttribute GetObsoleteAttribute ();
 		public abstract Type[] ParameterTypes { get; }
 		public abstract Type ReturnType { get; }
 		public abstract EmitContext CreateEmitContext(TypeContainer tc, ILGenerator ig);
@@ -6352,10 +6350,6 @@ namespace Mono.CSharp {
 			get { throw new InvalidOperationException ("Unexpected attempt to get doc comment from " + this.GetType () + "."); }
 		}
 
-		protected override void VerifyObsoleteAttribute()
-		{
-		}
-
 	}
 
 	//
@@ -6586,7 +6580,7 @@ namespace Mono.CSharp {
 
 			public override ObsoleteAttribute GetObsoleteAttribute ()
 			{
-				return method.GetObsoleteAttribute (method.ds);
+				return method.GetObsoleteAttribute ();
 			}
 
 			public override string GetSignatureForError()
@@ -7292,7 +7286,7 @@ namespace Mono.CSharp {
 
 			public override ObsoleteAttribute GetObsoleteAttribute ()
 			{
-				return method.GetObsoleteAttribute (method.Parent);
+				return method.GetObsoleteAttribute ();
 			}
 
 			public override string[] ValidAttributeTargets {

+ 26 - 0
mcs/gmcs/const.cs

@@ -174,6 +174,32 @@ namespace Mono.CSharp {
 			this.fi = fi;
 		}
 
+		private ExternalConstant (FieldInfo fi, Constant value):
+			this (fi)
+		{
+			this.value = value;
+		}
+
+		//
+		// Decimal constants cannot be encoded in the constant blob, and thus are marked
+		// as IsInitOnly ('readonly' in C# parlance).  We get its value from the 
+		// DecimalConstantAttribute metadata.
+		//
+		public static IConstant CreateDecimal (FieldInfo fi)
+		{
+			if (fi is FieldBuilder)
+				return null;
+			
+			object[] attrs = fi.GetCustomAttributes (TypeManager.decimal_constant_attribute_type, false);
+			if (attrs.Length != 1)
+				return null;
+
+			IConstant ic = new ExternalConstant (fi,
+				new DecimalConstant (((System.Runtime.CompilerServices.DecimalConstantAttribute) attrs [0]).Value, Location.Null));
+
+			return ic;
+		}
+
 		#region IConstant Members
 
 		public void CheckObsoleteness (Location loc)

+ 31 - 28
mcs/gmcs/decl.cs

@@ -382,21 +382,6 @@ namespace Mono.CSharp {
 			cached_name = null;
 		}
 
-		/// <summary>
-		/// Tests presence of ObsoleteAttribute and report proper error
-		/// </summary>
-		protected void CheckUsageOfObsoleteAttribute (Type type)
-		{
-			if (type == null)
-				return;
-
-			ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (type);
-			if (obsolete_attr == null)
-				return;
-
-			AttributeTester.Report_ObsoleteMessage (obsolete_attr, type.FullName, Location);
-		}
-
 		public abstract bool Define ();
 
 		// 
@@ -415,16 +400,19 @@ namespace Mono.CSharp {
 		/// </summary>
 		public virtual void Emit ()
 		{
-			// Hack with Parent == null is for EnumMember
-			if (Parent == null || (GetObsoleteAttribute (Parent) == null && Parent.GetObsoleteAttribute (Parent) == null))
-				VerifyObsoleteAttribute ();
-
 			if (!RootContext.VerifyClsCompliance)
 				return;
 
 			VerifyClsCompliance (Parent);
 		}
 
+		public virtual EmitContext EmitContext
+		{
+			get {
+				return Parent.EmitContext;
+			}
+		}
+
 		public bool InUnsafe {
 			get {
 				return ((ModFlags & Modifiers.UNSAFE) != 0) || Parent.UnsafeContext;
@@ -463,7 +451,7 @@ namespace Mono.CSharp {
 		/// <summary>
 		/// Returns instance of ObsoleteAttribute for this MemberCore
 		/// </summary>
-		public ObsoleteAttribute GetObsoleteAttribute (DeclSpace ds)
+		public virtual ObsoleteAttribute GetObsoleteAttribute ()
 		{
 			// ((flags & (Flags.Obsolete_Undetected | Flags.Obsolete)) == 0) is slower, but why ?
 			if ((caching_flags & Flags.Obsolete_Undetected) == 0 && (caching_flags & Flags.Obsolete) == 0) {
@@ -476,11 +464,11 @@ namespace Mono.CSharp {
 				return null;
 
 			Attribute obsolete_attr = OptAttributes.Search (
-				TypeManager.obsolete_attribute_type, ds.EmitContext);
+				TypeManager.obsolete_attribute_type, EmitContext);
 			if (obsolete_attr == null)
 				return null;
 
-			ObsoleteAttribute obsolete = obsolete_attr.GetObsoleteAttribute (ds.EmitContext);
+			ObsoleteAttribute obsolete = obsolete_attr.GetObsoleteAttribute (EmitContext);
 			if (obsolete == null)
 				return null;
 
@@ -491,9 +479,12 @@ namespace Mono.CSharp {
 		/// <summary>
 		/// Checks for ObsoleteAttribute presence. It's used for testing of all non-types elements
 		/// </summary>
-		public void CheckObsoleteness (Location loc)
+		public virtual void CheckObsoleteness (Location loc)
 		{
-			ObsoleteAttribute oa = GetObsoleteAttribute (Parent);
+			if (Parent != null)
+				Parent.CheckObsoleteness (loc);
+
+			ObsoleteAttribute oa = GetObsoleteAttribute ();
 			if (oa == null) {
 				return;
 			}
@@ -501,6 +492,18 @@ namespace Mono.CSharp {
 			AttributeTester.Report_ObsoleteMessage (oa, GetSignatureForError (), loc);
 		}
 
+		protected void CheckObsoleteType (Expression type)
+		{
+			ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (type.Type);
+			if (obsolete_attr == null)
+				return;
+
+			if (GetObsoleteAttribute () != null || Parent.GetObsoleteAttribute () != null)
+				return;
+
+			AttributeTester.Report_ObsoleteMessage (obsolete_attr, TypeManager.CSharpName (type.Type), type.Location);
+		}
+
 		/// <summary>
 		/// Analyze whether CLS-Compliant verification must be execute for this MemberCore.
 		/// </summary>
@@ -602,8 +605,6 @@ namespace Mono.CSharp {
 			return true;
 		}
 
-		protected abstract void VerifyObsoleteAttribute ();
-
 		//
 		// Raised (and passed an XmlElement that contains the comment)
 		// when GenerateDocComment is writing documentation expectedly.
@@ -675,8 +676,10 @@ namespace Mono.CSharp {
 		// The emit context for toplevel objects.
 		protected EmitContext ec;
 		
-		public EmitContext EmitContext {
-			get { return ec; }
+		public override EmitContext EmitContext {
+			get {
+				return ec;
+			}
 		}
 
 		//

+ 6 - 12
mcs/gmcs/delegate.cs

@@ -222,14 +222,16 @@ namespace Mono.CSharp {
 					return false;
 			}
 			
- 			ReturnType = ReturnType.ResolveAsTypeTerminal (ec);
-                        if (ReturnType == null)
-                            return false;
+			ReturnType = ReturnType.ResolveAsTypeTerminal (ec, false);
+			if (ReturnType == null)
+				return false;
                         
-   			ret_type = ReturnType.Type;
+			ret_type = ReturnType.Type;
 			if (ret_type == null)
 				return false;
 
+			CheckObsoleteType (ReturnType);
+
 			if (!Parent.AsAccessible (ret_type, ModFlags)) {
 				Report.Error (58, Location,
 					      "Inconsistent accessibility: return type `" +
@@ -721,14 +723,6 @@ namespace Mono.CSharp {
 			get { return "T:"; }
 		}
 
-		protected override void VerifyObsoleteAttribute()
-		{
-			CheckUsageOfObsoleteAttribute (ret_type);
-
-			foreach (Type type in param_types) {
-				CheckUsageOfObsoleteAttribute (type);
-			}
-		}
 	}
 
 	//

+ 22 - 32
mcs/gmcs/ecore.cs

@@ -145,18 +145,6 @@ namespace Mono.CSharp {
 		// Not nice but we have broken hierarchy
 		public virtual void CheckMarshallByRefAccess (Type container) {}
 
-		/// <summary>
-		/// Tests presence of ObsoleteAttribute and report proper error
-		/// </summary>
-		protected void CheckObsoleteAttribute (Type type)
-		{
-			ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (type);
-			if (obsolete_attr == null)
-				return;
-
-			AttributeTester.Report_ObsoleteMessage (obsolete_attr, type.FullName, loc);
-		}
-
 		public virtual string GetSignatureForError ()
 		{
 			return TypeManager.CSharpName (type);
@@ -284,6 +272,7 @@ namespace Mono.CSharp {
 			if ((ct != null) && !ec.ResolvingTypeTree && !ct.CheckConstraints (ec))
 				return null;
 
+			te.loc = loc;
 			return te;
 		}
 
@@ -2281,12 +2270,19 @@ namespace Mono.CSharp {
 
 		protected abstract TypeExpr DoResolveAsTypeStep (EmitContext ec);
 
-		public virtual Type ResolveType (EmitContext ec)
+		public Type ResolveType (EmitContext ec)
 		{
 			TypeExpr t = ResolveAsTypeTerminal (ec);
 			if (t == null)
 				return null;
 
+			if (ec.TestObsoleteMethodUsage) {
+				ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (t.Type);
+				if (obsolete_attr != null) {
+					AttributeTester.Report_ObsoleteMessage (obsolete_attr, Name, Location);
+				}
+			}
+
 			return t.Type;
 		}
 
@@ -2493,7 +2489,7 @@ namespace Mono.CSharp {
 			if (texpr == null)
 				return null;
 
-			Type type = texpr.Type;
+			Type type = texpr.ResolveType (ec);
 			int num_args = TypeManager.GetNumberOfTypeArguments (type);
 
 			if (args != null) {
@@ -2948,10 +2944,19 @@ namespace Mono.CSharp {
 		{
 			FieldInfo fi = FieldInfo.Mono_GetGenericFieldDefinition ();
 
-			if (fi.IsLiteral) {
+			Type t = fi.FieldType;
+
+			if (fi.IsLiteral || (fi.IsInitOnly && t == TypeManager.decimal_type)) {
 				IConstant ic = TypeManager.GetConstant (fi);
 				if (ic == null) {
-					ic = new ExternalConstant (fi);
+					if (fi.IsLiteral) {
+						ic = new ExternalConstant (fi);
+					} else {
+						ic = ExternalConstant.CreateDecimal (fi);
+						if (ic == null) {
+							return base.ResolveMemberAccess (ec, left, loc, original);
+						}
+					}
 					TypeManager.RegisterConstant (fi, ic);
 				}
 
@@ -2967,21 +2972,6 @@ namespace Mono.CSharp {
 
 				return ic.Value;
 			}
-
-			bool is_emitted = fi is FieldBuilder;
-			Type t = fi.FieldType;
-			
-			//
-			// Decimal constants cannot be encoded in the constant blob, and thus are marked
-			// as IsInitOnly ('readonly' in C# parlance).  We get its value from the 
-			// DecimalConstantAttribute metadata.
-			//
-			//TODO: incorporate in GetContant otherwise we miss all error checks + obsoleteness check
-			if (fi.IsInitOnly && !is_emitted && t == TypeManager.decimal_type) {
-				object[] attrs = fi.GetCustomAttributes (TypeManager.decimal_constant_attribute_type, false);
-				if (attrs.Length == 1)
-					return new DecimalConstant (((System.Runtime.CompilerServices.DecimalConstantAttribute) attrs [0]).Value, Location.Null);
-			}
 			
 			if (t.IsPointer && !ec.InUnsafe) {
 				UnsafeError (loc);
@@ -3031,7 +3021,7 @@ namespace Mono.CSharp {
 					return null;
 			}
 
-			if (!in_initializer) {
+			if (!in_initializer && !ec.IsFieldInitializer) {
 				ObsoleteAttribute oa;
 				FieldBase f = TypeManager.GetField (FieldInfo);
 				if (f != null) {

+ 13 - 10
mcs/gmcs/enum.cs

@@ -84,6 +84,19 @@ namespace Mono.CSharp {
 			return true;
 		}
 
+		// Because parent is TypeContainer and we have DeclSpace only
+		public override void CheckObsoleteness (Location loc)
+		{
+			parent_enum.CheckObsoleteness (loc);
+
+			ObsoleteAttribute oa = GetObsoleteAttribute ();
+			if (oa == null) {
+				return;
+			}
+
+			AttributeTester.Report_ObsoleteMessage (oa, GetSignatureForError (), loc);
+		}
+
 		public bool ResolveValue ()
 		{
 			if (value != null)
@@ -172,11 +185,6 @@ namespace Mono.CSharp {
 			return base.VerifyClsCompliance (parent_enum);
 		}
 
-		// There is no base type
-		protected override void VerifyObsoleteAttribute()
-		{
-		}
-
 		public override string DocCommentHeader {
 			get { return "F:"; }
 		}
@@ -381,11 +389,6 @@ namespace Mono.CSharp {
 			}
 		}
 
-		protected override void VerifyObsoleteAttribute()
-		{
-			// UnderlyingType is never obsolete
-		}
-
 		//
 		// Generates xml doc comments (if any), and if required,
 		// handle warning report.

+ 26 - 34
mcs/gmcs/expression.cs

@@ -1054,9 +1054,7 @@ namespace Mono.CSharp {
 			probe_type_expr = ProbeType.ResolveAsTypeTerminal (ec);
 			if (probe_type_expr == null)
 				return null;
-			Type probe_type = probe_type_expr.Type;
-
-			CheckObsoleteAttribute (probe_type);
+			Type probe_type = probe_type_expr.ResolveType (ec);
 
 			expr = expr.Resolve (ec);
 			if (expr == null)
@@ -1210,6 +1208,7 @@ namespace Mono.CSharp {
 		}
 
 		bool do_isinst = false;
+		Expression resolved_type;
 		
 		public override void Emit (EmitContext ec)
 		{
@@ -1230,10 +1229,12 @@ namespace Mono.CSharp {
 		
 		public override Expression DoResolve (EmitContext ec)
 		{
-			Expression e = base.DoResolve (ec);
+			if (resolved_type == null) {
+				resolved_type = base.DoResolve (ec);
 
-			if (e == null)
-				return null;
+				if (resolved_type == null)
+					return null;
+			}
 
 			type = probe_type_expr.Type;
 			eclass = ExprClass.Value;
@@ -1270,7 +1271,7 @@ namespace Mono.CSharp {
 				}
 			}
 			
-			e = Convert.ImplicitConversion (ec, expr, type, loc);
+			Expression e = Convert.ImplicitConversion (ec, expr, type, loc);
 			if (e != null){
 				expr = e;
 				do_isinst = false;
@@ -1848,9 +1849,7 @@ namespace Mono.CSharp {
 			if (target == null)
 				return null;
 			
-			type = target.Type;
-
-			CheckObsoleteAttribute (type);
+			type = target.ResolveType (ec);
 
 			if (type.IsAbstract && type.IsSealed) {
 				Report.Error (716, loc, "Cannot convert to static type `{0}'", TypeManager.CSharpName (type));
@@ -3994,11 +3993,7 @@ namespace Mono.CSharp {
 
 		override public Expression DoResolveLValue (EmitContext ec, Expression right_side)
 		{
-			Expression ret = DoResolveBase (ec, right_side);
-			if (ret != null)
-				CheckObsoleteAttribute (ret.Type);
-
-			return ret;
+			return DoResolveBase (ec, right_side);
 		}
 
 		public bool VerifyFixed ()
@@ -6224,19 +6219,15 @@ namespace Mono.CSharp {
 			if (texpr == null)
 				return null;
 
+			type = texpr.ResolveType (ec);
+
 			if (Arguments == null) {
 				Expression c = Constantify (type);
 				if (c != null)
 					return c;
 			}
 
-			type = texpr.Type;
-			if (type == null)
-				return null;
-			
-			CheckObsoleteAttribute (type);
-
-		        if (TypeManager.IsDelegateType (type)) {
+			if (TypeManager.IsDelegateType (type)) {
 				RequestedType = (new NewDelegate (type, Arguments, loc)).Resolve (ec);
 				if (RequestedType != null)
 					if (!(RequestedType is DelegateCreation))
@@ -6709,12 +6700,12 @@ namespace Mono.CSharp {
 			// Lookup the type
 			//
 			TypeExpr array_type_expr;
-			array_type_expr = new ComposedCast (requested_base_type, array_qualifier.ToString (), loc);
+			array_type_expr = new ComposedCast (requested_base_type, array_qualifier.ToString ());
 			array_type_expr = array_type_expr.ResolveAsTypeTerminal (ec);
 			if (array_type_expr == null)
 				return false;
 
-			type = array_type_expr.Type;
+			type = array_type_expr.ResolveType (ec);
 
 			if (!type.IsArray) {
 				Error (622, "Can only use array initializer expressions to assign to array types. Try using a new expression instead.");
@@ -7445,7 +7436,7 @@ namespace Mono.CSharp {
 			if (texpr == null)
 				return null;
 
-			typearg = texpr.Type;
+			typearg = texpr.ResolveType (ec);
 
 			if (typearg == TypeManager.void_type) {
 				Error (673, "System.Void cannot be used from C#. Use typeof (void) to get the void type object");
@@ -7456,7 +7447,6 @@ namespace Mono.CSharp {
 				UnsafeError (loc);
 				return null;
 			}
-			CheckObsoleteAttribute (typearg);
 
 			type = TypeManager.type_type;
 			// Even though what is returned is a type object, it's treated as a value by the compiler.
@@ -7519,7 +7509,7 @@ namespace Mono.CSharp {
 				return null;
 			}
 
-			type_queried = texpr.Type;
+			type_queried = texpr.ResolveType (ec);
 
 			int size_of = GetTypeSize (type_queried);
 			if (size_of > 0) {
@@ -7532,8 +7522,6 @@ namespace Mono.CSharp {
 				return null;
 			}
 
-			CheckObsoleteAttribute (type_queried);
-
 			if (!TypeManager.VerifyUnManaged (type_queried, loc)){
 				return null;
 			}
@@ -7641,15 +7629,16 @@ namespace Mono.CSharp {
 	///   Implements the member access expression
 	/// </summary>
 	public class MemberAccess : Expression {
-		public readonly string Identifier;  // TODO: LocatedToken
+		public readonly string Identifier;
 		Expression expr;
 		TypeArguments args;
 		
+		// TODO: Location can be removed
 		public MemberAccess (Expression expr, string id, Location l)
 		{
 			this.expr = expr;
 			Identifier = id;
-			loc = l;
+			loc = expr.Location;
 		}
 
 		public MemberAccess (Expression expr, string id, TypeArguments args,
@@ -7816,7 +7805,7 @@ namespace Mono.CSharp {
 			if (tnew_expr == null)
 				return null;
 
-			Type expr_type = tnew_expr.Type;
+			Type expr_type = tnew_expr.ResolveType (ec);
 
 			if (expr_type.IsPointer){
 				Error (23, "The `.' operator can not be applied to pointer operands (" +
@@ -9068,7 +9057,10 @@ namespace Mono.CSharp {
 			if (lexpr == null)
 				return null;
 
-			Type ltype = lexpr.Type;
+			bool old = ec.TestObsoleteMethodUsage;
+			ec.TestObsoleteMethodUsage = true;
+			Type ltype = lexpr.ResolveType (ec);
+			ec.TestObsoleteMethodUsage = old;
 
 			if ((ltype == TypeManager.void_type) && (dim != "*")) {
 				Report.Error (1547, Location,
@@ -9250,7 +9242,7 @@ namespace Mono.CSharp {
 			if (texpr == null)
 				return null;
 
-			otype = texpr.Type;
+			otype = texpr.ResolveType (ec);
 
 			if (!TypeManager.VerifyUnManaged (otype, loc))
 				return null;

+ 0 - 8
mcs/gmcs/generic.cs

@@ -737,9 +737,6 @@ namespace Mono.CSharp {
 			return true;
 		}
 
-		protected override void VerifyObsoleteAttribute ()
-		{ }
-
 		public override void ApplyAttributeBuilder (Attribute a,
 							    CustomAttributeBuilder cb)
 		{ }
@@ -1499,11 +1496,6 @@ namespace Mono.CSharp {
 			// FIXME
 		}
 
-		protected override void VerifyObsoleteAttribute()
-		{
-			// FIXME
-		}
-
 		public override AttributeTargets AttributeTargets {
 			get {
 				return AttributeTargets.Method | AttributeTargets.ReturnValue;

+ 1 - 1
mcs/gmcs/iterators.cs

@@ -707,7 +707,7 @@ namespace Mono.CSharp {
 
 			ctor = new Constructor (
 				this, MemberName.Name, Modifiers.PUBLIC, ctor_params,
-				new ConstructorBaseInitializer (null, Location),
+				new GeneratedBaseInitializer (Location),
 				Location);
 			AddConstructor (ctor);
 

+ 4 - 17
mcs/gmcs/statement.cs

@@ -55,16 +55,7 @@ namespace Mono.CSharp {
 
 			return ok;
 		}
-		
-		protected void CheckObsolete (Type type)
-		{
-			ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (type);
-			if (obsolete_attr == null)
-				return;
-
-			AttributeTester.Report_ObsoleteMessage (obsolete_attr, type.FullName, loc);
-		}
-		
+				
 		/// <summary>
 		///   Return value indicates whether all code paths emitted return.
 		/// </summary>
@@ -1060,7 +1051,7 @@ namespace Mono.CSharp {
 				if (texpr == null)
 					return false;
 				
-				VariableType = texpr.Type;
+				VariableType = texpr.ResolveType (ec);
 			}
 
 			if (VariableType == TypeManager.void_type) {
@@ -3373,9 +3364,7 @@ namespace Mono.CSharp {
 			if (texpr == null)
 				return false;
 
-			expr_type = texpr.Type;
-
-			CheckObsolete (expr_type);
+			expr_type = texpr.ResolveType (ec);
 
 			data = new Emitter [declarators.Count];
 
@@ -3595,8 +3584,6 @@ namespace Mono.CSharp {
 
 					type = te.ResolveType (ec);
 
-					CheckObsolete (type);
-
 					if (type != TypeManager.exception_type && !type.IsSubclassOf (TypeManager.exception_type)){
 						Error (155, "The type caught or thrown must be derived from System.Exception");
 						return false;
@@ -3822,7 +3809,7 @@ namespace Mono.CSharp {
 			if (texpr == null)
 				return false;
 
-			expr_type = texpr.Type;
+			expr_type = texpr.ResolveType (ec);
 
 			//
 			// The type must be an IDisposable or an implicit conversion

+ 5 - 3
mcs/gmcs/typemanager.cs

@@ -2122,12 +2122,14 @@ public partial class TypeManager {
 			if (texpr == null)
 				return null;
 
-			if (new_ifaces.Contains (texpr.Type))
+			Type itype = texpr.ResolveType (ec);
+
+			if (new_ifaces.Contains (itype))
 				continue;
 
-			new_ifaces.Add (texpr.Type);
+			new_ifaces.Add (itype);
 			
-			Type [] implementing = texpr.Type.GetInterfaces ();
+			Type [] implementing = itype.GetInterfaces ();
 
 			foreach (Type imp in implementing){
 				if (!new_ifaces.Contains (imp))

+ 2 - 0
mcs/tests/gtest-207.cs

@@ -1,3 +1,5 @@
+// Note that this test actually checks if we compiled mscorlib.dll properly.
+
 class M {
   static void p (string x) {
     System.Console.WriteLine (x);

+ 1 - 8
mcs/tests/known-issues-gmcs

@@ -4,17 +4,10 @@
 # csXXXX.cs		: test case causes error
 # csXXXX.cs IGNORE 	: adds test to ignore list
 
-gtest-179.cs IGNORE
 gtest-187.cs IGNORE
-test-439.cs IGNORE		# Compiles to invalid IL
-test-442.cs IGNORE		# Compiles to invalid IL
-test-453.cs IGNORE
-test-454.cs IGNORE
-test-456.cs
+test-442.cs IGNORE	# Causes runtime to crash
 
 test-50.cs IGNORE	# Windows-only test
 test-67.cs IGNORE	# Windows-only test
 test-anon-27.cs
 test-xml-027.cs
-test-iter-12.cs
-test-294.cs