Changeset 639
- Timestamp:
- 08/28/10 03:15:45 (1 year ago)
- Files:
-
- branches/dmd-1.x/src/aggregate.h (modified) (1 diff)
- branches/dmd-1.x/src/class.c (modified) (3 diffs)
- branches/dmd-1.x/src/declaration.c (modified) (6 diffs)
- branches/dmd-1.x/src/declaration.h (modified) (3 diffs)
- branches/dmd-1.x/src/expression.c (modified) (1 diff)
- branches/dmd-1.x/src/func.c (modified) (2 diffs)
- branches/dmd-1.x/src/mtype.c (modified) (6 diffs)
- branches/dmd-1.x/src/mtype.h (modified) (2 diffs)
- branches/dmd-1.x/src/statement.c (modified) (4 diffs)
- trunk/src/aggregate.h (modified) (1 diff)
- trunk/src/class.c (modified) (3 diffs)
- trunk/src/clone.c (modified) (1 diff)
- trunk/src/declaration.c (modified) (7 diffs)
- trunk/src/declaration.h (modified) (3 diffs)
- trunk/src/expression.c (modified) (1 diff)
- trunk/src/func.c (modified) (2 diffs)
- trunk/src/mtype.c (modified) (7 diffs)
- trunk/src/mtype.h (modified) (2 diffs)
- trunk/src/statement.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/aggregate.h
r638 r639 221 221 int com; // !=0 if this is a COM class (meaning 222 222 // it derives from IUnknown) 223 int is auto;// !=0 if this is an auto class223 int isscope; // !=0 if this is an auto class 224 224 int isabstract; // !=0 if abstract class 225 225 #if DMDV1 branches/dmd-1.x/src/class.c
r638 r639 192 192 193 193 com = 0; 194 is auto= 0;194 isscope = 0; 195 195 isabstract = 0; 196 196 isnested = 0; … … 472 472 // Inherit properties from base class 473 473 com = baseClass->isCOMclass(); 474 is auto = baseClass->isauto;474 isscope = baseClass->isscope; 475 475 vthis = baseClass->vthis; 476 476 } … … 554 554 } 555 555 556 if (storage_class & (STCauto | STCscope)) 557 isauto = 1; 556 if (storage_class & STCauto) 557 error("storage class 'auto' is invalid when declaring a class, did you mean to use 'scope'?"); 558 if (storage_class & STCscope) 559 isscope = 1; 558 560 if (storage_class & STCabstract) 559 561 isabstract = 1; branches/dmd-1.x/src/declaration.c
r608 r639 675 675 this->loc = loc; 676 676 offset = 0; 677 no auto= 0;677 noscope = 0; 678 678 #if DMDV2 679 679 isargptr = FALSE; … … 805 805 } 806 806 } 807 if ((storage_class & STCauto) && !inferred) 808 error("storage class 'auto' has no effect if type is not inferred, did you mean 'scope'?"); 807 809 808 810 if (tb->ty == Ttuple) … … 938 940 #endif 939 941 940 if (type->is auto() && !noauto)942 if (type->isscope() && !noscope) 941 943 { 942 944 if (storage_class & (STCfield | STCout | STCref | STCstatic) || !fd) … … 945 947 } 946 948 947 if (!(storage_class & (STCauto | STCscope)))949 if (!(storage_class & STCscope)) 948 950 { 949 951 if (!(storage_class & STCparameter) && ident != Id::withSym) … … 1379 1381 1380 1382 /****************************************** 1381 * If a variable has a n autodestructor call, return call for it.1383 * If a variable has a scope destructor call, return call for it. 1382 1384 * Otherwise, return NULL. 1383 1385 */ 1384 1386 1385 Expression *VarDeclaration::call AutoDtor(Scope *sc)1387 Expression *VarDeclaration::callScopeDtor(Scope *sc) 1386 1388 { Expression *e = NULL; 1387 1389 1388 //printf("VarDeclaration::call AutoDtor() %s\n", toChars());1389 if (storage_class & (STCauto | STCscope) && !no auto)1390 //printf("VarDeclaration::callScopeDtor() %s\n", toChars()); 1391 if (storage_class & (STCauto | STCscope) && !noscope) 1390 1392 { 1391 1393 for (ClassDeclaration *cd = type->isClassHandle(); … … 1593 1595 : VarDeclaration(loc, t, Id::This, NULL) 1594 1596 { 1595 no auto= 1;1597 noscope = 1; 1596 1598 } 1597 1599 branches/dmd-1.x/src/declaration.h
r591 r639 142 142 int isImmutable() { return storage_class & STCimmutable; } 143 143 int isAuto() { return storage_class & STCauto; } 144 int isScope() { return storage_class & (STCscope | STCauto); }144 int isScope() { return storage_class & STCscope; } 145 145 int isSynchronized() { return storage_class & STCsynchronized; } 146 146 int isParameter() { return storage_class & STCparameter; } … … 244 244 Initializer *init; 245 245 unsigned offset; 246 int no auto; // no auto semantics246 int noscope; // no auto semantics 247 247 #if DMDV2 248 248 FuncDeclarations nestedrefs; // referenced by these lexically nested functions … … 284 284 int needsAutoDtor(); 285 285 #endif 286 Expression *call AutoDtor(Scope *sc);286 Expression *callScopeDtor(Scope *sc); 287 287 ExpInitializer *getExpInitializer(); 288 288 Expression *getConstInitializer(); branches/dmd-1.x/src/expression.c
r637 r639 4008 4008 if (tb->ty == Tarray || tb->ty == Tsarray || tb->ty == Tclass) 4009 4009 { 4010 if ( (v->isAuto() || v->isScope()) && !v->noauto)4010 if (v->isScope() && !v->noscope) 4011 4011 error("escaping reference to auto local %s", v->toChars()); 4012 4012 else if (v->storage_class & STCvariadic) branches/dmd-1.x/src/func.c
r603 r639 958 958 959 959 v = new VarDeclaration(loc, type->nextOf(), outId, NULL); 960 v->no auto= 1;960 v->noscope = 1; 961 961 #if DMDV2 962 962 if (!isVirtual()) … … 1368 1368 continue; 1369 1369 1370 Expression *e = v->call AutoDtor(sc);1370 Expression *e = v->callScopeDtor(sc); 1371 1371 if (e) 1372 1372 { Statement *s = new ExpStatement(0, e); branches/dmd-1.x/src/mtype.c
r619 r639 505 505 } 506 506 507 int Type::is auto()507 int Type::isscope() 508 508 { 509 509 return FALSE; … … 1928 1928 break; 1929 1929 } 1930 if (tbn->is auto())1930 if (tbn->isscope()) 1931 1931 error(loc, "cannot have array of auto %s", tbn->toChars()); 1932 1932 return merge(); … … 2106 2106 break; 2107 2107 } 2108 if (tn->is auto())2109 error(loc, "cannot have array of auto%s", tn->toChars());2108 if (tn->isscope()) 2109 error(loc, "cannot have array of scope %s", tn->toChars()); 2110 2110 if (next != tn) 2111 2111 //deco = NULL; // redo … … 2303 2303 break; 2304 2304 } 2305 if (next->is auto())2305 if (next->isscope()) 2306 2306 error(loc, "cannot have array of auto %s", next->toChars()); 2307 2307 … … 2873 2873 tf->next = Type::terror; 2874 2874 } 2875 if (tf->next->is auto() && !(sc->flags & SCOPEctor))2876 error(loc, "functions cannot return auto%s", tf->next->toChars());2875 if (tf->next->isscope() && !(sc->flags & SCOPEctor)) 2876 error(loc, "functions cannot return scope %s", tf->next->toChars()); 2877 2877 } 2878 2878 … … 5013 5013 } 5014 5014 5015 int TypeClass::is auto()5016 { 5017 return sym->is auto;5015 int TypeClass::isscope() 5016 { 5017 return sym->isscope; 5018 5018 } 5019 5019 branches/dmd-1.x/src/mtype.h
r619 r639 218 218 virtual int isscalar(); 219 219 virtual int isunsigned(); 220 virtual int is auto();220 virtual int isscope(); 221 221 virtual int isString(); 222 222 virtual int checkBoolean(); // if can be converted to boolean value … … 672 672 int isZeroInit(Loc loc); 673 673 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 674 int is auto();674 int isscope(); 675 675 int checkBoolean(); 676 676 TypeInfoDeclaration *getTypeInfoDeclaration(); branches/dmd-1.x/src/statement.c
r586 r639 371 371 { Expression *e; 372 372 373 e = v->call AutoDtor(sc);373 e = v->callScopeDtor(sc); 374 374 if (e) 375 375 { … … 1696 1696 { 1697 1697 VarDeclaration *v = new VarDeclaration(loc, tret, Id::result, NULL); 1698 v->no auto= 1;1698 v->noscope = 1; 1699 1699 v->semantic(sc); 1700 1700 if (!sc->insert(v)) … … 2224 2224 Type *t = arg->type ? arg->type : condition->type; 2225 2225 match = new VarDeclaration(loc, t, arg->ident, NULL); 2226 match->no auto= 1;2226 match->noscope = 1; 2227 2227 match->semantic(scd); 2228 2228 if (!scd->insert(match)) … … 3298 3298 { // Declare vresult 3299 3299 VarDeclaration *v = new VarDeclaration(loc, tret, Id::result, NULL); 3300 v->no auto= 1;3300 v->noscope = 1; 3301 3301 v->semantic(scx); 3302 3302 if (!scx->insert(v)) trunk/src/aggregate.h
r638 r639 224 224 int com; // !=0 if this is a COM class (meaning 225 225 // it derives from IUnknown) 226 int is auto; // !=0 if this is an auto class226 int isscope; // !=0 if this is an auto class 227 227 int isabstract; // !=0 if abstract class 228 228 #if DMDV1 trunk/src/class.c
r638 r639 197 197 198 198 com = 0; 199 is auto= 0;199 isscope = 0; 200 200 isabstract = 0; 201 201 inuse = 0; … … 480 480 // Inherit properties from base class 481 481 com = baseClass->isCOMclass(); 482 is auto = baseClass->isauto;482 isscope = baseClass->isscope; 483 483 vthis = baseClass->vthis; 484 484 storage_class |= baseClass->storage_class & STC_TYPECTOR; … … 564 564 } 565 565 566 if (storage_class & (STCauto | STCscope)) 567 isauto = 1; 566 if (storage_class & STCauto) 567 error("storage class 'auto' is invalid when declaring a class, did you mean to use 'scope'?"); 568 if (storage_class & STCscope) 569 isscope = 1; 568 570 if (storage_class & STCabstract) 569 571 isabstract = 1; trunk/src/clone.c
r581 r639 158 158 { 159 159 tmp = new VarDeclaration(0, type, idtmp, new VoidInitializer(0)); 160 tmp->no auto= 1;160 tmp->noscope = 1; 161 161 tmp->storage_class |= STCctfe; 162 162 e = new DeclarationExp(0, tmp); trunk/src/declaration.c
r610 r639 653 653 this->loc = loc; 654 654 offset = 0; 655 no auto= 0;655 noscope = 0; 656 656 #if DMDV2 657 657 isargptr = FALSE; … … 825 825 } 826 826 } 827 if ((storage_class & STCauto) && !inferred) 828 error("storage class 'auto' has no effect if type is not inferred, did you mean 'scope'?"); 827 829 828 830 if (tb->ty == Ttuple) … … 976 978 #endif 977 979 978 if (type->is auto() && !noauto)980 if (type->isscope() && !noscope) 979 981 { 980 982 if (storage_class & (STCfield | STCout | STCref | STCstatic | STCmanifest | STCtls | STCgshared) || !fd) … … 983 985 } 984 986 985 if (!(storage_class & (STCauto | STCscope)))987 if (!(storage_class & STCscope)) 986 988 { 987 989 if (!(storage_class & STCparameter) && ident != Id::withSym) … … 1591 1593 //printf("VarDeclaration::needsAutoDtor() %s\n", toChars()); 1592 1594 1593 if (no auto|| storage_class & STCnodtor)1595 if (noscope || storage_class & STCnodtor) 1594 1596 return FALSE; 1595 1597 … … 1618 1620 1619 1621 /****************************************** 1620 * If a variable has a n autodestructor call, return call for it.1622 * If a variable has a scope destructor call, return call for it. 1621 1623 * Otherwise, return NULL. 1622 1624 */ 1623 1625 1624 Expression *VarDeclaration::call AutoDtor(Scope *sc)1626 Expression *VarDeclaration::callScopeDtor(Scope *sc) 1625 1627 { Expression *e = NULL; 1626 1628 1627 //printf("VarDeclaration::call AutoDtor() %s\n", toChars());1628 1629 if (no auto|| storage_class & STCnodtor)1629 //printf("VarDeclaration::callScopeDtor() %s\n", toChars()); 1630 1631 if (noscope || storage_class & STCnodtor) 1630 1632 return NULL; 1631 1633 … … 1898 1900 : VarDeclaration(loc, t, Id::This, NULL) 1899 1901 { 1900 no auto= 1;1902 noscope = 1; 1901 1903 } 1902 1904 trunk/src/declaration.h
r591 r639 141 141 int isImmutable() { return storage_class & STCimmutable; } 142 142 int isAuto() { return storage_class & STCauto; } 143 int isScope() { return storage_class & (STCscope | STCauto); }143 int isScope() { return storage_class & STCscope; } 144 144 int isSynchronized() { return storage_class & STCsynchronized; } 145 145 int isParameter() { return storage_class & STCparameter; } … … 240 240 Initializer *init; 241 241 unsigned offset; 242 int no auto; // no auto semantics242 int noscope; // no auto semantics 243 243 #if DMDV2 244 244 FuncDeclarations nestedrefs; // referenced by these lexically nested functions … … 280 280 int needsAutoDtor(); 281 281 #endif 282 Expression *call AutoDtor(Scope *sc);282 Expression *callScopeDtor(Scope *sc); 283 283 ExpInitializer *getExpInitializer(); 284 284 Expression *getConstInitializer(); trunk/src/expression.c
r634 r639 4342 4342 if (tb->ty == Tarray || tb->ty == Tsarray || tb->ty == Tclass) 4343 4343 { 4344 if ( (v->isAuto() || v->isScope()) && !v->noauto)4344 if (v->isScope() && !v->noscope) 4345 4345 error("escaping reference to scope local %s", v->toChars()); 4346 4346 else if (v->storage_class & STCvariadic) trunk/src/func.c
r611 r639 1108 1108 1109 1109 VarDeclaration *v = new VarDeclaration(loc, type->nextOf(), outId, NULL); 1110 v->no auto= 1;1110 v->noscope = 1; 1111 1111 v->storage_class |= STCresult; 1112 1112 #if DMDV2 … … 1519 1519 continue; 1520 1520 1521 Expression *e = v->call AutoDtor(sc2);1521 Expression *e = v->callScopeDtor(sc2); 1522 1522 if (e) 1523 1523 { Statement *s = new ExpStatement(0, e); trunk/src/mtype.c
r638 r639 1577 1577 } 1578 1578 1579 int Type::is auto()1579 int Type::isscope() 1580 1580 { 1581 1581 return FALSE; … … 3398 3398 break; 3399 3399 } 3400 if (tbn->is auto())3401 error(loc, "cannot have array of auto%s", tbn->toChars());3400 if (tbn->isscope()) 3401 error(loc, "cannot have array of scope %s", tbn->toChars()); 3402 3402 return merge(); 3403 3403 } … … 3627 3627 } 3628 3628 } 3629 if (tn->is auto())3630 error(loc, "cannot have array of auto%s", tn->toChars());3629 if (tn->isscope()) 3630 error(loc, "cannot have array of scope %s", tn->toChars()); 3631 3631 3632 3632 next = tn; … … 3830 3830 } 3831 3831 } 3832 if (tn->is auto())3833 error(loc, "cannot have array of auto%s", tn->toChars());3832 if (tn->isscope()) 3833 error(loc, "cannot have array of scope %s", tn->toChars()); 3834 3834 3835 3835 next = tn; … … 3958 3958 return Type::terror; 3959 3959 } 3960 if (next->is auto())3961 { error(loc, "cannot have array of auto%s", next->toChars());3960 if (next->isscope()) 3961 { error(loc, "cannot have array of scope %s", next->toChars()); 3962 3962 return Type::terror; 3963 3963 } … … 4858 4858 tf->next = Type::terror; 4859 4859 } 4860 if (tf->next->is auto() && !(sc->flags & SCOPEctor))4860 if (tf->next->isscope() && !(sc->flags & SCOPEctor)) 4861 4861 error(loc, "functions cannot return scope %s", tf->next->toChars()); 4862 4862 if (tf->next->toBasetype()->ty == Tvoid) … … 7420 7420 } 7421 7421 7422 int TypeClass::is auto()7423 { 7424 return sym->is auto;7422 int TypeClass::isscope() 7423 { 7424 return sym->isscope; 7425 7425 } 7426 7426 trunk/src/mtype.h
r619 r639 247 247 virtual int isscalar(); 248 248 virtual int isunsigned(); 249 virtual int is auto();249 virtual int isscope(); 250 250 virtual int isString(); 251 251 virtual int isAssignable(); … … 815 815 int isZeroInit(Loc loc); 816 816 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 817 int is auto();817 int isscope(); 818 818 int checkBoolean(); 819 819 TypeInfoDeclaration *getTypeInfoDeclaration(); trunk/src/statement.c
r636 r639 387 387 { Expression *e; 388 388 389 e = v->call AutoDtor(sc);389 e = v->callScopeDtor(sc); 390 390 if (e) 391 391 { … … 1761 1761 { 1762 1762 VarDeclaration *v = new VarDeclaration(loc, tret, Id::result, NULL); 1763 v->no auto= 1;1763 v->noscope = 1; 1764 1764 v->semantic(sc); 1765 1765 if (!sc->insert(v)) … … 2341 2341 Type *t = arg->type ? arg->type : condition->type; 2342 2342 match = new VarDeclaration(loc, t, arg->ident, NULL); 2343 match->no auto= 1;2343 match->noscope = 1; 2344 2344 match->semantic(scd); 2345 2345 if (!scd->insert(match)) … … 3497 3497 { // Declare vresult 3498 3498 VarDeclaration *v = new VarDeclaration(loc, tret, Id::result, NULL); 3499 v->no auto= 1;3499 v->noscope = 1; 3500 3500 v->storage_class |= STCresult; 3501 3501 v->semantic(scx);
