diff dmd/VarExp.d @ 137:09c858522d55

merge
author Trass3r
date Mon, 13 Sep 2010 23:29:00 +0200
parents af1bebfd96a4
children fe2e1b93e88f
line wrap: on
line diff
--- a/dmd/VarExp.d	Mon Sep 13 23:27:38 2010 +0200
+++ b/dmd/VarExp.d	Mon Sep 13 23:29:00 2010 +0200
@@ -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)
 {