Author: marek
Date: 2005-04-08 06:32:50 -0400 (Fri, 08 Apr 2005)
New Revision: 42682
Modified:
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/attribute.cs
trunk/mcs/mcs/class.cs
trunk/mcs/mcs/expression.cs
trunk/mcs/mcs/iterators.cs
trunk/mcs/mcs/statement.cs
trunk/mcs/mcs/typemanager.cs
Log:
2005-04-08 Marek Safar <[EMAIL PROTECTED]>
* attribute.cs (Attribute.IsValidArgumentType): Test valid named
argument types.
(Attribute.Resolve): Add named argument type checking.
* class.cs (FixedField.Define): Use IsPrimitiveType
* expression.cs (Binary.ResolveOperator): Reflect IsCLRType renaming.
* iterators.cs (Iterator.DefineIterator): Add check for arglist and
unsafe parameter types.
* statement.cs (Using.ResolveExpression): Add better error description.
* typemanager.cs (IsCLRType): Renamed to IsPrimitiveType.
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2005-04-08 09:31:28 UTC (rev 42681)
+++ trunk/mcs/mcs/ChangeLog 2005-04-08 10:32:50 UTC (rev 42682)
@@ -1,3 +1,20 @@
+2005-04-08 Marek Safar <[EMAIL PROTECTED]>
+
+ * attribute.cs (Attribute.IsValidArgumentType): Test valid named
+ argument types.
+ (Attribute.Resolve): Add named argument type checking.
+
+ * class.cs (FixedField.Define): Use IsPrimitiveType
+
+ * expression.cs (Binary.ResolveOperator): Reflect IsCLRType renaming.
+
+ * iterators.cs (Iterator.DefineIterator): Add check for arglist and
+ unsafe parameter types.
+
+ * statement.cs (Using.ResolveExpression): Add better error description.
+
+ * typemanager.cs (IsCLRType): Renamed to IsPrimitiveType.
+
2005-04-08 Raja R Harinath <[EMAIL PROTECTED]>
Fix #74484.
Modified: trunk/mcs/mcs/attribute.cs
===================================================================
--- trunk/mcs/mcs/attribute.cs 2005-04-08 09:31:28 UTC (rev 42681)
+++ trunk/mcs/mcs/attribute.cs 2005-04-08 10:32:50 UTC (rev 42682)
@@ -113,6 +113,11 @@
name);
}
+ void Error_InvalidNamedAgrumentType (string name)
+ {
+ Report.Error (655, Location, "'{0}' is not a valid
named attribute argument because its type is not valid attribute type", name);
+ }
+
static void Error_AttributeArgumentNotValid (string extra,
Location loc)
{
Report.Error (182, loc,
@@ -279,7 +284,17 @@
Error_AttributeArgumentNotValid (loc);
return false;
}
-
+
+ bool IsValidArgumentType (Type t)
+ {
+ return TypeManager.IsPrimitiveType (t) ||
+ (t.IsArray && TypeManager.IsPrimitiveType
(t.GetElementType ())) ||
+ TypeManager.IsEnumType (t) ||
+ t == TypeManager.string_type ||
+ t == TypeManager.object_type ||
+ t == TypeManager.type_type;
+ }
+
// Cache for parameter-less attributes
static PtrHashtable att_cache = new PtrHashtable ();
@@ -427,6 +442,12 @@
return null;
}
+ if (!IsValidArgumentType
(pi.PropertyType)) {
+
Report.SymbolRelatedToPreviousError (pi);
+ Error_InvalidNamedAgrumentType
(member_name);
+ return null;
+ }
+
object value;
if (!GetAttributeArgumentExpression (e,
Location, pi.PropertyType, out value))
return null;
@@ -443,6 +464,12 @@
return null;
}
+ if (!IsValidArgumentType
(fi.FieldType)) {
+
Report.SymbolRelatedToPreviousError (fi);
+ Error_InvalidNamedAgrumentType
(member_name);
+ return null;
+ }
+
object value;
if (!GetAttributeArgumentExpression (e,
Location, fi.FieldType, out value))
return null;
@@ -498,7 +525,7 @@
}
object value = pos_values [j];
- if (value != null && a.Type != value.GetType ()
&& a.Type.IsPrimitive) {
+ if (value != null && a.Type != value.GetType ()
&& TypeManager.IsPrimitiveType (a.Type)) {
bool fail;
pos_values [j] = TypeManager.ChangeType
(value, a.Type, out fail);
if (fail) {
Modified: trunk/mcs/mcs/class.cs
===================================================================
--- trunk/mcs/mcs/class.cs 2005-04-08 09:31:28 UTC (rev 42681)
+++ trunk/mcs/mcs/class.cs 2005-04-08 10:32:50 UTC (rev 42682)
@@ -5471,7 +5471,7 @@
if (!base.Define ())
return false;
- if (!MemberType.IsPrimitive) {
+ if (!TypeManager.IsPrimitiveType (MemberType)) {
Report.Error (1663, Location, "Fixed sized
buffer type must be one of the following: bool, byte, short, int, long, char,
sbyte, ushort, uint, ulong, float or double");
return false;
}
@@ -6069,7 +6069,7 @@
flags = method.flags;
} else {
if ((method.ModFlags &
Modifiers.ABSTRACT) != 0 && (ModFlags & Modifiers.PRIVATE) != 0) {
- Report.Error (422, Location,
"{0}': abstract properties cannot have private accessors", GetSignatureForError
(container));
+ Report.Error (442, Location,
"{0}': abstract properties cannot have private accessors", GetSignatureForError
(container));
}
CheckModifiers (container, ModFlags);
Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2005-04-08 09:31:28 UTC (rev 42681)
+++ trunk/mcs/mcs/expression.cs 2005-04-08 10:32:50 UTC (rev 42682)
@@ -2276,7 +2276,7 @@
// Do not perform operator overload resolution when
both sides are
// built-in types
//
- if (!(TypeManager.IsCLRType (l) &&
TypeManager.IsCLRType (r))){
+ if (!(TypeManager.IsPrimitiveType (l) &&
TypeManager.IsPrimitiveType (r))){
//
// Step 1: Perform Operator Overload location
//
Modified: trunk/mcs/mcs/iterators.cs
===================================================================
--- trunk/mcs/mcs/iterators.cs 2005-04-08 09:31:28 UTC (rev 42681)
+++ trunk/mcs/mcs/iterators.cs 2005-04-08 10:32:50 UTC (rev 42682)
@@ -390,6 +390,16 @@
"Iterators cannot have ref or
out parameters");
return false;
}
+
+ if ((mod & Parameter.Modifier.ARGLIST) != 0) {
+ Report.Error (1636, Location,
"__arglist is not allowed in parameter list of iterators");
+ return false;
+ }
+
+ if (parameters.ParameterType (i).IsPointer) {
+ Report.Error (1637, Location,
"Iterators cannot have unsafe parameters or yield types");
+ return false;
+ }
}
ArrayList list = new ArrayList ();
Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs 2005-04-08 09:31:28 UTC (rev 42681)
+++ trunk/mcs/mcs/statement.cs 2005-04-08 10:32:50 UTC (rev 42682)
@@ -3857,11 +3857,11 @@
bool ResolveExpression (EmitContext ec)
{
if (!TypeManager.ImplementsInterface (expr_type,
TypeManager.idisposable_type)){
- conv = Convert.ImplicitConversionRequired (
- ec, expr, TypeManager.idisposable_type,
loc);
-
- if (conv == null)
+ if (Convert.ImplicitConversion (ec, expr,
TypeManager.idisposable_type, loc) == null) {
+ Report.Error (1674, loc, "'{0}': type
used in a using statement must be implicitly convertible to
'System.IDisposable'",
+ TypeManager.CSharpName
(expr_type));
return false;
+ }
}
return true;
Modified: trunk/mcs/mcs/typemanager.cs
===================================================================
--- trunk/mcs/mcs/typemanager.cs 2005-04-08 09:31:28 UTC (rev 42681)
+++ trunk/mcs/mcs/typemanager.cs 2005-04-08 10:32:50 UTC (rev 42682)
@@ -1481,15 +1481,12 @@
// This is like IsBuiltinType, but lacks decimal_type, we should also
clean up
// the pieces in the code where we use IsBuiltinType and special case
decimal_type.
//
- public static bool IsCLRType (Type t)
+ public static bool IsPrimitiveType (Type t)
{
- if (t == object_type || t == int32_type || t == uint32_type ||
+ return (t == int32_type || t == uint32_type ||
t == int64_type || t == uint64_type || t == float_type || t
== double_type ||
t == char_type || t == short_type || t == bool_type ||
- t == sbyte_type || t == byte_type || t == ushort_type)
- return true;
- else
- return false;
+ t == sbyte_type || t == byte_type || t == ushort_type);
}
public static bool IsDelegateType (Type t)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches