Author: martin
Date: 2005-05-10 19:10:13 -0400 (Tue, 10 May 2005)
New Revision: 44364

Modified:
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/cfold.cs
   trunk/mcs/gmcs/expression.cs
Log:
**** Merged r44110 from MCS ****


Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2005-05-10 23:09:29 UTC (rev 44363)
+++ trunk/mcs/gmcs/ChangeLog    2005-05-10 23:10:13 UTC (rev 44364)
@@ -52,6 +52,12 @@
        (Attributable.IsClsComplianceRequired): Fix typo in the method name.
        (AttributeTester.AnalyzeTypeCompliance): Add generics support.
 
+2005-05-06  Marek Safar  <[EMAIL PROTECTED]>
+
+       * cfold (DoConstantNumericPromotions): Don't try to convert 0 enum.
+       
+       * expression.cs (Binary.DoResolve): (x && 0) is always 0.
+
 2005-05-05  Raja R Harinath  <[EMAIL PROTECTED]>
 
        Fix #74797.

Modified: trunk/mcs/gmcs/cfold.cs
===================================================================
--- trunk/mcs/gmcs/cfold.cs     2005-05-10 23:09:29 UTC (rev 44363)
+++ trunk/mcs/gmcs/cfold.cs     2005-05-10 23:10:13 UTC (rev 44364)
@@ -156,8 +156,9 @@
                                }
 
                                bool need_check = (other is EnumConstant) ||
-                                       ((oper != Binary.Operator.Addition) &&
-                                        (oper != Binary.Operator.Subtraction));
+                                       !(oper == Binary.Operator.Addition || 
+                                         oper == Binary.Operator.Subtraction ||
+                                         (other.IsZeroInteger && other is 
IntConstant));
 
                                if (need_check &&
                                    !Convert.ImplicitConversionExists (ec, 
match, other.Type)) {

Modified: trunk/mcs/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs        2005-05-10 23:09:29 UTC (rev 44363)
+++ trunk/mcs/gmcs/expression.cs        2005-05-10 23:10:13 UTC (rev 44364)
@@ -2762,11 +2762,26 @@
                        eclass = ExprClass.Value;
 
                        Constant rc = right as Constant;
-                       if (rc != null & lc != null){
+
+                       if (oper == Operator.BitwiseAnd) {
+                               if (rc != null && rc.IsZeroInteger) {
+                                       return lc is EnumConstant ?
+                                               new EnumConstant (rc, lc.Type):
+                                               rc;
+                               }
+
+                               if (lc != null && lc.IsZeroInteger) {
+                                       return rc is EnumConstant ?
+                                               new EnumConstant (lc, rc.Type):
+                                               lc;
+                               }
+                       }
+
+                       if (rc != null && lc != null){
                                Expression e = ConstantFold.BinaryFold (
                                        ec, oper, lc, rc, loc);
-                                       if (e != null)
-                                               return e;
+                               if (e != null)
+                                       return e;
                        }
 
                        if (TypeManager.IsNullableType (left.Type) || 
TypeManager.IsNullableType (right.Type))

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to