diff dmd/declaration.c @ 1621:fb2e6707ad17

Merge DMD r314+r315: bugzilla 2029 Typesafe variadic functions don't... Both DMD revisions are for fixing bugzilla 2029 (Typesafe variadic functions don't work in CTFE). The DMD r314 commit message is: bugzilla 2029 (Typesafe variadic functions don't work in CTFE The DMD r315 commit message is: bugzilla 2029 - try again --- dmd/constfold.c | 11 ++++- dmd/declaration.c | 21 +++++++++- dmd/declaration.h | 10 ++++- dmd/expression.c | 1 + dmd/interpret.c | 111 +++++++++++++++++++++++++++++++++++++++++++++-------- dmd/mars.h | 2 +- dmd/mtype.c | 2 +- 7 files changed, 135 insertions(+), 23 deletions(-)
author Leandro Lucarella <llucax@gmail.com>
date Wed, 06 Jan 2010 15:18:22 -0300
parents c61782a76dff
children 44b145be2ef5
line wrap: on
line diff
--- a/dmd/declaration.c	Wed Jan 06 15:18:22 2010 -0300
+++ b/dmd/declaration.c	Wed Jan 06 15:18:22 2010 -0300
@@ -309,6 +309,9 @@
     {	sem = 1;
 	basetype = basetype->semantic(loc, sc);
 	sem = 2;
+#if DMDV2
+	type = type->addStorageClass(storage_class);
+#endif
 	type = type->semantic(loc, sc);
 	if (sc->parent->isFuncDeclaration() && init)
 	    semantic2(sc);
@@ -441,8 +444,10 @@
     }
     this->inSemantic = 1;
 
+#if DMDV1   // don't really know why this is here
     if (storage_class & STCconst)
 	error("cannot be const");
+#endif
 
     storage_class |= sc->stc & STCdeprecated;
 
@@ -473,11 +478,12 @@
 	goto L2;			// it's a symbolic alias
 
 #if DMDV2
+    type = type->addStorageClass(storage_class);
     if (storage_class & (STCref | STCnothrow | STCpure))
     {	// For 'ref' to be attached to function types, and picked
 	// up by Type::resolve(), it has to go into sc.
 	sc = sc->push();
-	sc->stc |= storage_class & (STCref | STCnothrow | STCpure);
+	sc->stc |= storage_class & (STCref | STCnothrow | STCpure | STCshared);
 	type->resolve(loc, sc, &e, &t, &s);
 	sc = sc->pop();
     }
@@ -1341,7 +1347,7 @@
 {
 #if 0
     printf("VarDeclaration::isDataseg(%p, '%s')\n", this, toChars());
-    printf("%x, %p, %p\n", storage_class & (STCstatic | STCconst), parent->isModule(), parent->isTemplateInstance());
+    printf("%llx, %p, %p\n", storage_class & (STCstatic | STCconst), parent->isModule(), parent->isTemplateInstance());
     printf("parent = '%s'\n", parent->toChars());
 #endif
     Dsymbol *parent = this->toParent();
@@ -1364,6 +1370,17 @@
     return 0;
 }
 
+/********************************************
+ * Can variable be read and written by CTFE?
+ */
+
+int VarDeclaration::isCTFE()
+{
+    //printf("VarDeclaration::isCTFE(%p, '%s')\n", this, toChars());
+    //printf("%llx\n", storage_class);
+    return (storage_class & STCctfe) || !isDataseg();
+}
+
 int VarDeclaration::hasPointers()
 {
     //printf("VarDeclaration::hasPointers() %s, ty = %d\n", toChars(), type->ty);