Author: martin
Date: 2006-06-21 11:54:07 -0400 (Wed, 21 Jun 2006)
New Revision: 61909
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/statement.cs
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/statement.cs
trunk/mcs/tests/ChangeLog
trunk/mcs/tests/test-49.cs
Log:
2006-06-21 Martin Baulig <[EMAIL PROTECTED]>
* statement.cs (GotoCase.Resolve): Report a warning (CS0469)
instead of an error if the value is not implicitly convertible to
the switch types; fixes #77964.
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2006-06-21 15:18:20 UTC (rev 61908)
+++ trunk/mcs/gmcs/ChangeLog 2006-06-21 15:54:07 UTC (rev 61909)
@@ -1,3 +1,9 @@
+2006-06-21 Martin Baulig <[EMAIL PROTECTED]>
+
+ * statement.cs (GotoCase.Resolve): Report a warning (CS0469)
+ instead of an error if the value is not implicitly convertible to
+ the switch types; fixes #77964.
+
2006-06-21 Raja R Harinath <[EMAIL PROTECTED]>
Fix #78673
Modified: trunk/mcs/gmcs/statement.cs
===================================================================
--- trunk/mcs/gmcs/statement.cs 2006-06-21 15:18:20 UTC (rev 61908)
+++ trunk/mcs/gmcs/statement.cs 2006-06-21 15:54:07 UTC (rev 61909)
@@ -817,11 +817,22 @@
return false;
}
- c = c.ToType (ec.Switch.SwitchType, loc);
- if (c == null)
+ Type type = ec.Switch.SwitchType;
+ if (!Convert.ImplicitStandardConversionExists (c, type))
+ Report.Warning (469, 2, loc, "The `goto case'
value is not implicitly " +
+ "convertible to type `{0}'",
TypeManager.CSharpName (type));
+
+ bool fail = false;
+ object val = c.GetValue ();
+ if ((val != null) && (c.Type != type) && (c.Type !=
TypeManager.object_type))
+ val = TypeManager.ChangeType (val, type, out
fail);
+
+ if (fail) {
+ Report.Error (30, loc, "Cannot convert type
`{0}' to `{1}'",
+ c.GetSignatureForError (),
TypeManager.CSharpName (type));
return false;
+ }
- object val = c.GetValue ();
if (val == null)
val = SwitchLabel.NullStringCase;
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2006-06-21 15:18:20 UTC (rev 61908)
+++ trunk/mcs/mcs/ChangeLog 2006-06-21 15:54:07 UTC (rev 61909)
@@ -1,3 +1,9 @@
+2006-06-21 Martin Baulig <[EMAIL PROTECTED]>
+
+ * statement.cs (GotoCase.Resolve): Report a warning (CS0469)
+ instead of an error if the value is not implicitly convertible to
+ the switch types; fixes #77964.
+
2006-06-21 Raja R Harinath <[EMAIL PROTECTED]>
Fix #78673
Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs 2006-06-21 15:18:20 UTC (rev 61908)
+++ trunk/mcs/mcs/statement.cs 2006-06-21 15:54:07 UTC (rev 61909)
@@ -817,11 +817,22 @@
return false;
}
- c = c.ToType (ec.Switch.SwitchType, loc);
- if (c == null)
+ Type type = ec.Switch.SwitchType;
+ if (!Convert.ImplicitStandardConversionExists (c, type))
+ Report.Warning (469, 2, loc, "The `goto case'
value is not implicitly " +
+ "convertible to type `{0}'",
TypeManager.CSharpName (type));
+
+ bool fail = false;
+ object val = c.GetValue ();
+ if ((val != null) && (c.Type != type) && (c.Type !=
TypeManager.object_type))
+ val = TypeManager.ChangeType (val, type, out
fail);
+
+ if (fail) {
+ Report.Error (30, loc, "Cannot convert type
`{0}' to `{1}'",
+ c.GetSignatureForError (),
TypeManager.CSharpName (type));
return false;
+ }
- object val = c.GetValue ();
if (val == null)
val = SwitchLabel.NullStringCase;
Modified: trunk/mcs/tests/ChangeLog
===================================================================
--- trunk/mcs/tests/ChangeLog 2006-06-21 15:18:20 UTC (rev 61908)
+++ trunk/mcs/tests/ChangeLog 2006-06-21 15:54:07 UTC (rev 61909)
@@ -1,3 +1,7 @@
+2006-06-21 Martin Baulig <[EMAIL PROTECTED]>
+
+ * test-49.cs: Add test case for #77964.
+
2006-06-16 Raja R Harinath <[EMAIL PROTECTED]>
* Makefile (DISTFILES): Distribute *.snk.
Modified: trunk/mcs/tests/test-49.cs
===================================================================
--- trunk/mcs/tests/test-49.cs 2006-06-21 15:18:20 UTC (rev 61908)
+++ trunk/mcs/tests/test-49.cs 2006-06-21 15:54:07 UTC (rev 61909)
@@ -530,6 +530,19 @@
break;
}
}
+
+ static void test_77964()
+ {
+ char c = 'c';
+ switch (c)
+ {
+ case 'A':
+ break;
+
+ case 'a':
+ goto case 65;
+ }
+ }
static int Main ()
{
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches