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

Changeset 378

Show
Ignore:
Timestamp:
02/12/10 06:54:07 (15 years ago)
Author:
walter
Message:

bugzilla 3775 Segfault(cast.c): casting no-parameter template function using property syntax

Files:

Legend:

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

    r375 r378  
    77417741        return e; 
    77427742    } 
    77437743 
    77447744    // Struct casts are possible only when the sizes match 
    77457745    if (tob->ty == Tstruct || t1b->ty == Tstruct) 
    77467746    { 
    77477747        size_t fromsize = t1b->size(loc); 
    77487748        size_t tosize = tob->size(loc); 
    77497749        if (fromsize != tosize) 
    77507750        { 
    77517751        error("cannot cast from %s to %s", e1->type->toChars(), to->toChars()); 
    77527752        return new ErrorExp(); 
    77537753        } 
    77547754    } 
    77557755    } 
    77567756    else if (!to) 
    77577757    {   error("cannot cast tuple"); 
    77587758    to = Type::terror; 
    77597759    } 
    77607760 
     7761    if (!e1->type) 
     7762    {   error("cannot cast %s", e1->toChars()); 
     7763    return new ErrorExp(); 
     7764    } 
     7765 
    77617766#if 1 
    77627767    if (sc->func && sc->func->isSafe() && !sc->intypeof) 
    77637768#else 
    77647769    if (global.params.safe && !sc->module->safe && !sc->intypeof) 
    77657770#endif 
    77667771    {   // Disallow unsafe casts 
    77677772    Type *tob = to->toBasetype(); 
    77687773    Type *t1b = e1->type->toBasetype(); 
    77697774    if (!t1b->isMutable() && tob->isMutable()) 
    77707775    {   // Cast not mutable to mutable 
    77717776      Lunsafe: 
    77727777        error("cast from %s to %s not allowed in safe code", e1->type->toChars(), to->toChars()); 
    77737778    } 
    77747779    else if (t1b->isShared() && !tob->isShared()) 
    77757780        // Cast away shared 
    77767781        goto Lunsafe; 
    77777782    else if (tob->ty == Tpointer) 
    77787783    {   if (t1b->ty != Tpointer) 
    77797784        goto Lunsafe; 
    77807785        Type *tobn = tob->nextOf()->toBasetype();