Author: raja
Date: 2005-07-05 08:49:40 -0400 (Tue, 05 Jul 2005)
New Revision: 46942
Added:
trunk/mcs/errors/cs0212-2.cs
trunk/mcs/tests/test-423.cs
Modified:
trunk/mcs/errors/ChangeLog
trunk/mcs/errors/known-issues-gmcs
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/ecore.cs
trunk/mcs/mcs/expression.cs
trunk/mcs/mcs/statement.cs
trunk/mcs/tests/ChangeLog
trunk/mcs/tests/known-issues-gmcs
trunk/mcs/tests/known-issues-mcs
Log:
In mcs:
Make 'fixed variable' handling standards compliant. Fix #70807, #72729.
* ecore.cs (IVariable.VerifyFixed): Remove 'is_expression' parameter.
(FieldExpr.VerifyFixed): Ensure that the field is part of a fixed
variable of struct type.
* expression.cs (Unary.ResolveOperator): Update to change.
(Indirection.VerifyFixed): Likewise.
(LocalVariableReference.VerifyFixed): A local variable is always fixed.
(ParameterReference.VerifyFixed): Value parameters are fixed.
(This.VerifyFixed): Treat 'this' as a value parameter.
* statement.cs (LocalInfo.IsFixed): Remove.
In tests:
* test-423.cs: New test based on #70807.
In errors:
* cs0212-2.cs: New test from #72729.
Modified: trunk/mcs/errors/ChangeLog
===================================================================
--- trunk/mcs/errors/ChangeLog 2005-07-05 12:19:51 UTC (rev 46941)
+++ trunk/mcs/errors/ChangeLog 2005-07-05 12:49:40 UTC (rev 46942)
@@ -1,3 +1,7 @@
+2005-07-05 Raja R Harinath <[EMAIL PROTECTED]>
+
+ * cs0212-2.cs: New test from #72729.
+
2005-06-30 Raja R Harinath <[EMAIL PROTECTED]>
* cs0021-3.cs: New test from #75412.
Added: trunk/mcs/errors/cs0212-2.cs
===================================================================
--- trunk/mcs/errors/cs0212-2.cs 2005-07-05 12:19:51 UTC (rev 46941)
+++ trunk/mcs/errors/cs0212-2.cs 2005-07-05 12:49:40 UTC (rev 46942)
@@ -0,0 +1,19 @@
+// cs0212-2.cs: You can only take the address of unfixed expression inside of
a fixed statement initializer
+// Line: 17
+// Compiler options: -unsafe
+
+using System;
+
+unsafe class X {
+ static void Main ()
+ {
+ int foo = 0;
+ Blah (ref foo);
+
+ }
+
+ static void Blah (ref int mptr)
+ {
+ int* x = &mptr;
+ }
+}
Modified: trunk/mcs/errors/known-issues-gmcs
===================================================================
--- trunk/mcs/errors/known-issues-gmcs 2005-07-05 12:19:51 UTC (rev 46941)
+++ trunk/mcs/errors/known-issues-gmcs 2005-07-05 12:49:40 UTC (rev 46942)
@@ -18,6 +18,7 @@
cs0121-3.cs NO ERROR
cs0201.cs
cs0202.cs # new in GMCS
+cs0212-2.cs NO ERROR
cs0229.cs NO ERROR
cs0229-2.cs
cs0245.cs
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2005-07-05 12:19:51 UTC (rev 46941)
+++ trunk/mcs/mcs/ChangeLog 2005-07-05 12:49:40 UTC (rev 46942)
@@ -1,3 +1,16 @@
+2005-07-05 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Make 'fixed variable' handling standards compliant. Fix #70807, #72729.
+ * ecore.cs (IVariable.VerifyFixed): Remove 'is_expression' parameter.
+ (FieldExpr.VerifyFixed): Ensure that the field is part of a fixed
+ variable of struct type.
+ * expression.cs (Unary.ResolveOperator): Update to change.
+ (Indirection.VerifyFixed): Likewise.
+ (LocalVariableReference.VerifyFixed): A local variable is always fixed.
+ (ParameterReference.VerifyFixed): Value parameters are fixed.
+ (This.VerifyFixed): Treat 'this' as a value parameter.
+ * statement.cs (LocalInfo.IsFixed): Remove.
+
2005-07-01 Martin Baulig <[EMAIL PROTECTED]>
* iterators.cs (Iterator.CapturedThisReference.Emit): Use
Modified: trunk/mcs/mcs/ecore.cs
===================================================================
--- trunk/mcs/mcs/ecore.cs 2005-07-05 12:19:51 UTC (rev 46941)
+++ trunk/mcs/mcs/ecore.cs 2005-07-05 12:49:40 UTC (rev 46942)
@@ -115,7 +115,7 @@
get;
}
- bool VerifyFixed (bool is_expression);
+ bool VerifyFixed ();
}
/// <remarks>
@@ -3066,13 +3066,13 @@
}
}
- public bool VerifyFixed (bool is_expression)
+ public bool VerifyFixed ()
{
IVariable variable = InstanceExpression as IVariable;
- if ((variable == null) || !variable.VerifyFixed (true))
- return false;
-
- return true;
+ // A variable of the form V.I is fixed when V is a
fixed variable of a struct type.
+ // We defer the InstanceExpression check after the
variable check to avoid a
+ // separate null check on InstanceExpression.
+ return variable != null &&
InstanceExpression.Type.IsValueType && variable.VerifyFixed ();
}
public override int GetHashCode()
Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2005-07-05 12:19:51 UTC (rev 46941)
+++ trunk/mcs/mcs/expression.cs 2005-07-05 12:49:40 UTC (rev 46942)
@@ -432,7 +432,7 @@
}
IVariable variable = Expr as IVariable;
- bool is_fixed = variable != null &&
variable.VerifyFixed (false);
+ bool is_fixed = variable != null &&
variable.VerifyFixed ();
if (!ec.InFixedInitializer && !is_fixed) {
Error (212, "You can only take the
address of an unfixed expression inside " +
@@ -750,8 +750,9 @@
}
}
- public bool VerifyFixed (bool is_expression)
+ public bool VerifyFixed ()
{
+ // A pointer-indirection is always fixed.
return true;
}
@@ -3757,9 +3758,10 @@
return ret;
}
- public bool VerifyFixed (bool is_expression)
+ public bool VerifyFixed ()
{
- return !is_expression || local_info.IsFixed;
+ // A local Variable is always fixed.
+ return true;
}
public override int GetHashCode()
@@ -3913,9 +3915,10 @@
get { return vi; }
}
- public bool VerifyFixed (bool is_expression)
+ public bool VerifyFixed ()
{
- return !is_expression || TypeManager.IsValueType (type);
+ // A parameter is fixed if it's a value parameter
(i.e., no modifier like out, ref, param).
+ return mod == Parameter.Modifier.NONE;
}
public bool IsAssigned (EmitContext ec, Location loc)
@@ -6858,12 +6861,10 @@
get { return variable_info; }
}
- public bool VerifyFixed (bool is_expression)
+ public bool VerifyFixed ()
{
- if ((variable_info == null) || (variable_info.LocalInfo
== null))
- return false;
- else
- return variable_info.LocalInfo.IsFixed;
+ // Treat 'this' as a value parameter for the purpose of
fixed variable determination.
+ return true;
}
public bool ResolveBase (EmitContext ec)
Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs 2005-07-05 12:19:51 UTC (rev 46941)
+++ trunk/mcs/mcs/statement.cs 2005-07-05 12:49:40 UTC (rev 46942)
@@ -1079,18 +1079,6 @@
return true;
}
- //
- // Whether the variable is Fixed (because its Pinned or its a
value type)
- //
- public bool IsFixed {
- get {
- if (((flags & Flags.Pinned) != 0) ||
TypeManager.IsValueType (VariableType))
- return true;
-
- return false;
- }
- }
-
public bool IsCaptured {
get {
return (flags & Flags.Captured) != 0;
Modified: trunk/mcs/tests/ChangeLog
===================================================================
--- trunk/mcs/tests/ChangeLog 2005-07-05 12:19:51 UTC (rev 46941)
+++ trunk/mcs/tests/ChangeLog 2005-07-05 12:49:40 UTC (rev 46942)
@@ -1,3 +1,7 @@
+2005-07-05 Raja R Harinath <[EMAIL PROTECTED]>
+
+ * test-423.cs: New test based on #70807.
+
2005-06-30 Marek Safar <[EMAIL PROTECTED]>
* gtest-180.cs: DefaultCharSetAttribute test.
Modified: trunk/mcs/tests/known-issues-gmcs
===================================================================
--- trunk/mcs/tests/known-issues-gmcs 2005-07-05 12:19:51 UTC (rev 46941)
+++ trunk/mcs/tests/known-issues-gmcs 2005-07-05 12:49:40 UTC (rev 46942)
@@ -15,3 +15,4 @@
gtest-179.cs
test-422.cs
+test-423.cs
Modified: trunk/mcs/tests/known-issues-mcs
===================================================================
--- trunk/mcs/tests/known-issues-mcs 2005-07-05 12:19:51 UTC (rev 46941)
+++ trunk/mcs/tests/known-issues-mcs 2005-07-05 12:49:40 UTC (rev 46942)
@@ -12,4 +12,3 @@
test-xml-027.cs
test-67.cs IGNORE # Windows-only test
-test-389.cs IGNORE
Added: trunk/mcs/tests/test-423.cs
===================================================================
--- trunk/mcs/tests/test-423.cs 2005-07-05 12:19:51 UTC (rev 46941)
+++ trunk/mcs/tests/test-423.cs 2005-07-05 12:49:40 UTC (rev 46942)
@@ -0,0 +1,19 @@
+// Compiler options: -unsafe
+
+unsafe class Test
+{
+ static void lowLevelCall (int *pv) { }
+
+ static void Func (out int i)
+ {
+ fixed(int *pi = &i)
+ lowLevelCall (pi);
+ }
+
+ static void Main ()
+ {
+ int i = 0;
+ Func (out i);
+ }
+}
+
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches