Skip to content

Commit

Permalink
Issue 6360 - @Property is doubled in di files when used with auto
Browse files Browse the repository at this point in the history
Reduce redundant storage classes between FuncDeclaration::storage_class and FuncDeclaration::type
  • Loading branch information
9rnsr committed Sep 22, 2011
1 parent 0f1af1b commit a1566e3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/declaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ enum PURE;
// but not typed as "shared"
#define STCwild 0x80000000LL // for "wild" type constructor
#define STC_TYPECTOR (STCconst | STCimmutable | STCshared | STCwild)
#define STC_FUNCATTR (STCref | STCnothrow | STCpure | STCproperty | STCsafe | STCtrusted | STCsystem)

#define STCproperty 0x100000000LL
#define STCsafe 0x200000000LL
Expand Down
26 changes: 11 additions & 15 deletions src/func.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ FuncDeclaration::FuncDeclaration(Loc loc, Loc endloc, Identifier *id, StorageCla
//printf("storage_class = x%x\n", storage_class);
this->storage_class = storage_class;
this->type = type;
if (type)
this->storage_class &= ~(STC_TYPECTOR | STC_FUNCATTR);
this->loc = loc;
this->endloc = endloc;
fthrows = NULL;
Expand Down Expand Up @@ -3059,10 +3061,10 @@ void CtorDeclaration::semantic(Scope *sc)
//printf("CtorDeclaration::semantic() %s\n", toChars());
TypeFunction *tf = (TypeFunction *)type;
assert(tf && tf->ty == Tfunction);
Expressions *fargs = ((TypeFunction *)type)->fargs; // for auto ref

sc = sc->push();
sc->stc &= ~STCstatic; // not a static constructor
sc->flags |= SCOPEctor;

parent = sc->parent;
Dsymbol *parent = toParent2();
Expand All @@ -3077,17 +3079,16 @@ void CtorDeclaration::semantic(Scope *sc)
{ tret = ad->handle;
assert(tret);
tret = tret->addStorageClass(storage_class | sc->stc);
tret = tret->addMod(type->mod);
}
tf = new TypeFunction(tf->parameters, tret, tf->varargs, LINKd, storage_class | sc->stc);
tf->fargs = fargs;
type = tf;
tf->next = tret;
type = type->semantic(loc, sc);

#if STRUCTTHISREF
if (ad && ad->isStructDeclaration())
{ ((TypeFunction *)type)->isref = 1;
if (!originalType)
// Leave off the "ref"
originalType = new TypeFunction(tf->parameters, tret, tf->varargs, LINKd, storage_class | sc->stc);
{ if (!originalType)
originalType = type->syntaxCopy();
((TypeFunction *)type)->isref = 1;
}
#endif
if (!originalType)
Expand Down Expand Up @@ -3155,13 +3156,8 @@ int CtorDeclaration::addPostInvariant()

void CtorDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
{
TypeFunction *tf = (TypeFunction *)type;
assert(tf && tf->ty == Tfunction);

if (originalType && originalType->ty == Tfunction)
((TypeFunction *)originalType)->attributesToCBuffer(buf, 0);
buf->writestring("this");
Parameter::argsToCBuffer(buf, hgs, tf->parameters, tf->varargs);
StorageClassDeclaration::stcToCBuffer(buf, storage_class);
type->toCBuffer(buf, Id::This, hgs); // ident == Id::this
bodyToCBuffer(buf, hgs);
}

Expand Down
3 changes: 3 additions & 0 deletions src/mtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -4454,6 +4454,9 @@ TypeFunction::TypeFunction(Parameters *parameters, Type *treturn, int varargs, e
if (stc & STCproperty)
this->isproperty = true;

if (stc & STCref)
this->isref = true;

this->trust = TRUSTdefault;
if (stc & STCsafe)
this->trust = TRUSTsafe;
Expand Down
13 changes: 13 additions & 0 deletions test/compilable/extra-files/header.di
Original file line number Diff line number Diff line change
Expand Up @@ -384,3 +384,16 @@ return 0;
);
}
}
struct S6360
{
@property const pure nothrow long weeks1()
{
return 0;
}

const nothrow pure @property long weeks2()
{
return 0;
}

}
8 changes: 8 additions & 0 deletions test/compilable/header.d
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,11 @@ int bar11(T)()
}


struct S6360
{
@property long weeks1() const pure nothrow { return 0; }

@property const pure nothrow long weeks2() { return 0; }
}


0 comments on commit a1566e3

Please sign in to comment.