diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2006-09-30 09:15:45 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2006-09-30 13:45:33 -0400 |
| commit | 02a7055f72840f05dbf7530b2c82af46306ec0c2 (patch) | |
| tree | 746b6abb0f2e1d38085840c7004c36b060025b20 | |
| parent | 304b6f7746b700fd1c553b3552b51d7d97bee206 (diff) | |
| download | sparse-dev-02a7055f72840f05dbf7530b2c82af46306ec0c2.tar.gz | |
[PATCH] fix duplicate initializer detection
bit_offset() doesn't deal with nested designators.
Fixed, testcase added.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| -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} +}; |
