Add some new classes/enums/delegates for 2.0 and some new CAS unit tests
[mono.git] / mcs / mcs / cfold.cs
index 0c69e1c5d3dfc80be89753efb9f04014b287e1c0..9e8a5a1a6293a1de740c20cb86e3fc3ef0ebbc6d 100644 (file)
@@ -118,9 +118,9 @@ namespace Mono.CSharp {
                                if (ic != null){
                                        if (ic.Value >= 0){
                                                if (left == other)
-                                                       left = new UIntConstant ((uint) ic.Value);
+                                                       left = new UIntConstant ((uint) ic.Value, ic.Location);
                                                else
-                                                       right = new UIntConstant ((uint) ic.Value);
+                                                       right = new UIntConstant ((uint) ic.Value, ic.Location);
                                                return;
                                        }
                                }
@@ -141,33 +141,6 @@ namespace Mono.CSharp {
                                        right = right.ToDecimal (loc);
                                return;
                        } else if (left is EnumConstant || right is EnumConstant){
-                               //
-                               // If either operand is an enum constant, the other one must
-                               // be implicitly convertable to that enum's underlying type.
-                               //
-                               EnumConstant match;
-                               Constant other;
-                               if (left is EnumConstant){
-                                       other = right;
-                                       match = (EnumConstant) left;
-                               } else {
-                                       other = left;
-                                       match = (EnumConstant) right;
-                               }
-
-                               bool need_check = (other is EnumConstant) ||
-                                       !(oper == Binary.Operator.Addition || 
-                                         oper == Binary.Operator.Subtraction ||
-                                         (other.IsZeroInteger && other is IntConstant));
-
-                               if (need_check &&
-                                   !Convert.ImplicitConversionExists (ec, match, other.Type)) {
-                                       Convert.Error_CannotImplicitConversion (loc, match.Type, other.Type);
-                                       left = null;
-                                       right = null;
-                                       return;
-                               }
-
                                if (left is EnumConstant)
                                        left = ((EnumConstant) left).Child;
                                if (right is EnumConstant)
@@ -235,7 +208,7 @@ namespace Mono.CSharp {
                                        IntConstant v;
                                        int res = ((IntConstant) left).Value | ((IntConstant) right).Value;
                                        
-                                       v = new IntConstant (res);
+                                       v = new IntConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -244,7 +217,7 @@ namespace Mono.CSharp {
                                        UIntConstant v;
                                        uint res = ((UIntConstant)left).Value | ((UIntConstant)right).Value;
                                        
-                                       v = new UIntConstant (res);
+                                       v = new UIntConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -253,7 +226,7 @@ namespace Mono.CSharp {
                                        LongConstant v;
                                        long res = ((LongConstant)left).Value | ((LongConstant)right).Value;
                                        
-                                       v = new LongConstant (res);
+                                       v = new LongConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -263,7 +236,7 @@ namespace Mono.CSharp {
                                        ulong res = ((ULongConstant)left).Value |
                                                ((ULongConstant)right).Value;
                                        
-                                       v = new ULongConstant (res);
+                                       v = new ULongConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -273,7 +246,7 @@ namespace Mono.CSharp {
                                        ushort res = (ushort) (((UShortConstant)left).Value |
                                                               ((UShortConstant)right).Value);
                                        
-                                       v = new UShortConstant (res);
+                                       v = new UShortConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -283,7 +256,7 @@ namespace Mono.CSharp {
                                        short res = (short) (((ShortConstant)left).Value |
                                                             ((ShortConstant)right).Value);
                                        
-                                       v = new ShortConstant (res);
+                                       v = new ShortConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -300,7 +273,7 @@ namespace Mono.CSharp {
                                        IntConstant v;
                                        int res = ((IntConstant) left).Value & ((IntConstant) right).Value;
                                        
-                                       v = new IntConstant (res);
+                                       v = new IntConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -309,7 +282,7 @@ namespace Mono.CSharp {
                                        UIntConstant v;
                                        uint res = ((UIntConstant)left).Value & ((UIntConstant)right).Value;
                                        
-                                       v = new UIntConstant (res);
+                                       v = new UIntConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -318,7 +291,7 @@ namespace Mono.CSharp {
                                        LongConstant v;
                                        long res = ((LongConstant)left).Value & ((LongConstant)right).Value;
                                        
-                                       v = new LongConstant (res);
+                                       v = new LongConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -328,7 +301,7 @@ namespace Mono.CSharp {
                                        ulong res = ((ULongConstant)left).Value &
                                                ((ULongConstant)right).Value;
                                        
-                                       v = new ULongConstant (res);
+                                       v = new ULongConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -338,7 +311,7 @@ namespace Mono.CSharp {
                                        ushort res = (ushort) (((UShortConstant)left).Value &
                                                               ((UShortConstant)right).Value);
                                        
-                                       v = new UShortConstant (res);
+                                       v = new UShortConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -348,7 +321,7 @@ namespace Mono.CSharp {
                                        short res = (short) (((ShortConstant)left).Value &
                                                             ((ShortConstant)right).Value);
                                        
-                                       v = new ShortConstant (res);
+                                       v = new ShortConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -365,7 +338,7 @@ namespace Mono.CSharp {
                                        IntConstant v;
                                        int res = ((IntConstant) left).Value ^ ((IntConstant) right).Value;
                                        
-                                       v = new IntConstant (res);
+                                       v = new IntConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -374,7 +347,7 @@ namespace Mono.CSharp {
                                        UIntConstant v;
                                        uint res = ((UIntConstant)left).Value ^ ((UIntConstant)right).Value;
                                        
-                                       v = new UIntConstant (res);
+                                       v = new UIntConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -383,7 +356,7 @@ namespace Mono.CSharp {
                                        LongConstant v;
                                        long res = ((LongConstant)left).Value ^ ((LongConstant)right).Value;
                                        
-                                       v = new LongConstant (res);
+                                       v = new LongConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -393,7 +366,7 @@ namespace Mono.CSharp {
                                        ulong res = ((ULongConstant)left).Value ^
                                                ((ULongConstant)right).Value;
                                        
-                                       v = new ULongConstant (res);
+                                       v = new ULongConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -403,7 +376,7 @@ namespace Mono.CSharp {
                                        ushort res = (ushort) (((UShortConstant)left).Value ^
                                                               ((UShortConstant)right).Value);
                                        
-                                       v = new UShortConstant (res);
+                                       v = new UShortConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -413,7 +386,7 @@ namespace Mono.CSharp {
                                        short res = (short)(((ShortConstant)left).Value ^
                                                            ((ShortConstant)right).Value);
                                        
-                                       v = new ShortConstant (res);
+                                       v = new ShortConstant (res, left.Location);
                                        if (result_type == null)
                                                return v;
                                        else
@@ -435,7 +408,7 @@ namespace Mono.CSharp {
                                        if (left_is_string && right_is_string)
                                                return new StringConstant (
                                                        ((StringConstant) left).Value +
-                                                       ((StringConstant) right).Value);
+                                                       ((StringConstant) right).Value, left.Location);
                                        
                                        return null;
                                }
@@ -480,7 +453,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((DoubleConstant) left).Value +
                                                                         ((DoubleConstant) right).Value);
                                                
-                                               result = new DoubleConstant (res);
+                                               result = new DoubleConstant (res, left.Location);
                                        } else if (left is FloatConstant){
                                                float res;
                                                
@@ -491,7 +464,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((FloatConstant) left).Value +
                                                                         ((FloatConstant) right).Value);
                                                
-                                               result = new FloatConstant (res);
+                                               result = new FloatConstant (res, left.Location);
                                        } else if (left is ULongConstant){
                                                ulong res;
                                                
@@ -502,7 +475,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((ULongConstant) left).Value +
                                                                         ((ULongConstant) right).Value);
 
-                                               result = new ULongConstant (res);
+                                               result = new ULongConstant (res, left.Location);
                                        } else if (left is LongConstant){
                                                long res;
                                                
@@ -513,7 +486,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((LongConstant) left).Value +
                                                                         ((LongConstant) right).Value);
                                                
-                                               result = new LongConstant (res);
+                                               result = new LongConstant (res, left.Location);
                                        } else if (left is UIntConstant){
                                                uint res;
                                                
@@ -524,7 +497,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((UIntConstant) left).Value +
                                                                         ((UIntConstant) right).Value);
                                                
-                                               result = new UIntConstant (res);
+                                               result = new UIntConstant (res, left.Location);
                                        } else if (left is IntConstant){
                                                int res;
 
@@ -535,7 +508,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((IntConstant) left).Value +
                                                                         ((IntConstant) right).Value);
 
-                                               result = new IntConstant (res);
+                                               result = new IntConstant (res, left.Location);
                                        } else if (left is DecimalConstant) {
                                                decimal res;
 
@@ -546,7 +519,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((DecimalConstant) left).Value +
                                                                ((DecimalConstant) right).Value);
 
-                                               result = new DecimalConstant (res);
+                                               result = new DecimalConstant (res, left.Location);
                                        } else {
                                                throw new Exception ( "Unexepected addition input: " + left);
                                        }
@@ -555,7 +528,7 @@ namespace Mono.CSharp {
                                }
 
                                if (wrap_as != null)
-                                       return new EnumConstant (result, wrap_as);
+                                       return result.TryReduce (ec, wrap_as, loc);
                                else
                                        return result;
 
@@ -612,7 +585,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((DoubleConstant) left).Value -
                                                                         ((DoubleConstant) right).Value);
                                                
-                                               result = new DoubleConstant (res);
+                                               result = new DoubleConstant (res, left.Location);
                                        } else if (left is FloatConstant){
                                                float res;
                                                
@@ -623,7 +596,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((FloatConstant) left).Value -
                                                                         ((FloatConstant) right).Value);
                                                
-                                               result = new FloatConstant (res);
+                                               result = new FloatConstant (res, left.Location);
                                        } else if (left is ULongConstant){
                                                ulong res;
                                                
@@ -634,7 +607,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((ULongConstant) left).Value -
                                                                         ((ULongConstant) right).Value);
                                                
-                                               result = new ULongConstant (res);
+                                               result = new ULongConstant (res, left.Location);
                                        } else if (left is LongConstant){
                                                long res;
                                                
@@ -645,7 +618,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((LongConstant) left).Value -
                                                                         ((LongConstant) right).Value);
                                                
-                                               result = new LongConstant (res);
+                                               result = new LongConstant (res, left.Location);
                                        } else if (left is UIntConstant){
                                                uint res;
                                                
@@ -656,7 +629,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((UIntConstant) left).Value -
                                                                         ((UIntConstant) right).Value);
                                                
-                                               result = new UIntConstant (res);
+                                               result = new UIntConstant (res, left.Location);
                                        } else if (left is IntConstant){
                                                int res;
 
@@ -667,7 +640,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((IntConstant) left).Value -
                                                                         ((IntConstant) right).Value);
 
-                                               result = new IntConstant (res);
+                                               result = new IntConstant (res, left.Location);
                                        } else if (left is DecimalConstant) {
                                                decimal res;
 
@@ -678,17 +651,18 @@ namespace Mono.CSharp {
                                                        res = unchecked (((DecimalConstant) left).Value -
                                                                ((DecimalConstant) right).Value);
 
-                                               return new DecimalConstant (res);
+                                               return new DecimalConstant (res, left.Location);
                                        } else {
                                                throw new Exception ( "Unexepected subtraction input: " + left);
                                        }
                                } catch (OverflowException){
                                        Error_CompileTimeOverflow (loc);
                                }
+
                                if (wrap_as != null)
-                                       return new EnumConstant (result, wrap_as);
-                               else
-                                       return result;
+                                       return result.TryReduce (ec, wrap_as, loc);
+
+                               return result;
                                
                        case Binary.Operator.Multiply:
                                DoConstantNumericPromotions (ec, oper, ref left, ref right, loc);
@@ -706,7 +680,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((DoubleConstant) left).Value *
                                                                ((DoubleConstant) right).Value);
                                                
-                                               return new DoubleConstant (res);
+                                               return new DoubleConstant (res, left.Location);
                                        } else if (left is FloatConstant){
                                                float res;
                                                
@@ -717,7 +691,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((FloatConstant) left).Value *
                                                                ((FloatConstant) right).Value);
                                                
-                                               return new FloatConstant (res);
+                                               return new FloatConstant (res, left.Location);
                                        } else if (left is ULongConstant){
                                                ulong res;
                                                
@@ -728,7 +702,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((ULongConstant) left).Value *
                                                                ((ULongConstant) right).Value);
                                                
-                                               return new ULongConstant (res);
+                                               return new ULongConstant (res, left.Location);
                                        } else if (left is LongConstant){
                                                long res;
                                                
@@ -739,7 +713,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((LongConstant) left).Value *
                                                                ((LongConstant) right).Value);
                                                
-                                               return new LongConstant (res);
+                                               return new LongConstant (res, left.Location);
                                        } else if (left is UIntConstant){
                                                uint res;
                                                
@@ -750,7 +724,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((UIntConstant) left).Value *
                                                                ((UIntConstant) right).Value);
                                                
-                                               return new UIntConstant (res);
+                                               return new UIntConstant (res, left.Location);
                                        } else if (left is IntConstant){
                                                int res;
 
@@ -761,7 +735,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((IntConstant) left).Value *
                                                                ((IntConstant) right).Value);
 
-                                               return new IntConstant (res);
+                                               return new IntConstant (res, left.Location);
                                        } else if (left is DecimalConstant) {
                                                decimal res;
 
@@ -772,7 +746,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((DecimalConstant) left).Value *
                                                                ((DecimalConstant) right).Value);
 
-                                               return new DecimalConstant (res);
+                                               return new DecimalConstant (res, left.Location);
                                        } else {
                                                throw new Exception ( "Unexepected multiply input: " + left);
                                        }
@@ -797,7 +771,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((DoubleConstant) left).Value /
                                                                ((DoubleConstant) right).Value);
                                                
-                                               return new DoubleConstant (res);
+                                               return new DoubleConstant (res, left.Location);
                                        } else if (left is FloatConstant){
                                                float res;
                                                
@@ -808,7 +782,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((FloatConstant) left).Value /
                                                                ((FloatConstant) right).Value);
                                                
-                                               return new FloatConstant (res);
+                                               return new FloatConstant (res, left.Location);
                                        } else if (left is ULongConstant){
                                                ulong res;
                                                
@@ -819,7 +793,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((ULongConstant) left).Value /
                                                                ((ULongConstant) right).Value);
                                                
-                                               return new ULongConstant (res);
+                                               return new ULongConstant (res, left.Location);
                                        } else if (left is LongConstant){
                                                long res;
                                                
@@ -830,7 +804,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((LongConstant) left).Value /
                                                                ((LongConstant) right).Value);
                                                
-                                               return new LongConstant (res);
+                                               return new LongConstant (res, left.Location);
                                        } else if (left is UIntConstant){
                                                uint res;
                                                
@@ -841,7 +815,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((UIntConstant) left).Value /
                                                                ((UIntConstant) right).Value);
                                                
-                                               return new UIntConstant (res);
+                                               return new UIntConstant (res, left.Location);
                                        } else if (left is IntConstant){
                                                int res;
 
@@ -852,7 +826,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((IntConstant) left).Value /
                                                                ((IntConstant) right).Value);
 
-                                               return new IntConstant (res);
+                                               return new IntConstant (res, left.Location);
                                        } else if (left is DecimalConstant) {
                                                decimal res;
 
@@ -863,7 +837,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((DecimalConstant) left).Value /
                                                                ((DecimalConstant) right).Value);
 
-                                               return new DecimalConstant (res);
+                                               return new DecimalConstant (res, left.Location);
                                        } else {
                                                throw new Exception ( "Unexepected division input: " + left);
                                        }
@@ -892,7 +866,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((DoubleConstant) left).Value %
                                                                         ((DoubleConstant) right).Value);
                                                
-                                               return new DoubleConstant (res);
+                                               return new DoubleConstant (res, left.Location);
                                        } else if (left is FloatConstant){
                                                float res;
                                                
@@ -903,7 +877,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((FloatConstant) left).Value %
                                                                         ((FloatConstant) right).Value);
                                                
-                                               return new FloatConstant (res);
+                                               return new FloatConstant (res, left.Location);
                                        } else if (left is ULongConstant){
                                                ulong res;
                                                
@@ -914,7 +888,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((ULongConstant) left).Value %
                                                                         ((ULongConstant) right).Value);
                                                
-                                               return new ULongConstant (res);
+                                               return new ULongConstant (res, left.Location);
                                        } else if (left is LongConstant){
                                                long res;
                                                
@@ -925,7 +899,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((LongConstant) left).Value %
                                                                         ((LongConstant) right).Value);
                                                
-                                               return new LongConstant (res);
+                                               return new LongConstant (res, left.Location);
                                        } else if (left is UIntConstant){
                                                uint res;
                                                
@@ -936,7 +910,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((UIntConstant) left).Value %
                                                                         ((UIntConstant) right).Value);
                                                
-                                               return new UIntConstant (res);
+                                               return new UIntConstant (res, left.Location);
                                        } else if (left is IntConstant){
                                                int res;
 
@@ -947,7 +921,7 @@ namespace Mono.CSharp {
                                                        res = unchecked (((IntConstant) left).Value %
                                                                         ((IntConstant) right).Value);
 
-                                               return new IntConstant (res);
+                                               return new IntConstant (res, left.Location);
                                        } else {
                                                throw new Exception ( "Unexepected modulus input: " + left);
                                        }
@@ -971,19 +945,19 @@ namespace Mono.CSharp {
 
                                IntConstant lic;
                                if ((lic = left.ConvertToInt ()) != null)
-                                       return new IntConstant (lic.Value << lshift_val);
+                                       return new IntConstant (lic.Value << lshift_val, left.Location);
 
                                UIntConstant luic;
                                if ((luic = left.ConvertToUInt ()) != null)
-                                       return new UIntConstant (luic.Value << lshift_val);
+                                       return new UIntConstant (luic.Value << lshift_val, left.Location);
 
                                LongConstant llc;
                                if ((llc = left.ConvertToLong ()) != null)
-                                       return new LongConstant (llc.Value << lshift_val);
+                                       return new LongConstant (llc.Value << lshift_val, left.Location);
 
                                ULongConstant lulc;
                                if ((lulc = left.ConvertToULong ()) != null)
-                                       return new ULongConstant (lulc.Value << lshift_val);
+                                       return new ULongConstant (lulc.Value << lshift_val, left.Location);
 
                                Binary.Error_OperatorCannotBeApplied (loc, "<<", lt, rt);
                                break;
@@ -1001,19 +975,19 @@ namespace Mono.CSharp {
 
                                IntConstant ric;
                                if ((ric = left.ConvertToInt ()) != null)
-                                       return new IntConstant (ric.Value >> rshift_val);
+                                       return new IntConstant (ric.Value >> rshift_val, left.Location);
 
                                UIntConstant ruic;
                                if ((ruic = left.ConvertToUInt ()) != null)
-                                       return new UIntConstant (ruic.Value >> rshift_val);
+                                       return new UIntConstant (ruic.Value >> rshift_val, left.Location);
 
                                LongConstant rlc;
                                if ((rlc = left.ConvertToLong ()) != null)
-                                       return new LongConstant (rlc.Value >> rshift_val);
+                                       return new LongConstant (rlc.Value >> rshift_val, left.Location);
 
                                ULongConstant rulc;
                                if ((rulc = left.ConvertToULong ()) != null)
-                                       return new ULongConstant (rulc.Value >> rshift_val);
+                                       return new ULongConstant (rulc.Value >> rshift_val, left.Location);
 
                                Binary.Error_OperatorCannotBeApplied (loc, ">>", lt, rt);
                                break;
@@ -1022,7 +996,7 @@ namespace Mono.CSharp {
                                if (left is BoolConstant && right is BoolConstant){
                                        return new BoolConstant (
                                                ((BoolConstant) left).Value &&
-                                               ((BoolConstant) right).Value);
+                                               ((BoolConstant) right).Value, left.Location);
                                }
                                break;
 
@@ -1030,7 +1004,7 @@ namespace Mono.CSharp {
                                if (left is BoolConstant && right is BoolConstant){
                                        return new BoolConstant (
                                                ((BoolConstant) left).Value ||
-                                               ((BoolConstant) right).Value);
+                                               ((BoolConstant) right).Value, left.Location);
                                }
                                break;
                                
@@ -1038,26 +1012,26 @@ namespace Mono.CSharp {
                                if (left is BoolConstant && right is BoolConstant){
                                        return new BoolConstant (
                                                ((BoolConstant) left).Value ==
-                                               ((BoolConstant) right).Value);
+                                               ((BoolConstant) right).Value, left.Location);
                                
                                }
                                if (left is NullLiteral){
                                        if (right is NullLiteral)
-                                               return new BoolConstant (true);
+                                               return new BoolConstant (true, left.Location);
                                        else if (right is StringConstant)
                                                return new BoolConstant (
-                                                       ((StringConstant) right).Value == null);
+                                                       ((StringConstant) right).Value == null, left.Location);
                                } else if (right is NullLiteral){
                                        if (left is NullLiteral)
-                                               return new BoolConstant (true);
+                                               return new BoolConstant (true, left.Location);
                                        else if (left is StringConstant)
                                                return new BoolConstant (
-                                                       ((StringConstant) left).Value == null);
+                                                       ((StringConstant) left).Value == null, left.Location);
                                }
                                if (left is StringConstant && right is StringConstant){
                                        return new BoolConstant (
                                                ((StringConstant) left).Value ==
-                                               ((StringConstant) right).Value);
+                                               ((StringConstant) right).Value, left.Location);
                                        
                                }
 
@@ -1087,31 +1061,31 @@ namespace Mono.CSharp {
                                else
                                        return null;
 
-                               return new BoolConstant (bool_res);
+                               return new BoolConstant (bool_res, left.Location);
 
                        case Binary.Operator.Inequality:
                                if (left is BoolConstant && right is BoolConstant){
                                        return new BoolConstant (
                                                ((BoolConstant) left).Value !=
-                                               ((BoolConstant) right).Value);
+                                               ((BoolConstant) right).Value, left.Location);
                                }
                                if (left is NullLiteral){
                                        if (right is NullLiteral)
-                                               return new BoolConstant (false);
+                                               return new BoolConstant (false, left.Location);
                                        else if (right is StringConstant)
                                                return new BoolConstant (
-                                                       ((StringConstant) right).Value != null);
+                                                       ((StringConstant) right).Value != null, left.Location);
                                } else if (right is NullLiteral){
                                        if (left is NullLiteral)
-                                               return new BoolConstant (false);
+                                               return new BoolConstant (false, left.Location);
                                        else if (left is StringConstant)
                                                return new BoolConstant (
-                                                       ((StringConstant) left).Value != null);
+                                                       ((StringConstant) left).Value != null, left.Location);
                                }
                                if (left is StringConstant && right is StringConstant){
                                        return new BoolConstant (
                                                ((StringConstant) left).Value !=
-                                               ((StringConstant) right).Value);
+                                               ((StringConstant) right).Value, left.Location);
                                        
                                }
                                DoConstantNumericPromotions (ec, oper, ref left, ref right, loc);
@@ -1140,7 +1114,7 @@ namespace Mono.CSharp {
                                else
                                        return null;
 
-                               return new BoolConstant (bool_res);
+                               return new BoolConstant (bool_res, left.Location);
 
                        case Binary.Operator.LessThan:
                                DoConstantNumericPromotions (ec, oper, ref left, ref right, loc);
@@ -1169,7 +1143,7 @@ namespace Mono.CSharp {
                                else
                                        return null;
 
-                               return new BoolConstant (bool_res);
+                               return new BoolConstant (bool_res, left.Location);
                                
                        case Binary.Operator.GreaterThan:
                                DoConstantNumericPromotions (ec, oper, ref left, ref right, loc);
@@ -1198,7 +1172,7 @@ namespace Mono.CSharp {
                                else
                                        return null;
 
-                               return new BoolConstant (bool_res);
+                               return new BoolConstant (bool_res, left.Location);
 
                        case Binary.Operator.GreaterThanOrEqual:
                                DoConstantNumericPromotions (ec, oper, ref left, ref right, loc);
@@ -1227,7 +1201,7 @@ namespace Mono.CSharp {
                                else
                                        return null;
 
-                               return new BoolConstant (bool_res);
+                               return new BoolConstant (bool_res, left.Location);
 
                        case Binary.Operator.LessThanOrEqual:
                                DoConstantNumericPromotions (ec, oper, ref left, ref right, loc);
@@ -1256,7 +1230,7 @@ namespace Mono.CSharp {
                                else
                                        return null;
 
-                               return new BoolConstant (bool_res);
+                               return new BoolConstant (bool_res, left.Location);
                        }
                                        
                        return null;