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

Changeset 371

Show
Ignore:
Timestamp:
02/06/10 03:53:22 (15 years ago)
Author:
walter
Message:

bugzilla 3450 incorrect result for is (typeof({ ... }())) inside a struct

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dmd-1.x/src/func.c

    r366 r371  
    715715    sc2->parent = this; 
    716716    sc2->callSuper = 0; 
    717717    sc2->sbreak = NULL; 
    718718    sc2->scontinue = NULL; 
    719719    sc2->sw = NULL; 
    720720    sc2->fes = fes; 
    721721    sc2->linkage = LINKd; 
    722722    sc2->stc &= ~(STCauto | STCscope | STCstatic | STCabstract | STCdeprecated | STCfinal); 
    723723    sc2->protection = PROTpublic; 
    724724    sc2->explicitProtection = 0; 
    725725    sc2->structalign = 8; 
    726726    sc2->incontract = 0; 
    727727    sc2->tf = NULL; 
    728728    sc2->noctor = 0; 
    729729 
    730730    // Declare 'this' 
    731731    AggregateDeclaration *ad = isThis(); 
    732732    if (ad) 
    733733    {   VarDeclaration *v; 
    734734 
    735         if (isFuncLiteralDeclaration() && isNested()
     735        if (isFuncLiteralDeclaration() && isNested() && !sc->intypeof
    736736        { 
    737         error("literals cannot be class members"); 
     737        error("function literals cannot be class members"); 
    738738        return; 
    739739        } 
    740740        else 
    741741        { 
    742         assert(!isNested());  // can't be both member and nested 
     742        assert(!isNested() || sc->intypeof);  // can't be both member and nested 
    743743        assert(ad->handle); 
    744744        v = new ThisDeclaration(loc, ad->handle); 
    745745        v->storage_class |= STCparameter | STCin; 
    746746        v->semantic(sc2); 
    747747        if (!sc2->insert(v)) 
    748748            assert(0); 
    749749        v->parent = this; 
    750750        vthis = v; 
    751751        } 
    752752    } 
    753753    else if (isNested()) 
    754754    { 
    755755        /* The 'this' for a nested function is the link to the 
    756756         * enclosing function's stack frame. 
    757757         * Note that nested functions and member functions are disjoint. 
    758758         */ 
    759759        VarDeclaration *v = new ThisDeclaration(loc, Type::tvoid->pointerTo()); 
    760760        v->storage_class |= STCparameter | STCin; 
    761761        v->semantic(sc2); 
    762762        if (!sc2->insert(v)) 
  • trunk/src/func.c

    r366 r371  
    824824    sc2->sbreak = NULL; 
    825825    sc2->scontinue = NULL; 
    826826    sc2->sw = NULL; 
    827827    sc2->fes = fes; 
    828828    sc2->linkage = LINKd; 
    829829    sc2->stc &= ~(STCauto | STCscope | STCstatic | STCabstract | STCdeprecated | 
    830830            STC_TYPECTOR | STCfinal | STCtls | STCgshared | STCref | 
    831831            STCproperty | STCsafe | STCtrusted | STCsystem); 
    832832    sc2->protection = PROTpublic; 
    833833    sc2->explicitProtection = 0; 
    834834    sc2->structalign = 8; 
    835835    sc2->incontract = 0; 
    836836    sc2->tf = NULL; 
    837837    sc2->noctor = 0; 
    838838 
    839839    // Declare 'this' 
    840840    AggregateDeclaration *ad = isThis(); 
    841841    if (ad) 
    842842    {   VarDeclaration *v; 
    843843 
    844         if (isFuncLiteralDeclaration() && isNested()
     844        if (isFuncLiteralDeclaration() && isNested() && !sc->intypeof
    845845        { 
    846         error("literals cannot be class members"); 
     846        error("function literals cannot be class members"); 
    847847        return; 
    848848        } 
    849849        else 
    850850        { 
    851         assert(!isNested());  // can't be both member and nested 
     851        assert(!isNested() || sc->intypeof);  // can't be both member and nested 
    852852        assert(ad->handle); 
    853853        Type *thandle = ad->handle; 
    854854#if STRUCTTHISREF 
    855855        thandle = thandle->addMod(type->mod); 
    856856        thandle = thandle->addStorageClass(storage_class); 
    857857        if (isPure()) 
    858858            thandle = thandle->addMod(MODconst); 
    859859#else 
    860860        if (storage_class & STCconst || type->isConst()) 
    861861        { 
    862862            assert(0); // BUG: shared not handled 
    863863            if (thandle->ty == Tclass) 
    864864            thandle = thandle->constOf(); 
    865865            else 
    866866            {   assert(thandle->ty == Tpointer); 
    867867            thandle = thandle->nextOf()->constOf()->pointerTo(); 
    868868            } 
    869869        } 
    870870        else if (storage_class & STCimmutable || type->isImmutable()) 
    871871        {