Mercurial > projects > ldc
diff dmd/attrib.c @ 737:041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Changed the way struct/class fields are added, first small part of cleaning up these...
Make struct/class/union fields aware of any anonymous struct/union they might be part of, not yet really useful, but part of getting better union support.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 28 Oct 2008 15:41:09 +0100 |
parents | 55f6c2e454d7 |
children | 661384d6a936 |
line wrap: on
line diff
--- a/dmd/attrib.c Mon Oct 27 17:42:38 2008 +0100 +++ b/dmd/attrib.c Tue Oct 28 15:41:09 2008 +0100 @@ -501,9 +501,6 @@ { 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 @@ 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 @@ //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); }