mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-28 17:43:14 +01:00
Automated merge with http://hg.dsource.org/projects/ldc
This commit is contained in:
28
dmd/attrib.c
28
dmd/attrib.c
@@ -501,9 +501,6 @@ AlignDeclaration::AlignDeclaration(Loc loc, unsigned sa, Array *decl)
|
||||
{
|
||||
this->loc = loc;
|
||||
salign = sa;
|
||||
|
||||
if (global.params.warnings && salign != 1)
|
||||
warning("%s: align(%d) is not implemented and specified to be unportable anyway, use align(1) and manual fillers instead", loc.toChars(), salign);
|
||||
}
|
||||
|
||||
Dsymbol *AlignDeclaration::syntaxCopy(Dsymbol *s)
|
||||
@@ -517,21 +514,33 @@ Dsymbol *AlignDeclaration::syntaxCopy(Dsymbol *s)
|
||||
|
||||
void AlignDeclaration::semantic(Scope *sc)
|
||||
{
|
||||
// LDC
|
||||
// we only support packed structs, as from the spec: align(1) struct Packed { ... }
|
||||
// other alignments are simply ignored. my tests show this is what llvm-gcc does too ...
|
||||
|
||||
//printf("\tAlignDeclaration::semantic '%s'\n",toChars());
|
||||
if (decl)
|
||||
{ unsigned salign_save = sc->structalign;
|
||||
|
||||
sc->structalign = salign;
|
||||
for (unsigned i = 0; i < decl->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)decl->data[i];
|
||||
|
||||
s->semantic(sc);
|
||||
if (s->isStructDeclaration() && salign == 1)
|
||||
{
|
||||
sc->structalign = salign;
|
||||
s->semantic(sc);
|
||||
sc->structalign = salign_save;
|
||||
}
|
||||
else
|
||||
{
|
||||
s->semantic(sc);
|
||||
}
|
||||
}
|
||||
sc->structalign = salign_save;
|
||||
}
|
||||
else
|
||||
sc->structalign = salign;
|
||||
assert(0 && "what kind of align use triggers this?");
|
||||
}
|
||||
|
||||
|
||||
@@ -658,12 +667,17 @@ void AnonDeclaration::semantic(Scope *sc)
|
||||
//printf("sc->offset = %d\n", sc->offset);
|
||||
|
||||
// Add members of aad to ad
|
||||
//printf("\tadding members of aad to '%s'\n", ad->toChars());
|
||||
//printf("\tadding members of aad (%p) to '%s'\n", &aad, ad->toChars());
|
||||
for (unsigned i = 0; i < aad.fields.dim; i++)
|
||||
{
|
||||
VarDeclaration *v = (VarDeclaration *)aad.fields.data[i];
|
||||
|
||||
v->offset += sc->offset;
|
||||
|
||||
// LDC
|
||||
if (!v->anonDecl)
|
||||
v->anonDecl = this;
|
||||
|
||||
ad->fields.push(v);
|
||||
}
|
||||
|
||||
|
||||
@@ -621,6 +621,9 @@ VarDeclaration::VarDeclaration(Loc loc, Type *type, Identifier *id, Initializer
|
||||
onstack = 0;
|
||||
canassign = 0;
|
||||
value = NULL;
|
||||
|
||||
// LDC
|
||||
anonDecl = NULL;
|
||||
}
|
||||
|
||||
Dsymbol *VarDeclaration::syntaxCopy(Dsymbol *s)
|
||||
|
||||
@@ -37,6 +37,7 @@ struct StructDeclaration;
|
||||
struct TupleType;
|
||||
struct InterState;
|
||||
struct IRState;
|
||||
struct AnonDeclaration;
|
||||
|
||||
enum PROT;
|
||||
enum LINK;
|
||||
@@ -269,6 +270,9 @@ struct VarDeclaration : Declaration
|
||||
|
||||
// Eliminate need for dynamic_cast
|
||||
VarDeclaration *isVarDeclaration() { return (VarDeclaration *)this; }
|
||||
|
||||
// LDC
|
||||
AnonDeclaration* anonDecl;
|
||||
};
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
@@ -349,6 +349,9 @@ Array *Parser::parseDeclDefs(int once)
|
||||
case TOKalign:
|
||||
{ unsigned n;
|
||||
|
||||
// LDC better align code locations
|
||||
Loc alignloc = loc;
|
||||
|
||||
s = NULL;
|
||||
nextToken();
|
||||
if (token.value == TOKlparen)
|
||||
@@ -367,7 +370,7 @@ Array *Parser::parseDeclDefs(int once)
|
||||
n = global.structalign; // default
|
||||
|
||||
a = parseBlock();
|
||||
s = new AlignDeclaration(loc, n, a);
|
||||
s = new AlignDeclaration(alignloc, n, a);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ struct AnonymousAggregateDeclaration;
|
||||
struct FuncDeclaration;
|
||||
struct DocComment;
|
||||
struct EnclosingHandler;
|
||||
struct AnonDeclaration;
|
||||
enum LINK;
|
||||
enum PROT;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user