Author: miguel
Date: 2008-02-14 18:24:14 -0500 (Thu, 14 Feb 2008)
New Revision: 95709
Added:
trunk/mcs/tests/test-613.cs
Modified:
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/expression.cs
Log:
2008-02-14 Miguel de Icaza <[EMAIL PROTECTED]>
* expression.cs: Do not fold BitwiseAnd operators when the left
side is a false constant, because we still need to evaluate the
right-hand side.
Fixes #359789
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2008-02-14 22:56:09 UTC (rev 95708)
+++ trunk/mcs/mcs/ChangeLog 2008-02-14 23:24:14 UTC (rev 95709)
@@ -1,7 +1,16 @@
2008-02-14 Miguel de Icaza <[EMAIL PROTECTED]>
- * support.cs: Increase the size.
+ * expression.cs: Do not fold BitwiseAnd operators when the left
+ side is a false constant, because we still need to evaluate the
+ right-hand side.
+ Fixes #359789
+
+ * support.cs: Instead of throwing an InternalErrorException when
+ the position of the stream is outside the boundary of our buffer,
+ reset the state of the reader, and restart the reading from the
+ beginning of the file.
+
2008-02-14 Marek Safar <[EMAIL PROTECTED]>
* generic.cs (TypeParameter.GetMembers): Is not supported operation.
Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2008-02-14 22:56:09 UTC (rev 95708)
+++ trunk/mcs/mcs/expression.cs 2008-02-14 23:24:14 UTC (rev 95709)
@@ -2473,40 +2473,40 @@
Constant EnumLiftUp (Constant left, Constant right)
{
switch (oper) {
- case Operator.BitwiseOr:
- case Operator.BitwiseAnd:
- case Operator.ExclusiveOr:
- case Operator.Equality:
- case Operator.Inequality:
- case Operator.LessThan:
- case Operator.LessThanOrEqual:
- case Operator.GreaterThan:
- case Operator.GreaterThanOrEqual:
- if (left is EnumConstant)
- return left;
-
- if (left.IsZeroInteger)
- return new EnumConstant (left,
right.Type);
-
+ case Operator.BitwiseOr:
+ case Operator.BitwiseAnd:
+ case Operator.ExclusiveOr:
+ case Operator.Equality:
+ case Operator.Inequality:
+ case Operator.LessThan:
+ case Operator.LessThanOrEqual:
+ case Operator.GreaterThan:
+ case Operator.GreaterThanOrEqual:
+ if (left is EnumConstant)
+ return left;
+
+ if (left.IsZeroInteger)
+ return new EnumConstant (left,
right.Type);
+
+ break;
+
+ case Operator.Addition:
+ case Operator.Subtraction:
+ return left;
+
+ case Operator.Multiply:
+ case Operator.Division:
+ case Operator.Modulus:
+ case Operator.LeftShift:
+ case Operator.RightShift:
+ if (right is EnumConstant || left is
EnumConstant)
break;
-
- case Operator.Addition:
- case Operator.Subtraction:
- return left;
-
- case Operator.Multiply:
- case Operator.Division:
- case Operator.Modulus:
- case Operator.LeftShift:
- case Operator.RightShift:
- if (right is EnumConstant || left is
EnumConstant)
- break;
- return left;
+ return left;
}
Error_OperatorCannotBeApplied ();
return null;
}
-
+
public override Expression DoResolve (EmitContext ec)
{
if (left == null)
@@ -2564,9 +2564,10 @@
}
if (lc != null && lc.IsZeroInteger) {
- return rc is EnumConstant ?
- new EnumConstant (lc, rc.Type):
- lc;
+ if (rc is EnumConstant)
+ return new EnumConstant (lc,
rc.Type);
+ Type = TypeManager.bool_type;
+ return this;
}
}
else if (oper == Operator.BitwiseOr) {
Added: trunk/mcs/tests/test-613.cs
===================================================================
--- trunk/mcs/tests/test-613.cs 2008-02-14 22:56:09 UTC (rev 95708)
+++ trunk/mcs/tests/test-613.cs 2008-02-14 23:24:14 UTC (rev 95709)
@@ -0,0 +1,25 @@
+//
+// Checks that we do not short-circuit the bitwise and operation
+// See bug: 359789
+//
+public class M {
+ static bool called;
+
+ public static bool g() {
+ called = true;
+ return false;
+ }
+
+ public static int Main() {
+ called = false;
+ System.Console.WriteLine (false & g());
+ if (!called)
+ return 1;
+
+ called = false;
+ System.Console.WriteLine (true | g());
+ if (!called)
+ return 1;
+ return 0;
+ }
+}
Property changes on: trunk/mcs/tests/test-613.cs
___________________________________________________________________
Name: svn:eol-style
+ native
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches