diff options
| -rw-r--r-- | expand.c | 4 | ||||
| -rw-r--r-- | validation/field-overlap.c | 12 |
2 files changed, 14 insertions, 2 deletions
@@ -842,8 +842,8 @@ static int expand_pos_expression(struct expression *expr) static unsigned long bit_offset(const struct expression *expr) { unsigned long offset = 0; - if (expr->type == EXPR_POS) { - offset = expr->init_offset << 3; + while (expr->type == EXPR_POS) { + offset += expr->init_offset << 3; expr = expr->init_expr; } if (expr && expr->ctype) diff --git a/validation/field-overlap.c b/validation/field-overlap.c new file mode 100644 index 00000000..8586c7ff --- /dev/null +++ b/validation/field-overlap.c @@ -0,0 +1,12 @@ +struct { + int x; + struct { + int z; + int w; + } y; +} a = { .y.z = 1, .y.w = 2, }; + +struct {int x, y, z;} w[2] = { + {.x = 1, .y = 2, .z = 3}, + {.x = 1, .y = 2, .z = 3} +}; |
