aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
-rw-r--r--expand.c4
-rw-r--r--validation/field-overlap.c12
2 files changed, 14 insertions, 2 deletions
diff --git a/expand.c b/expand.c
index 1539446c..1007014b 100644
--- a/expand.c
+++ b/expand.c
@@ -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}
+};