diff dmd/VarExp.d @ 135:af1bebfd96a4 dmd2037

dmd 2.038
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Mon, 13 Sep 2010 22:19:42 +0100
parents 60bb0fe4563e
children fe2e1b93e88f
line wrap: on
line diff
--- a/dmd/VarExp.d	Sat Sep 11 13:03:39 2010 +0100
+++ b/dmd/VarExp.d	Mon Sep 13 22:19:42 2010 +0100
@@ -70,7 +70,7 @@
 		if (v)
 		{
 static if (false) {
-			if ((v.isConst() || v.isInvariant()) && type.toBasetype().ty != TY.Tsarray && v.init)
+			if ((v.isConst() || v.isImmutable()) && type.toBasetype().ty != TY.Tsarray && v.init)
 			{
 				ExpInitializer ei = v.init.isExpInitializer();
 				if (ei)
@@ -121,12 +121,12 @@
 				 * If it is pure, it cannot access any mutable variables other
 				 * than those inside itself
 				 */
-				if (hasPureParent && v.isDataseg() && !v.isInvariant())
+				if (hasPureParent && v.isDataseg() && !v.isImmutable())
 				{
 					error("pure function '%s' cannot access mutable static data '%s'",
 						sc.func.toChars(), v.toChars());
 				}
-				else if (sc.func.isPure() && sc.parent != v.parent && !v.isInvariant() && !(v.storage_class & STC.STCmanifest))
+				else if (sc.func.isPure() && sc.parent != v.parent && !v.isImmutable() && !(v.storage_class & STC.STCmanifest))
 				{
 					error("pure nested function '%s' cannot access mutable data '%s'", sc.func.toChars(), v.toChars());
 					if (v.isEnumDeclaration())
@@ -142,7 +142,7 @@
 	} else {
 			if (sc.func && sc.func.isPure() && !sc.intypeof)
 			{
-				if (v.isDataseg() && !v.isInvariant())
+				if (v.isDataseg() && !v.isImmutable())
 					error("pure function '%s' cannot access mutable static data '%s'", sc.func.toChars(), v.toChars());
 			}
 	}
@@ -207,6 +207,16 @@
 			}
 		}
 	}
+    
+    override void checkEscapeRef()
+    {
+        VarDeclaration v = var.isVarDeclaration();
+        if (v)
+        {
+	    if (!v.isDataseg() && !(v.storage_class & (STCref | STCout)))
+	        error("escaping reference to local variable %s", v.toChars());
+        }
+    }
 
 version (DMDV2)
 {