mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-27 00:53:23 +01:00
Merged DMD commit 2101219b7b3fa5f545af8401dcacd2cb91c8ef08:
bugzilla 5110 Excess attribute propagation of structs and classes
This commit is contained in:
@@ -563,8 +563,7 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
isabstract = 1;
|
||||
|
||||
sc = sc->push(this);
|
||||
sc->stc &= ~(STCfinal | STCauto | STCscope | STCstatic |
|
||||
STCabstract | STCdeprecated);
|
||||
sc->stc &= STCsafe | STCtrusted | STCsystem;
|
||||
sc->parent = this;
|
||||
sc->inunion = 0;
|
||||
|
||||
|
||||
@@ -762,6 +762,10 @@ void VarDeclaration::semantic(Scope *sc)
|
||||
if (storage_class & STCextern && init)
|
||||
error("extern symbols cannot have initializers");
|
||||
|
||||
AggregateDeclaration *ad = isThis();
|
||||
if (ad)
|
||||
storage_class |= ad->storage_class & STC_TYPECTOR;
|
||||
|
||||
/* If auto type inference, do the inference
|
||||
*/
|
||||
int inferred = 0;
|
||||
@@ -1324,6 +1328,27 @@ void VarDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
buf->writenl();
|
||||
}
|
||||
|
||||
AggregateDeclaration *VarDeclaration::isThis()
|
||||
{
|
||||
AggregateDeclaration *ad = NULL;
|
||||
|
||||
if (!(storage_class & (STCstatic | STCextern | STCmanifest | STCtemplateparameter |
|
||||
STCtls | STCgshared | STCctfe)))
|
||||
{
|
||||
if ((storage_class & (STCconst | STCimmutable)) && init)
|
||||
return NULL;
|
||||
|
||||
for (Dsymbol *s = this; s; s = s->parent)
|
||||
{
|
||||
ad = s->isMember();
|
||||
if (ad)
|
||||
break;
|
||||
if (!s->parent || !s->parent->isTemplateMixin()) break;
|
||||
}
|
||||
}
|
||||
return ad;
|
||||
}
|
||||
|
||||
int VarDeclaration::needThis()
|
||||
{
|
||||
//printf("VarDeclaration::needThis(%s, x%x)\n", toChars(), storage_class);
|
||||
|
||||
@@ -304,6 +304,7 @@ struct VarDeclaration : Declaration
|
||||
Type *htype;
|
||||
Initializer *hinit;
|
||||
#endif
|
||||
AggregateDeclaration *isThis();
|
||||
int needThis();
|
||||
int isImportedSymbol();
|
||||
int isDataseg();
|
||||
|
||||
15
dmd/func.c
15
dmd/func.c
@@ -143,6 +143,7 @@ Dsymbol *FuncDeclaration::syntaxCopy(Dsymbol *s)
|
||||
|
||||
void FuncDeclaration::semantic(Scope *sc)
|
||||
{ TypeFunction *f;
|
||||
AggregateDeclaration *ad;
|
||||
StructDeclaration *sd;
|
||||
ClassDeclaration *cd;
|
||||
InterfaceDeclaration *id;
|
||||
@@ -201,7 +202,11 @@ void FuncDeclaration::semantic(Scope *sc)
|
||||
|
||||
linkage = sc->linkage;
|
||||
protection = sc->protection;
|
||||
|
||||
storage_class |= sc->stc;
|
||||
ad = isThis();
|
||||
if (ad)
|
||||
storage_class |= ad->storage_class & (STC_TYPECTOR | STCsynchronized);
|
||||
//printf("function storage_class = x%x\n", storage_class);
|
||||
|
||||
if (ident == Id::ctor && !isCtorDeclaration())
|
||||
@@ -232,11 +237,11 @@ void FuncDeclaration::semantic(Scope *sc)
|
||||
#endif
|
||||
|
||||
#ifdef IN_GCC
|
||||
AggregateDeclaration *ad;
|
||||
|
||||
ad = parent->isAggregateDeclaration();
|
||||
if (ad)
|
||||
ad->methods.push(this);
|
||||
{
|
||||
AggregateDeclaration *ad = parent->isAggregateDeclaration();
|
||||
if (ad)
|
||||
ad->methods.push(this);
|
||||
}
|
||||
#endif
|
||||
sd = parent->isStructDeclaration();
|
||||
if (sd)
|
||||
|
||||
Reference in New Issue
Block a user