diff dmd/VarDeclaration.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 b7b61140701d
line wrap: on
line diff
--- a/dmd/VarDeclaration.d	Sat Sep 11 13:03:39 2010 +0100
+++ b/dmd/VarDeclaration.d	Mon Sep 13 22:19:42 2010 +0100
@@ -343,10 +343,12 @@
 		if (type.isShared())
 			storage_class |= STC.STCshared;
 		}
-		else if (type.isInvariant())
+		else if (type.isImmutable())
 		storage_class |= STC.STCimmutable;
 		else if (type.isShared())
 		storage_class |= STC.STCshared;
+        else if (type.isWild())
+	    storage_class |= STC.STCwild;
 
 		if (isSynchronized())
 		{
@@ -422,6 +424,13 @@
 		{
 			error("only parameters or foreach declarations can be ref");
 		}
+
+        if ((storage_class & (STCstatic | STCextern | STCtls | STCgshared | STCmanifest) ||
+	        isDataseg()) &&
+	        type.hasWild())
+        {
+	        error("only fields, parameters or stack based variables can be inout");
+        }
 }
 
 		if (type.isauto() && !noauto)
@@ -438,7 +447,7 @@
 			}
 		}
 
-		if ((isConst() || isInvariant()) && !init && !fd)
+		if ((isConst() || isImmutable()) && !init && !fd)
 		{
 			// Initialize by constructor only
 			storage_class |= STC.STCctorinit;
@@ -652,7 +661,7 @@
 			}
 		}
 		else if (storage_class & (STC.STCconst | STC.STCimmutable | STC.STCmanifest) ||
-			type.isConst() || type.isInvariant() ||
+			type.isConst() || type.isImmutable() ||
 			parent.isAggregateDeclaration())
 		{
 			/* Because we may need the results of a const declaration in a
@@ -795,7 +804,7 @@
 	{
 static if (false) {
 		printf("VarDeclaration.isDataseg(%p, '%s')\n", this, toChars());
-		printf("%x, %p, %p\n", storage_class & (STC.STCstatic | STC.STCconst), parent.isModule(), parent.isTemplateInstance());
+		printf("%llx, isModule: %p, isTemplateInstance: %p\n", storage_class & (STC.STCstatic | STC.STCconst), parent.isModule(), parent.isTemplateInstance());
 		printf("parent = '%s'\n", parent.toChars());
 }
 		if (storage_class & STC.STCmanifest)
@@ -830,6 +839,15 @@
 }
 	}
 	
+    /********************************************
+     * Can variable be read and written by CTFE?
+     */
+
+    int isCTFE()
+    {
+        return (storage_class & STCctfe) || !isDataseg();
+    }
+
     override bool hasPointers()
 	{
 		//printf("VarDeclaration.hasPointers() %s, ty = %d\n", toChars(), type.ty);
@@ -844,7 +862,7 @@
 		 *	const int x = 3;
 		 * are not stored and hence cannot have their address taken.
 		 */
-		if ((isConst() || isInvariant()) && (storage_class & STC.STCinit) && (!(storage_class & (STC.STCstatic | STC.STCextern)) || (storage_class & STC.STCfield)) &&
+		if ((isConst() || isImmutable()) && (storage_class & STC.STCinit) && (!(storage_class & (STC.STCstatic | STC.STCextern)) || (storage_class & STC.STCfield)) &&
 			(!parent || toParent().isModule() || toParent().isTemplateInstance()) && type.toBasetype().isTypeBasic())
 		{
 			return false;
@@ -992,7 +1010,7 @@
 	 */
     Expression getConstInitializer()
 	{
-		if ((isConst() || isInvariant() || storage_class & STC.STCmanifest) && storage_class & STC.STCinit)
+		if ((isConst() || isImmutable() || storage_class & STC.STCmanifest) && storage_class & STC.STCinit)
 		{
 			ExpInitializer ei = getExpInitializer();
 			if (ei)