Author: martin
Date: 2005-04-30 03:54:00 -0400 (Sat, 30 Apr 2005)
New Revision: 43817
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/attribute.cs
trunk/mcs/gmcs/class.cs
trunk/mcs/gmcs/decl.cs
Log:
**** Merged r43579 from MCS ****
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2005-04-30 07:53:37 UTC (rev 43816)
+++ trunk/mcs/gmcs/ChangeLog 2005-04-30 07:54:00 UTC (rev 43817)
@@ -1,3 +1,15 @@
+2005-04-26 Marek Safar <[EMAIL PROTECTED]>
+
+ * attribute.cs (AreOverloadedMethodParamsClsCompliant): Add array
+ of arrays detection.
+
+ * class.cs (Interface.VerifyClsCompliance): Add base interfaces
+ verification.
+ (Field.VerifyClsCompliance): Volatile fields are not compliant.
+
+ * decl.cs (MemberCache.VerifyClsParameterConflict): Add array of
+ arrays report.
+
2005-04-25 Ben Maurer <[EMAIL PROTECTED]>
* cs-parser.jay: Use the prefered version of -unsafe in error
Modified: trunk/mcs/gmcs/attribute.cs
===================================================================
--- trunk/mcs/gmcs/attribute.cs 2005-04-30 07:53:37 UTC (rev 43816)
+++ trunk/mcs/gmcs/attribute.cs 2005-04-30 07:54:00 UTC (rev 43817)
@@ -1406,24 +1406,41 @@
{
}
+ public enum Result {
+ Ok,
+ RefOutArrayError,
+ ArrayArrayError
+ }
+
/// <summary>
/// Returns true if parameters of two compared methods are
CLS-Compliant.
/// It tests differing only in ref or out, or in array rank.
/// </summary>
- public static bool AreOverloadedMethodParamsClsCompliant
(Type[] types_a, Type[] types_b)
+ public static Result AreOverloadedMethodParamsClsCompliant
(Type[] types_a, Type[] types_b)
{
if (types_a == null || types_b == null)
- return true;
+ return Result.Ok;
if (types_a.Length != types_b.Length)
- return true;
+ return Result.Ok;
+ Result result = Result.Ok;
for (int i = 0; i < types_b.Length; ++i) {
Type aType = types_a [i];
Type bType = types_b [i];
- if (aType.IsArray && bType.IsArray &&
aType.GetArrayRank () != bType.GetArrayRank () && aType.GetElementType () ==
bType.GetElementType ()) {
- return false;
+ if (aType.IsArray && bType.IsArray) {
+ Type a_el_type = aType.GetElementType
();
+ Type b_el_type = bType.GetElementType
();
+ if (aType.GetArrayRank () !=
bType.GetArrayRank () && a_el_type == b_el_type) {
+ result =
Result.RefOutArrayError;
+ continue;
+ }
+
+ if (a_el_type.IsArray ||
b_el_type.IsArray) {
+ result = Result.ArrayArrayError;
+ continue;
+ }
}
Type aBaseType = aType;
@@ -1442,12 +1459,12 @@
}
if (aBaseType != bBaseType)
- continue;
+ return Result.Ok;
if (is_either_ref_or_out)
- return false;
+ result = Result.RefOutArrayError;
}
- return true;
+ return result;
}
/// <summary>
Modified: trunk/mcs/gmcs/class.cs
===================================================================
--- trunk/mcs/gmcs/class.cs 2005-04-30 07:53:37 UTC (rev 43816)
+++ trunk/mcs/gmcs/class.cs 2005-04-30 07:54:00 UTC (rev 43817)
@@ -3270,6 +3270,24 @@
}
}
+ protected override bool VerifyClsCompliance (DeclSpace ds)
+ {
+ if (!base.VerifyClsCompliance (ds))
+ return false;
+
+ if (ifaces != null) {
+ foreach (Type t in ifaces) {
+ if (AttributeTester.IsClsCompliant (t))
+ continue;
+
+ Report.SymbolRelatedToPreviousError (t);
+ Report.Warning (3027, 1, Location,
"'{0}' is not CLS-compliant because base interface '{1}' is not CLS-compliant",
+ GetSignatureForError (),
TypeManager.CSharpName (t));
+ }
+ }
+
+ return true;
+ }
}
public abstract class MethodCore : MemberBase {
@@ -6180,6 +6198,18 @@
return true;
}
+
+ protected override bool VerifyClsCompliance (DeclSpace ds)
+ {
+ if (!base.VerifyClsCompliance (ds))
+ return false;
+
+ if ((ModFlags & Modifiers.VOLATILE) != 0) {
+ Report.Warning (3026, 1, Location,
"CLS-compliant field '{0}' cannot be volatile", GetSignatureForError ());
+ }
+
+ return true;
+ }
}
//
@@ -6874,18 +6904,6 @@
Set.UpdateName (this);
}
- protected override bool VerifyClsCompliance (DeclSpace ds)
- {
- if (!base.VerifyClsCompliance (ds))
- return false;
-
- if ((Get.ModFlags != ModFlags && !Get.IsDummy) ||
(Set.ModFlags != ModFlags && !Set.IsDummy)) {
- Report.Error (3025, Get.ModFlags != ModFlags ?
Get.Location : Set.Location,
- "CLS-compliant accessors must have the
same accessibility as their property");
- }
- return true;
- }
-
public override string[] ValidAttributeTargets {
get {
return attribute_targets;
Modified: trunk/mcs/gmcs/decl.cs
===================================================================
--- trunk/mcs/gmcs/decl.cs 2005-04-30 07:53:37 UTC (rev 43816)
+++ trunk/mcs/gmcs/decl.cs 2005-04-30 07:54:00 UTC (rev 43817)
@@ -2320,7 +2320,10 @@
continue;
MethodBase method_to_compare =
(MethodBase)entry.Member;
- if
(AttributeTester.AreOverloadedMethodParamsClsCompliant (method.ParameterTypes,
TypeManager.GetArgumentTypes (method_to_compare)))
+ AttributeTester.Result result =
AttributeTester.AreOverloadedMethodParamsClsCompliant (
+ method.ParameterTypes,
TypeManager.GetArgumentTypes (method_to_compare));
+
+ if (result == AttributeTester.Result.Ok)
continue;
IMethodData md = TypeManager.GetMethod
(method_to_compare);
@@ -2331,7 +2334,16 @@
continue;
Report.SymbolRelatedToPreviousError
(entry.Member);
- Report.Error (3006, method.Location,
"Overloaded method '{0}' differing only in ref or out, or in array rank, is not
CLS-compliant", method.GetSignatureForError ());
+ switch (result) {
+ case
AttributeTester.Result.RefOutArrayError:
+ Report.Error (3006,
method.Location, "Overloaded method '{0}' differing only in ref or out, or in
array rank, is not CLS-compliant", method.GetSignatureForError ());
+ continue;
+ case
AttributeTester.Result.ArrayArrayError:
+ Report.Error (3007,
method.Location, "Overloaded method '{0}' differing only by unnamed array types
is not CLS-compliant", method.GetSignatureForError ());
+ continue;
+ }
+
+ throw new NotImplementedException
(result.ToString ());
}
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches