Author: raja
Date: 2005-03-07 02:08:31 -0500 (Mon, 07 Mar 2005)
New Revision: 41506
Added:
trunk/mcs/errors/cs0120-6.cs
trunk/mcs/errors/cs0120-7.cs
Modified:
trunk/mcs/errors/ChangeLog
trunk/mcs/errors/gmcs-ignore-tests
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/ecore.cs
Log:
Fix #73394.
* mcs/ecore.cs (FieldExpr.EmitInstance): Catch cases of CS0120 that
slipped in because of variable names that are identical to a
builtin type's BCL equivalent ('string String;', 'int Int32;').
(PropertyExpr.EmitInstance): Likewise.
* errors/cs0120-6.cs, errors/cs0120-7.cs: New tests from #73394.
Modified: trunk/mcs/errors/ChangeLog
===================================================================
--- trunk/mcs/errors/ChangeLog 2005-03-07 06:58:11 UTC (rev 41505)
+++ trunk/mcs/errors/ChangeLog 2005-03-07 07:08:31 UTC (rev 41506)
@@ -1,3 +1,7 @@
+2005-03-07 Raja R Harinath <[EMAIL PROTECTED]>
+
+ * cs0120-6.cs, cs0120-7.cs: New tests from #73394.
+
2005-02-28 Raja R Harinath <[EMAIL PROTECTED]>
* cs0053-2.cs: New test from #73052.
Added: trunk/mcs/errors/cs0120-6.cs
===================================================================
--- trunk/mcs/errors/cs0120-6.cs 2005-03-07 06:58:11 UTC (rev 41505)
+++ trunk/mcs/errors/cs0120-6.cs 2005-03-07 07:08:31 UTC (rev 41506)
@@ -0,0 +1,14 @@
+// CS0120: An object reference is required for the non-static field `Int32'
+// Line: 11
+
+using System;
+
+public class MemRefMonoBug {
+ private int Int32; // this member has the same name as
System.Int32 class
+ public static void Main ()
+ {
+ new MemRefMonoBug ().Int32 = 0; // this line causes no problem
+ Int32 = 0; // mcs crashes in this line
+ }
+}
+
Added: trunk/mcs/errors/cs0120-7.cs
===================================================================
--- trunk/mcs/errors/cs0120-7.cs 2005-03-07 06:58:11 UTC (rev 41505)
+++ trunk/mcs/errors/cs0120-7.cs 2005-03-07 07:08:31 UTC (rev 41506)
@@ -0,0 +1,14 @@
+// CS0120: An object reference is required for the non-static field `String'
+// Line: 11
+
+using System;
+
+public class MemRefMonoBug {
+ private string String; // this member has the same name as
System.String class
+ public static void Main ()
+ {
+ new MemRefMonoBug ().String = ""; // this line causes no
problem
+ String = ""; // mcs crashes in this line
+ }
+}
+
Modified: trunk/mcs/errors/gmcs-ignore-tests
===================================================================
--- trunk/mcs/errors/gmcs-ignore-tests 2005-03-07 06:58:11 UTC (rev 41505)
+++ trunk/mcs/errors/gmcs-ignore-tests 2005-03-07 07:08:31 UTC (rev 41506)
@@ -3,4 +3,6 @@
cs0053-2.cs
cs0120-5.cs
+cs0120-6.cs
+cs0120-7.cs
cs0131-3.cs
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2005-03-07 06:58:11 UTC (rev 41505)
+++ trunk/mcs/mcs/ChangeLog 2005-03-07 07:08:31 UTC (rev 41506)
@@ -1,3 +1,11 @@
+2005-03-07 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Fix #73394.
+ * ecore.cs (FieldExpr.EmitInstance): Catch cases of CS0120 that
+ slipped in because of variable names that are identical to a
+ builtin type's BCL equivalent ('string String;', 'int Int32;').
+ (PropertyExpr.EmitInstance): Likewise.
+
2005-03-04 Marek Safar <[EMAIL PROTECTED]>
* cs-tokenizer.cs (PreProcessPragma): Add warning 1633, 1635.
Modified: trunk/mcs/mcs/ecore.cs
===================================================================
--- trunk/mcs/mcs/ecore.cs 2005-03-07 06:58:11 UTC (rev 41505)
+++ trunk/mcs/mcs/ecore.cs 2005-03-07 07:08:31 UTC (rev 41506)
@@ -2934,6 +2934,16 @@
void EmitInstance (EmitContext ec)
{
+ //
+ // In case it escapes StaticMemberCheck due to
IdenticalTypeAndName.
+ // This happens in cases like 'string String', 'int
Int32', etc.
+ // where the "IdenticalTypeAndName" mechanism is fooled.
+ //
+ if (instance_expr == null) {
+ SimpleName.Error_ObjectRefRequired (ec, loc,
FieldInfo.Name);
+ return;
+ }
+
if (instance_expr.Type.IsValueType) {
if (instance_expr is IMemoryLocation) {
((IMemoryLocation)
instance_expr).AddressOf (ec, AddressOp.LoadStore);
@@ -3313,6 +3323,16 @@
if (is_static)
return;
+ //
+ // In case it escapes StaticMemberCheck due to
IdenticalTypeAndName.
+ // This happens in cases like 'string String', 'int
Int32', etc.
+ // where the "IdenticalTypeAndName" mechanism is fooled.
+ //
+ if (instance_expr == null) {
+ SimpleName.Error_ObjectRefRequired (ec, loc,
PropertyInfo.Name);
+ return;
+ }
+
if (instance_expr.Type.IsValueType) {
if (instance_expr is IMemoryLocation) {
((IMemoryLocation)
instance_expr).AddressOf (ec, AddressOp.LoadStore);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches