Split off record layouting

Such struct decl:

  struct S { char a; int i;} __attribute__((packed));

should be accepted and cause S to be five bytes long (i.e.
the packed attribute should matter).  So we can't layout
the members during parsing already.  Split off the offset
and alignment calculation for this.
This commit is contained in:
Michael Matz
2016-10-02 21:37:58 +02:00
parent 5d6a9e797a
commit ddecb0e685
2 changed files with 114 additions and 82 deletions

View File

@ -3539,7 +3539,6 @@ typedef struct __attribute__((__packed__)) {
char a;
short b;
int c;
} Spacked2;
} Spacked2;
Spacked2 spacked2;
/* This doesn't work for now. Requires adjusting field offsets/sizes
@ -3548,14 +3547,11 @@ typedef struct Spacked3_s {
char a;
short b;
int c;
} __attribute__((__packed__)) Spacked3;
} __attribute__((__packed__)) Spacked3;
Spacked3 spacked3;
void attrib_test(void)
{
printf("attr: %d %d %d %d\n", sizeof(struct Spacked),
printf("attr: %d %d %d %d\n", sizeof(struct Spacked),
#ifdef BROKEN
sizeof(spacked), sizeof(Spacked2), sizeof(spacked2));
printf("attr: %d %d\n", sizeof(Spacked3), sizeof(spacked3));
}