mcs chokes when trying to take the address of a pointer variable. The
attached patch fixes this and adds a test case.
Index: mcs/ChangeLog
===================================================================
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 <[EMAIL PROTECTED]>
+
+ * typemanager.cs (TypeManager.VerifyUnManaged): Allow
+ address-of operator on both value types and pointers.
+
2002-06-10 Martin Baulig <[EMAIL PROTECTED]>
* interface.cs (Interface.PopulateIndexer): Add the indexer's
Index: mcs/typemanager.cs
===================================================================
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
===================================================================
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 <[EMAIL PROTECTED]>
+
+ * unsafe-3.cs: New test for address-of-pointer.
+
2002-06-09 Martin Baulig <[EMAIL PROTECTED]>
* test-130.cs: New test for constants and casts.
Index: tests/makefile
===================================================================
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 test-129 test-130
UNSAFE_SOURCES = \
- unsafe-1 unsafe-2
+ unsafe-1 unsafe-2 unsafe-3
TEST_NOPASS = \
test-29 test-38 \
Index: tests/unsafe-3.cs
===================================================================
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 = 42;
+ b = &a;
+ c = &b;
+
+ Console.WriteLine ("*c == b : {0}", *c == b);
+ Console.WriteLine ("**c == a : {0}", **c == a);
+
+ if (*c == b && **c == a)
+ {
+ Console.WriteLine ("Test passed");
+ return 0;
+ }
+ else
+ {
+ Console.WriteLine ("Test failed");
+ return 1;
+ }
+ }
+}