Skip to content

Commit 8dcd67a

Browse files
committed
dmd 2.014
1 parent d550a1a commit 8dcd67a

32 files changed

+1272
-263
lines changed

src/aggregate.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,13 @@ struct AnonymousAggregateDeclaration : AggregateDeclaration
107107
struct StructDeclaration : AggregateDeclaration
108108
{
109109
int zeroInit; // !=0 if initialize with 0 fill
110+
#if V2
110111
int hasIdentityAssign; // !=0 if has identity opAssign
111112
FuncDeclaration *cpctor; // generated copy-constructor, if any
112113

113114
FuncDeclarations postblits; // Array of postblit functions
114115
FuncDeclaration *postblit; // aggregate postblit
116+
#endif
115117

116118
StructDeclaration(Loc loc, Identifier *id);
117119
Dsymbol *syntaxCopy(Dsymbol *s);
@@ -127,7 +129,7 @@ struct StructDeclaration : AggregateDeclaration
127129

128130
PROT getAccess(Dsymbol *smember); // determine access to smember
129131

130-
void toObjFile(); // compile to .obj file
132+
void toObjFile(int multiobj); // compile to .obj file
131133
void toDt(dt_t **pdt);
132134
void toDebug(); // to symbolic debug info
133135

@@ -236,7 +238,7 @@ struct ClassDeclaration : AggregateDeclaration
236238
void addLocalClass(ClassDeclarations *);
237239

238240
// Back end
239-
void toObjFile(); // compile to .obj file
241+
void toObjFile(int multiobj); // compile to .obj file
240242
void toDebug();
241243
unsigned baseVtblOffset(BaseClass *bc);
242244
Symbol *toSymbol();
@@ -266,7 +268,7 @@ struct InterfaceDeclaration : ClassDeclaration
266268
#endif
267269
virtual int isCOMinterface();
268270

269-
void toObjFile(); // compile to .obj file
271+
void toObjFile(int multiobj); // compile to .obj file
270272
Symbol *toSymbol();
271273

272274
InterfaceDeclaration *isInterfaceDeclaration() { return this; }

src/attrib.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ void AttribDeclaration::emitComment(Scope *sc)
176176
}
177177
}
178178

179-
void AttribDeclaration::toObjFile()
179+
void AttribDeclaration::toObjFile(int multiobj)
180180
{
181181
unsigned i;
182182
Array *d = include(NULL, NULL);
@@ -187,7 +187,7 @@ void AttribDeclaration::toObjFile()
187187
{ Dsymbol *s;
188188

189189
s = (Dsymbol *)d->data[i];
190-
s->toObjFile();
190+
s->toObjFile(multiobj);
191191
}
192192
}
193193
}
@@ -917,7 +917,7 @@ char *PragmaDeclaration::kind()
917917
return "pragma";
918918
}
919919

920-
void PragmaDeclaration::toObjFile()
920+
void PragmaDeclaration::toObjFile(int multiobj)
921921
{
922922
if (ident == Id::lib)
923923
{
@@ -943,7 +943,7 @@ void PragmaDeclaration::toObjFile()
943943
Symbol *s = f->toSymbol();
944944
obj_startaddress(s);
945945
}
946-
AttribDeclaration::toObjFile();
946+
AttribDeclaration::toObjFile(multiobj);
947947
}
948948

949949
void PragmaDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)

src/attrib.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct AttribDeclaration : Dsymbol
5050
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
5151
AttribDeclaration *isAttribDeclaration() { return this; }
5252

53-
void toObjFile(); // compile to .obj file
53+
void toObjFile(int multiobj); // compile to .obj file
5454
int cvMember(unsigned char *p);
5555
};
5656

@@ -119,7 +119,7 @@ struct PragmaDeclaration : AttribDeclaration
119119
int oneMember(Dsymbol **ps);
120120
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
121121
char *kind();
122-
void toObjFile(); // compile to .obj file
122+
void toObjFile(int multiobj); // compile to .obj file
123123
};
124124

125125
struct ConditionalDeclaration : AttribDeclaration

src/cast.c

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,31 +1514,52 @@ Expression *BinExp::typeCombine(Scope *sc)
15141514
goto Lagain;
15151515
}
15161516
else if (t1->ty == Tclass || t2->ty == Tclass)
1517-
{ int i1;
1518-
int i2;
1517+
{
1518+
while (1)
1519+
{
1520+
int i1 = e2->implicitConvTo(t1);
1521+
int i2 = e1->implicitConvTo(t2);
15191522

1520-
i1 = e2->implicitConvTo(t1);
1521-
i2 = e1->implicitConvTo(t2);
1523+
if (i1 && i2)
1524+
{
1525+
// We have the case of class vs. void*, so pick class
1526+
if (t1->ty == Tpointer)
1527+
i1 = 0;
1528+
else if (t2->ty == Tpointer)
1529+
i2 = 0;
1530+
}
15221531

1523-
if (i1 && i2)
1524-
{
1525-
// We have the case of class vs. void*, so pick class
1526-
if (t1->ty == Tpointer)
1527-
i1 = 0;
1528-
else if (t2->ty == Tpointer)
1529-
i2 = 0;
1530-
}
1532+
if (i2)
1533+
{
1534+
goto Lt2;
1535+
}
1536+
else if (i1)
1537+
{
1538+
goto Lt1;
1539+
}
1540+
else if (t1->ty == Tclass && t2->ty == Tclass)
1541+
{ TypeClass *tc1 = (TypeClass *)t1;
1542+
TypeClass *tc2 = (TypeClass *)t2;
15311543

1532-
if (i2)
1533-
{
1534-
goto Lt2;
1535-
}
1536-
else if (i1)
1537-
{
1538-
goto Lt1;
1544+
/* Pick 'tightest' type
1545+
*/
1546+
ClassDeclaration *cd1 = tc1->sym->baseClass;
1547+
ClassDeclaration *cd2 = tc1->sym->baseClass;
1548+
1549+
if (cd1 && cd2)
1550+
{ t1 = cd1->type;
1551+
t2 = cd2->type;
1552+
}
1553+
else if (cd1)
1554+
t1 = cd1->type;
1555+
else if (cd2)
1556+
t2 = cd2->type;
1557+
else
1558+
goto Lincompatible;
1559+
}
1560+
else
1561+
goto Lincompatible;
15391562
}
1540-
else
1541-
goto Lincompatible;
15421563
}
15431564
else if (t1->ty == Tstruct && t2->ty == Tstruct)
15441565
{

src/declaration.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -947,10 +947,6 @@ void VarDeclaration::semantic(Scope *sc)
947947
if (fd && !isStatic() && !(storage_class & STCmanifest) &&
948948
!init->isVoidInitializer())
949949
{
950-
Expression *e1;
951-
Type *t;
952-
int dim;
953-
954950
//printf("fd = '%s', var = '%s'\n", fd->toChars(), toChars());
955951
if (!ei)
956952
{
@@ -968,15 +964,15 @@ void VarDeclaration::semantic(Scope *sc)
968964
init = ei;
969965
}
970966

971-
e1 = new VarExp(loc, this);
967+
Expression *e1 = new VarExp(loc, this);
972968

973-
t = type->toBasetype();
969+
Type *t = type->toBasetype();
974970
if (t->ty == Tsarray)
975971
{
976972
ei->exp = ei->exp->semantic(sc);
977973
if (!ei->exp->implicitConvTo(type))
978974
{
979-
dim = ((TypeSArray *)t)->dim->toInteger();
975+
int dim = ((TypeSArray *)t)->dim->toInteger();
980976
// If multidimensional static array, treat as one large array
981977
while (1)
982978
{
@@ -993,7 +989,11 @@ void VarDeclaration::semantic(Scope *sc)
993989
{
994990
ei->exp = ei->exp->semantic(sc);
995991
if (!ei->exp->implicitConvTo(type))
996-
ei->exp = new CastExp(loc, ei->exp, type);
992+
{ Type *ti = ei->exp->type->toBasetype();
993+
// Don't cast away invariant or mutability in initializer
994+
if (!(ti->ty == Tstruct && t->toDsymbol(sc) == ti->toDsymbol(sc)))
995+
ei->exp = new CastExp(loc, ei->exp, type);
996+
}
997997
}
998998
ei->exp = new AssignExp(loc, e1, ei->exp);
999999
ei->exp->op = op;

src/declaration.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ struct TypedefDeclaration : Declaration
178178

179179
void toDocBuffer(OutBuffer *buf);
180180

181-
void toObjFile(); // compile to .obj file
181+
void toObjFile(int multiobj); // compile to .obj file
182182
void toDebug();
183183
int cvMember(unsigned char *p);
184184

@@ -257,7 +257,7 @@ struct VarDeclaration : Declaration
257257
Dsymbol *toAlias();
258258

259259
Symbol *toSymbol();
260-
void toObjFile(); // compile to .obj file
260+
void toObjFile(int multiobj); // compile to .obj file
261261
int cvMember(unsigned char *p);
262262

263263
// Eliminate need for dynamic_cast
@@ -319,7 +319,7 @@ struct TypeInfoDeclaration : VarDeclaration
319319
void emitComment(Scope *sc);
320320

321321
Symbol *toSymbol();
322-
void toObjFile(); // compile to .obj file
322+
void toObjFile(int multiobj); // compile to .obj file
323323
virtual void toDt(dt_t **pdt);
324324
};
325325

@@ -568,7 +568,7 @@ struct FuncDeclaration : Declaration
568568

569569
Symbol *toSymbol();
570570
Symbol *toThunkSymbol(int offset); // thunk version
571-
void toObjFile(); // compile to .obj file
571+
void toObjFile(int multiobj); // compile to .obj file
572572
int cvMember(unsigned char *p);
573573
void buildClosure(IRState *irs);
574574

src/dsymbol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ struct Dsymbol : Object
165165
// Backend
166166

167167
virtual Symbol *toSymbol(); // to backend symbol
168-
virtual void toObjFile(); // compile to .obj file
168+
virtual void toObjFile(int multiobj); // compile to .obj file
169169
virtual int cvMember(unsigned char *p); // emit cv debug info for member
170170

171171
Symbol *toImport(); // to backend import symbol

src/e2ir.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ elem *Dsymbol_toElem(Dsymbol *s, IRState *irs)
10541054
if (s != vd)
10551055
return Dsymbol_toElem(s, irs);
10561056
if (vd->isStatic() || vd->storage_class & STCextern)
1057-
vd->toObjFile();
1057+
vd->toObjFile(0);
10581058
else
10591059
{
10601060
sp = s->toSymbol();
@@ -1073,18 +1073,15 @@ elem *Dsymbol_toElem(Dsymbol *s, IRState *irs)
10731073
else if ((cd = s->isClassDeclaration()) != NULL)
10741074
{
10751075
irs->deferToObj->push(s);
1076-
//sd->toObjFile();
10771076
}
10781077
else if ((sd = s->isStructDeclaration()) != NULL)
10791078
{
10801079
irs->deferToObj->push(sd);
1081-
//sd->toObjFile();
10821080
}
10831081
else if ((fd = s->isFuncDeclaration()) != NULL)
10841082
{
10851083
//printf("function %s\n", fd->toChars());
10861084
irs->deferToObj->push(fd);
1087-
//fd->toObjFile();
10881085
}
10891086
else if ((tm = s->isTemplateMixin()) != NULL)
10901087
{

src/enum.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct EnumDeclaration : ScopeDsymbol
5252

5353
EnumDeclaration *isEnumDeclaration() { return this; }
5454

55-
void toObjFile(); // compile to .obj file
55+
void toObjFile(int multiobj); // compile to .obj file
5656
void toDebug();
5757
int cvMember(unsigned char *p);
5858

0 commit comments

Comments
 (0)