Author: martin
Date: 2005-04-18 00:51:07 -0400 (Mon, 18 Apr 2005)
New Revision: 43190
Modified:
trunk/mcs/gmcs/AssemblyInfo.cs
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/class.cs
trunk/mcs/gmcs/expression.cs
Log:
**** Merged r42042 from MCS ****
Modified: trunk/mcs/gmcs/AssemblyInfo.cs
===================================================================
--- trunk/mcs/gmcs/AssemblyInfo.cs 2005-04-18 04:50:44 UTC (rev 43189)
+++ trunk/mcs/gmcs/AssemblyInfo.cs 2005-04-18 04:51:07 UTC (rev 43190)
@@ -1,7 +1,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-[assembly: AssemblyVersion("1.1.4")]
+[assembly: AssemblyVersion("1.1.5")]
[assembly: AssemblyTitle ("Mono C# Compiler")]
[assembly: AssemblyDescription ("Mono C# Compiler with Generics")]
[assembly: AssemblyCopyright ("2001, 2002, 2003 Ximian, Inc.")]
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2005-04-18 04:50:44 UTC (rev 43189)
+++ trunk/mcs/gmcs/ChangeLog 2005-04-18 04:51:07 UTC (rev 43190)
@@ -1,3 +1,10 @@
+2005-03-21 Marek Safar <[EMAIL PROTECTED]>
+
+ * class.cs (FixedField.Define): Check for CS1664 and more sanity
+ checks.
+
+ * expression.cs (ElementAccess.DoResolveLValue): Check for CS1708.
+
2005-03-18 Marek Safar <[EMAIL PROTECTED]>
* modifiers.cs (Modifiers.PROPERTY_CUSTOM): New constant for
Modified: trunk/mcs/gmcs/class.cs
===================================================================
--- trunk/mcs/gmcs/class.cs 2005-04-18 04:50:44 UTC (rev 43189)
+++ trunk/mcs/gmcs/class.cs 2005-04-18 04:51:07 UTC (rev 43190)
@@ -5906,13 +5906,27 @@
return false;
}
- buffer_size = (int)c.GetValue ();
+ IntConstant buffer_size_const = c.ToInt (Location);
+ if (buffer_size_const == null)
+ return false;
+
+ buffer_size = buffer_size_const.Value;
+
if (buffer_size <= 0) {
Report.Error (1665, Location, "Fixed sized
buffer '{0}' must have a length greater than zero", GetSignatureForError ());
return false;
}
- buffer_size *= Expression.GetTypeSize (MemberType);
+ int type_size = Expression.GetTypeSize (MemberType);
+
+ if (buffer_size > int.MaxValue / type_size) {
+ Report.Error (1664, Location, "Fixed sized
buffer of length '{0}' and type '{1}' exceeded 2^31 limit",
+ buffer_size.ToString (),
TypeManager.CSharpName (MemberType));
+ return false;
+ }
+
+ buffer_size *= type_size;
+
// Define nested
string name = String.Format ("<{0}>__FixedBuffer{1}",
Name, GlobalCounter++);
Modified: trunk/mcs/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs 2005-04-18 04:50:44 UTC (rev 43189)
+++ trunk/mcs/gmcs/expression.cs 2005-04-18 04:51:07 UTC (rev 43190)
@@ -8043,10 +8043,14 @@
if (fe != null) {
IFixedBuffer ff =
AttributeTester.GetFixedBuffer (fe.FieldInfo);
if (ff != null) {
+ if (!(fe.InstanceExpression is
LocalVariableReference) &&
+ !(fe.InstanceExpression is
This)) {
+ Error (1708, "Fixed buffers can
only be accessed through locals or fields");
+ return null;
+ }
// TODO: not sure whether it is correct
// if (!ec.InFixedInitializer) {
-// if (!ec.InFixedInitializer) {
-// Error (1666, "You cannot use
fixed sized buffers contained in unfixed expressions. Try using the fixed
statement.");
+// Error (1666, "You cannot use
fixed sized buffers contained in unfixed expressions. Try using the fixed
statement");
// return null;
// }
return MakePointerAccess (ec,
ff.ElementType);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches