[Mono-list] PATCH: Address of a pointer
Rachel Hestilow
hestilow@ximian.com
10 Jun 2002 20:11:57 -0500
--=-ZHcyuteawV1+y0WpHzDt
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
mcs chokes when trying to take the address of a pointer variable. The
attached patch fixes this and adds a test case.
--=-ZHcyuteawV1+y0WpHzDt
Content-Disposition: inline; filename=pointer.diff
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-patch; name=pointer.diff; charset=ISO-8859-1
Index: mcs/ChangeLog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/mcs/ChangeLog,v
retrieving revision 1.506
diff -u -r1.506 ChangeLog
--- mcs/ChangeLog 10 Jun 2002 08:34:32 -0000 1.506
+++ mcs/ChangeLog 10 Jun 2002 21:28:16 -0000
@@ -1,3 +1,8 @@
+2002-06-10 Rachel Hestilow <hestilow@ximian.com>
+
+ * typemanager.cs (TypeManager.VerifyUnManaged): Allow
+ address-of operator on both value types and pointers.
+=09
2002-06-10 Martin Baulig <martin@gnome.org>
=20
* interface.cs (Interface.PopulateIndexer): Add the indexer's
Index: mcs/typemanager.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/mcs/typemanager.cs,v
retrieving revision 1.131
diff -u -r1.131 typemanager.cs
--- mcs/typemanager.cs 9 Jun 2002 15:17:57 -0000 1.131
+++ mcs/typemanager.cs 10 Jun 2002 21:28:16 -0000
@@ -1184,7 +1184,7 @@
/// </summary>
public static bool VerifyUnManaged (Type t, Location loc)
{
- if (t.IsValueType){
+ if (t.IsValueType || t.IsPointer){
//
// FIXME: this is more complex, we actually need to
// make sure that the type does not contain any
Index: tests/ChangeLog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/tests/ChangeLog,v
retrieving revision 1.78
diff -u -r1.78 ChangeLog
--- tests/ChangeLog 9 Jun 2002 15:14:33 -0000 1.78
+++ tests/ChangeLog 10 Jun 2002 21:28:16 -0000
@@ -1,3 +1,7 @@
+2002-06-10 Rachel Hestilow <hestilow@ximian.com>
+
+ * unsafe-3.cs: New test for address-of-pointer.
+=09
2002-06-09 Martin Baulig <martin@gnome.org>
=20
* test-130.cs: New test for constants and casts.
Index: tests/makefile
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/tests/makefile,v
retrieving revision 1.116
diff -u -r1.116 makefile
--- tests/makefile 9 Jun 2002 15:14:34 -0000 1.116
+++ tests/makefile 10 Jun 2002 21:28:16 -0000
@@ -19,7 +19,7 @@
test-121 test-122 test-123 test-125 test-126 test-127 test-128 t=
est-129 test-130
=20
UNSAFE_SOURCES =3D \
- unsafe-1 unsafe-2
+ unsafe-1 unsafe-2 unsafe-3
=20
TEST_NOPASS =3D \
test-29 test-38 \
Index: tests/unsafe-3.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: tests/unsafe-3.cs
diff -N tests/unsafe-3.cs
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/unsafe-3.cs 10 Jun 2002 21:28:16 -0000
@@ -0,0 +1,31 @@
+// this tests making a pointer to a pointer
+
+using System;
+
+unsafe class Foo
+{
+ public static int Main ()
+ {
+ int a;
+ int *b;
+ int **c;
+
+ a =3D 42;
+ b =3D &a;
+ c =3D &b;
+ =09
+ Console.WriteLine ("*c =3D=3D b : {0}", *c =3D=3D b);
+ Console.WriteLine ("**c =3D=3D a : {0}", **c =3D=3D a);
+
+ if (*c =3D=3D b && **c =3D=3D a)
+ {
+ Console.WriteLine ("Test passed");
+ return 0;
+ }
+ else
+ {
+ Console.WriteLine ("Test failed");
+ return 1;
+ }
+ }
+}
--=-ZHcyuteawV1+y0WpHzDt--