diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2005-11-21 22:06:43 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-22 08:43:02 -0800 |
| commit | ea92e467f57dc19726c7f63d22932e2e961bac50 (patch) | |
| tree | ccc2e9ba91eee7b45f65ff0b1c55bddf2b19c32f | |
| parent | a046c1b92025c46a84a89c2d40ba2da3be12893c (diff) | |
| download | sparse-dev-ea92e467f57dc19726c7f63d22932e2e961bac50.tar.gz | |
[PATCH] fix of compound literals on inlining
We need to create a copy of cast_type when we are copying a combination
of EXPR_CAST and EXPR_INITIALIZER (i.e. a compound literal).
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
| -rw-r--r-- | inline.c | 9 | ||||
| -rw-r--r-- | validation/inline_compound_literals.c | 18 |
2 files changed, 27 insertions, 0 deletions
@@ -135,6 +135,15 @@ static struct expression * copy_expression(struct expression *expr) /* Cast/sizeof/__alignof__ */ case EXPR_CAST: + if (expr->cast_expression->type == EXPR_INITIALIZER) { + struct expression *cast = expr->cast_expression; + struct symbol *sym = expr->cast_type; + expr = dup_expression(expr); + expr->cast_expression = copy_expression(cast); + expr->cast_type = alloc_symbol(sym->pos, sym->type); + *expr->cast_type = *sym; + break; + } case EXPR_IMPLIED_CAST: case EXPR_SIZEOF: case EXPR_PTRSIZEOF: diff --git a/validation/inline_compound_literals.c b/validation/inline_compound_literals.c new file mode 100644 index 00000000..649d42ab --- /dev/null +++ b/validation/inline_compound_literals.c @@ -0,0 +1,18 @@ +struct foo { + int x; +}; + +static inline void baz(void) +{ + (struct foo) { .x = 0 }; +} + +static void barf(void) +{ + baz(); +} + +static void foo(void) +{ + baz(); +} |
