[Mono-list] [PATCH] Const fold for AddressOf/Indirect

Andrew Birkett andy@nobugs.org
27 Jul 2002 11:29:14 +0100


--=-3CX0rJKT30LGe8rOQ33X
Content-Type: multipart/mixed; boundary="=-Zk7AckdPKuHyLssXSBgs"


--=-Zk7AckdPKuHyLssXSBgs
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Hi,

Here is a trivial patch to fix a crash which I discovered when trying to
stress the parser.  Unary expressions '& 1' and '* 1' (AddressOf and
Indirect) currently crash mcs when it tries to perform constant
folding.  Shall I apply to CVS? =20

Andrew
(new email address, btw)


--=-Zk7AckdPKuHyLssXSBgs
Content-Disposition: attachment; filename=unary-const-fold-patch
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1

Index: expression.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/expression.cs,v
retrieving revision 1.306
diff -u -r1.306 expression.cs
--- expression.cs	24 Jul 2002 22:56:44 -0000	1.306
+++ expression.cs	27 Jul 2002 10:13:53 -0000
@@ -236,8 +236,14 @@
=20
 				Error23 (expr_type);
 				return null;
+
+			case Operator.AddressOf:
+				return e;
+
+			case Operator.Indirection:
+				return e;
 			}
-			throw new Exception ("Can not constant fold");
+			throw new Exception ("Can not constant fold: " + Oper.ToString());
 		}
=20
 		Expression ResolveOperator (EmitContext ec)

--=-Zk7AckdPKuHyLssXSBgs--

--=-3CX0rJKT30LGe8rOQ33X
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQA9QnX5Fc3/QiaGVhgRAqK7AJ4452UaQp+Wvc8MGyll4A+MroizsACeMYFs
g9SvNWxSYTLV8PlFx7zq9zw=
=sxyz
-----END PGP SIGNATURE-----

--=-3CX0rJKT30LGe8rOQ33X--