diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-07-20 17:39:22 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-07-20 17:39:22 +0000 |
commit | ffbeca59aadc215e559e3dcac8ed918f1844dc8e (patch) | |
tree | 2667a59244c4fe3df2140a60b8878cc03a7811b1 /gcc/tree-object-size.c | |
parent | f6d257e759ae8bd931f07a25a7eda15b25b84c77 (diff) | |
download | gcc-ffbeca59aadc215e559e3dcac8ed918f1844dc8e.tar.gz |
* tree-object-size.c (addr_object_size): Handle unions with
array in it as last field of structs in __bos (, 1) as __bos (, 0).
* gcc.dg/builtin-object-size-6.c: Adjust expected values.
* gcc.dg/builtin-object-size-8.c: New test.
* g++.dg/ext/builtin-object-size1.C: Adjust expected values.
* g++.dg/ext/builtin-object-size2.C: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149825 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-object-size.c')
-rw-r--r-- | gcc/tree-object-size.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c index 5c64b989d5e..5b9fe38e96b 100644 --- a/gcc/tree-object-size.c +++ b/gcc/tree-object-size.c @@ -217,7 +217,7 @@ addr_object_size (struct object_size_info *osi, const_tree ptr, && TREE_CODE (var) != IMAGPART_EXPR) var = TREE_OPERAND (var, 0); if (var != pt_var && TREE_CODE (var) == ARRAY_REF) - var = TREE_OPERAND (var, 0); + var = TREE_OPERAND (var, 0); if (! TYPE_SIZE_UNIT (TREE_TYPE (var)) || ! host_integerp (TYPE_SIZE_UNIT (TREE_TYPE (var)), 1) || (pt_var_size @@ -262,8 +262,17 @@ addr_object_size (struct object_size_info *osi, const_tree ptr, v = NULL_TREE; break; } - if (TREE_CODE (TREE_TYPE (TREE_OPERAND (v, 0))) - == RECORD_TYPE) + while (v != pt_var && TREE_CODE (v) == COMPONENT_REF) + if (TREE_CODE (TREE_TYPE (TREE_OPERAND (v, 0))) + != UNION_TYPE + && TREE_CODE (TREE_TYPE (TREE_OPERAND (v, 0))) + != QUAL_UNION_TYPE) + break; + else + v = TREE_OPERAND (v, 0); + if (TREE_CODE (v) == COMPONENT_REF + && TREE_CODE (TREE_TYPE (TREE_OPERAND (v, 0))) + == RECORD_TYPE) { tree fld_chain = TREE_CHAIN (TREE_OPERAND (v, 1)); for (; fld_chain; fld_chain = TREE_CHAIN (fld_chain)) @@ -275,18 +284,17 @@ addr_object_size (struct object_size_info *osi, const_tree ptr, v = NULL_TREE; break; } + v = TREE_OPERAND (v, 0); } - - if (TREE_CODE (TREE_TYPE (TREE_OPERAND (v, 0))) - == RECORD_TYPE) - v = TREE_OPERAND (v, 0); - while (v && v != pt_var && TREE_CODE (v) == COMPONENT_REF) - if (TREE_CODE (TREE_TYPE (v)) != UNION_TYPE - && TREE_CODE (TREE_TYPE (v)) != QUAL_UNION_TYPE) + while (v != pt_var && TREE_CODE (v) == COMPONENT_REF) + if (TREE_CODE (TREE_TYPE (TREE_OPERAND (v, 0))) + != UNION_TYPE + && TREE_CODE (TREE_TYPE (TREE_OPERAND (v, 0))) + != QUAL_UNION_TYPE) break; else v = TREE_OPERAND (v, 0); - if (v && v != pt_var) + if (v != pt_var) v = NULL_TREE; else v = pt_var; |