Author: marek
Date: 2006-03-20 15:05:56 -0500 (Mon, 20 Mar 2006)
New Revision: 58199

Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/expression.cs
Log:
2006-03-20  Marek Safar  <[EMAIL PROTECTED]>

        * expression.cs (StringConcat.Append): Issue a warning when empty string
        is going to append.

Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2006-03-20 20:02:04 UTC (rev 58198)
+++ trunk/mcs/mcs/ChangeLog     2006-03-20 20:05:56 UTC (rev 58199)
@@ -1,5 +1,10 @@
 2006-03-20  Marek Safar  <[EMAIL PROTECTED]>
 
+       * expression.cs (StringConcat.Append): Issue a warning when empty string
+       is going to append.
+
+2006-03-20  Marek Safar  <[EMAIL PROTECTED]>
+
        * assign.cs (CompoundAssign.ResolveSource): Removed.
 
        * attribute.cs (ResolvePossibleAttributeType): Updated after 
MemberAccess

Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2006-03-20 20:02:04 UTC (rev 58198)
+++ trunk/mcs/mcs/expression.cs 2006-03-20 20:05:56 UTC (rev 58199)
@@ -2925,11 +2925,17 @@
                        //
                        // Constant folding
                        //
-                       if (operand is StringConstant && operands.Count != 0) {
-                               StringConstant last_operand = operands 
[operands.Count - 1] as StringConstant;
-                               if (last_operand != null) {
-                                       operands [operands.Count - 1] = new 
StringConstant (last_operand.Value + ((StringConstant) operand).Value, 
last_operand.Location);
-                                       return;
+                       StringConstant sc = operand as StringConstant;
+                       if (sc != null) {
+                               if (sc.Value.Length == 0)
+                                       Report.Warning (-300, 3, Location, 
"Appending an empty string has no effect. Did you intend to append a space 
string?");
+
+                               if (operands.Count != 0) {
+                                       StringConstant last_operand = operands 
[operands.Count - 1] as StringConstant;
+                                       if (last_operand != null) {
+                                               operands [operands.Count - 1] = 
new StringConstant (last_operand.Value + ((StringConstant) operand).Value, 
last_operand.Location);
+                                               return;
+                                       }
                                }
                        }
                        

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

Reply via email to