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:
@@ -3539,7 +3539,6 @@ typedef struct __attribute__((__packed__)) {
|
||||
int c;
|
||||
} Spacked2;
|
||||
Spacked2 spacked2;
|
||||
#ifdef BROKEN
|
||||
/* This doesn't work for now. Requires adjusting field offsets/sizes
|
||||
after parsing the struct members. */
|
||||
typedef struct Spacked3_s {
|
||||
@@ -3548,14 +3547,11 @@ typedef struct Spacked3_s {
|
||||
int c;
|
||||
} __attribute__((__packed__)) Spacked3;
|
||||
Spacked3 spacked3;
|
||||
#endif
|
||||
void attrib_test(void)
|
||||
{
|
||||
printf("attr: %d %d %d %d\n", sizeof(struct Spacked),
|
||||
sizeof(spacked), sizeof(Spacked2), sizeof(spacked2));
|
||||
#ifdef BROKEN
|
||||
printf("attr: %d %d\n", sizeof(Spacked3), sizeof(spacked3));
|
||||
#endif
|
||||
}
|
||||
extern __attribute__((__unused__)) char * __attribute__((__unused__)) *
|
||||
strange_attrib_placement (void);
|
||||
|
||||
Reference in New Issue
Block a user