Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 776

Show
Ignore:
Timestamp:
12/05/10 04:09:44 (14 years ago)
Author:
walter
Message:

bugzilla 5107 Const-shared classes/structs not typed as shared

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/class.c

    r650 r776  
    553554                    } 
    554555                    else 
    555556                        assert(0); 
    556557                    if (t->ty == Tstruct)       // ref to struct 
    557558                        t = Type::tvoidptr; 
    558559                    assert(!vthis); 
    559560                    vthis = new ThisDeclaration(loc, t); 
    560561                    members->push(vthis); 
    561562                } 
    562563            } 
    563564        } 
    564565    } 
    565566 
    566567    if (storage_class & STCauto) 
    567568        error("storage class 'auto' is invalid when declaring a class, did you mean to use 'scope'?"); 
    568569    if (storage_class & STCscope) 
    569570        isscope = 1; 
    570571    if (storage_class & STCabstract) 
    571572        isabstract = 1; 
    572573    if (storage_class & STCimmutable) 
    573         type = type->invariantOf(); 
    574     else if (storage_class & STCconst) 
    575         type = type->constOf(); 
    576     else if (storage_class & STCshared) 
    577         type = type->sharedOf(); 
     574        type = type->addMod(MODimmutable); 
     575    if (storage_class & STCconst) 
     576        type = type->addMod(MODconst); 
     577    if (storage_class & STCshared) 
     578        type = type->addMod(MODshared); 
    578579 
    579580    sc = sc->push(this); 
    580581    sc->stc &= ~(STCfinal | STCauto | STCscope | STCstatic | 
    581582                 STCabstract | STCdeprecated | STC_TYPECTOR | STCtls | STCgshared); 
    582583    sc->stc |= storage_class & STC_TYPECTOR; 
    583584    sc->parent = this; 
    584585    sc->inunion = 0; 
    585586 
    586587    if (isCOMclass()) 
    587588    { 
    588589#if _WIN32 
    589590        sc->linkage = LINKwindows; 
    590591#else 
    591592        /* This enables us to use COM objects under Linux and 
    592593         * work with things like XPCOM 
    593594         */ 
    594595        sc->linkage = LINKc; 
    595596#endif 
    596597    } 
    597598    sc->protection = PROTpublic; 
  • trunk/src/struct.c

    r719 r776  
    300300 
    301301    unsigned dprogress_save = Module::dprogress; 
    302302 
    303303    parent = sc->parent; 
    304304    type = type->semantic(loc, sc); 
    305305#if STRUCTTHISREF 
    306306    handle = type; 
    307307#else 
    308308    handle = type->pointerTo(); 
    309309#endif 
    310310    structalign = sc->structalign; 
    311311    protection = sc->protection; 
    312312    storage_class |= sc->stc; 
    313313    if (sc->stc & STCdeprecated) 
    314314        isdeprecated = 1; 
    315315    assert(!isAnonymous()); 
    316316    if (sc->stc & STCabstract) 
    317317        error("structs, unions cannot be abstract"); 
    318318#if DMDV2 
    319319    if (storage_class & STCimmutable) 
    320         type = type->invariantOf(); 
    321     else if (storage_class & STCconst) 
    322         type = type->constOf(); 
    323     else if (storage_class & STCshared) 
    324         type = type->sharedOf(); 
     320        type = type->addMod(MODimmutable); 
     321    if (storage_class & STCconst) 
     322        type = type->addMod(MODconst); 
     323    if (storage_class & STCshared) 
     324        type = type->addMod(MODshared); 
    325325#endif 
    326326 
    327327    if (sizeok == 0)            // if not already done the addMember step 
    328328    { 
    329329        int hasfunctions = 0; 
    330330        for (int i = 0; i < members->dim; i++) 
    331331        { 
    332332            Dsymbol *s = (Dsymbol *)members->data[i]; 
    333333            //printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars()); 
    334334            s->addMember(sc, this, 1); 
    335335            if (s->isFuncDeclaration()) 
    336336                hasfunctions = 1; 
    337337        } 
    338338 
    339339        // If nested struct, add in hidden 'this' pointer to outer scope 
    340340        if (hasfunctions && !(storage_class & STCstatic)) 
    341341        {   Dsymbol *s = toParent2(); 
    342342            if (s) 
    343343            { 
    344344                AggregateDeclaration *ad = s->isAggregateDeclaration();