Mercurial > projects > ldc
diff dmd/declaration.c @ 1530:05c235309d6f
Make the auto storage class never have the same meaning as scope.
This changes the meaning of
auto class MyClass {} and
auto MyClass ident;
Both have been made an error to prevent accidents.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 12 Jul 2009 16:15:21 +0200 |
parents | df11cdec45a2 |
children | e4ff2e15cf5f |
line wrap: on
line diff
--- a/dmd/declaration.c Fri Jul 10 21:30:02 2009 +0200 +++ b/dmd/declaration.c Sun Jul 12 16:15:21 2009 +0200 @@ -619,7 +619,7 @@ #endif this->loc = loc; offset = 0; - noauto = 0; + noscope = 0; nestedref = 0; ctorinit = 0; aliassym = NULL; @@ -747,6 +747,8 @@ error("no definition of struct %s", ts->toChars()); } } + if ((storage_class & STCauto) && !inferred) + error("storage class has no effect: auto"); if (tb->ty == Ttuple) { /* Instead, declare variables for each of the tuple elements @@ -862,14 +864,14 @@ } } - if (type->isauto() && !noauto) + if (type->isscope() && !noscope) { if (storage_class & (STCfield | STCout | STCref | STCstatic) || !fd) { - error("globals, statics, fields, ref and out parameters cannot be auto"); + error("globals, statics, fields, ref and out parameters cannot be scope"); } - if (!(storage_class & (STCauto | STCscope))) + if (!(storage_class & STCscope)) { if (!(storage_class & STCparameter) && ident != Id::withSym) error("reference to scope class must be scope"); @@ -1222,15 +1224,15 @@ } /****************************************** - * If a variable has an auto destructor call, return call for it. + * If a variable has an scope destructor call, return call for it. * Otherwise, return NULL. */ -Expression *VarDeclaration::callAutoDtor() +Expression *VarDeclaration::callScopeDtor() { Expression *e = NULL; - //printf("VarDeclaration::callAutoDtor() %s\n", toChars()); - if (storage_class & (STCauto | STCscope) && !noauto) + //printf("VarDeclaration::callScopeDtor() %s\n", toChars()); + if (storage_class & STCscope && !noscope) { for (ClassDeclaration *cd = type->isClassHandle(); cd; @@ -1430,7 +1432,7 @@ ThisDeclaration::ThisDeclaration(Loc loc, Type *t) : VarDeclaration(loc, t, Id::This, NULL) { - noauto = 1; + noscope = 1; } Dsymbol *ThisDeclaration::syntaxCopy(Dsymbol *s)