summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2011-03-24 12:44:58 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2011-03-24 12:44:58 +0000
commit1688dd20f8f0355b3748d31e11274c5239d7a853 (patch)
treefaced84a3cdaada552e2cec1d6c500866d64c6b6
parent284cc4806917b7677ea5e0780a3dbaddadff325a (diff)
downloadgcc-1688dd20f8f0355b3748d31e11274c5239d7a853.tar.gz
2011-03-24 Richard Guenther <rguenther@suse.de>
PR middle-end/48269 * tree-object-size.c (addr_object_size): Do not double-account for MEM_REF offsets. * gcc.dg/builtin-object-size-10.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171388 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/builtin-object-size-10.c26
-rw-r--r--gcc/tree-object-size.c2
4 files changed, 37 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index feace5129f0..8e361612595 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2011-03-24 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/48269
+ * tree-object-size.c (addr_object_size): Do not double-account
+ for MEM_REF offsets.
+
2011-03-24 Diego Novillo <dnovillo@google.com>
* lto-opts.c (input_data_block): Move to lto-streamer-in.c.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8bda6a47eec..0d331be99f7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2011-03-24 Richard Guenther <rguenther@suse.de>
+ PR middle-end/48269
+ * gcc.dg/builtin-object-size-10.c: New testcase.
+
+2011-03-24 Richard Guenther <rguenther@suse.de>
+
PR tree-optimization/46562
* c-c++-common/pr46562-2.c: New testcase.
* c-c++-common/pr46562.c: Likewise.
diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-10.c b/gcc/testsuite/gcc.dg/builtin-object-size-10.c
new file mode 100644
index 00000000000..6c7ed45b6e0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtin-object-size-10.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-objsz-details" } */
+
+typedef struct {
+ char sentinel[4];
+ char data[0];
+} drone_packet;
+typedef struct {
+ char type_str[16];
+ char channel_hop;
+} drone_source_packet;
+drone_packet *
+foo(char *x)
+{
+ drone_packet *dpkt = __builtin_malloc(sizeof(drone_packet)
+ + sizeof(drone_source_packet));
+ drone_source_packet *spkt = (drone_source_packet *) dpkt->data;
+ __builtin___snprintf_chk (spkt->type_str, 16,
+ 1, __builtin_object_size (spkt->type_str, 1),
+ "%s", x);
+ return dpkt;
+}
+
+/* { dg-final { scan-tree-dump "maximum object size 21" "objsz" } } */
+/* { dg-final { scan-tree-dump "maximum subobject size 16" "objsz" } } */
+/* { dg-final { cleanup-tree-dump "objsz" } } */
diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
index 6a74d19edc0..043b445bf2e 100644
--- a/gcc/tree-object-size.c
+++ b/gcc/tree-object-size.c
@@ -348,8 +348,6 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
tree bytes2 = compute_object_offset (TREE_OPERAND (ptr, 0), pt_var);
if (bytes2 != error_mark_node)
{
- bytes2 = size_binop (PLUS_EXPR, bytes2,
- TREE_OPERAND (pt_var, 1));
if (TREE_CODE (bytes2) == INTEGER_CST
&& tree_int_cst_lt (pt_var_size, bytes2))
bytes2 = size_zero_node;