diff options
author | Andrew Pinski <pinskia@physics.uc.edu> | 2005-08-17 01:55:05 +0000 |
---|---|---|
committer | Andrew Pinski <pinskia@physics.uc.edu> | 2005-08-17 01:55:05 +0000 |
commit | 06fca3a0cddf3d19b9907727b71e54c8e7627ec5 (patch) | |
tree | d00c8bb96337b5b35ec229a136bbb9fbfed3ba57 /gcc/gimplify.c | |
parent | 8da79687d685a4500b61fddc14f6092f8f7cc0be (diff) |
2005-08-16 Andrew Pinski <pinskia@physics.uc.edu>
PR tree-opt/23402
* gcc.c-torture/compile/zero-strct-3.c: New test.
* gcc.c-torture/compile/zero-strct-4.c: New test.
2005-08-16 Andrew Pinski <pinskia@physics.uc.edu>
PR tree-opt/23402
* gimplify.c (zero_sized_type): New function.
(gimplify_modify_expr_rhs): If we have a zero sized type,
replace the statement with an empty statement.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@103191 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 41ca3b3bbb2..a4ff3d23a2c 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2533,6 +2533,17 @@ zero_sized_field_decl (tree fdecl) return false; } +/* Return true if TYPE is zero sized. */ + +static bool +zero_sized_type (tree type) +{ + if (AGGREGATE_TYPE_P (type) && TYPE_SIZE (type) + && integer_zerop (TYPE_SIZE (type))) + return true; + return false; +} + /* A subroutine of gimplify_init_constructor. Generate individual MODIFY_EXPRs for a CONSTRUCTOR. OBJECT is the LHS against which the assignments should happen. ELTS is the CONSTRUCTOR_ELTS of the @@ -2949,6 +2960,12 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, tree *pre_p, tree *post_p, bool want_value) { enum gimplify_status ret = GS_OK; + tree type = TREE_TYPE (*from_p); + if (zero_sized_type (type)) + { + *expr_p = NULL_TREE; + return GS_ALL_DONE; + } while (ret != GS_UNHANDLED) switch (TREE_CODE (*from_p)) |