From f82bdab4272a3d1e4981779a27774f4e1613f32f Mon Sep 17 00:00:00 2001 From: rguenth Date: Tue, 1 Feb 2011 09:47:21 +0000 Subject: [PATCH] 2011-02-01 Richard Guenther PR tree-optimization/47541 * tree-ssa-structalias.c (push_fields_onto_fieldstack): Make sure to have a field at offset zero. * g++.dg/torture/pr47541.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169468 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/torture/pr47541.C | 27 ++++++++++++++++++++++++++ gcc/tree-ssa-structalias.c | 13 +++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 gcc/testsuite/g++.dg/torture/pr47541.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 90e4c78c0cff..e5ed1d8ecf2d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-02-01 Richard Guenther + + PR tree-optimization/47541 + * tree-ssa-structalias.c (push_fields_onto_fieldstack): Make + sure to have a field at offset zero. + 2011-01-31 Joseph Myers * config/arc/arc.opt (EB, EL): New Driver options. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 17bb107bfe1a..8164cf4c1982 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-02-01 Richard Guenther + + PR tree-optimization/47541 + * g++.dg/torture/pr47541.C: New testcase. + 2011-01-31 Janus Weil PR fortran/47455 diff --git a/gcc/testsuite/g++.dg/torture/pr47541.C b/gcc/testsuite/g++.dg/torture/pr47541.C new file mode 100644 index 000000000000..350a05192979 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr47541.C @@ -0,0 +1,27 @@ +/* { dg-do run } */ + +struct Dummy {}; +struct RefCount : public Dummy { + ~RefCount(); /* Has to be non-pod. */ + int *a; + int *b; +}; +RefCount::~RefCount(){} +struct Wrapper : public Dummy { RefCount ref; }; +void __attribute__((noinline,noclone)) +Push(Wrapper ptr) +{ + *ptr.ref.b = 0; +} +extern "C" void abort (void); +int main() +{ + int a = 1, b = 1; + Wrapper x; + x.ref.a = &a; + x.ref.b = &b; + Push(x); + if (b != 0) + abort (); + return 0; +} diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index cf1e817f3770..97719ff84738 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -5083,6 +5083,19 @@ push_fields_onto_fieldstack (tree type, VEC(fieldoff_s,heap) **fieldstack, if (!VEC_empty (fieldoff_s, *fieldstack)) pair = VEC_last (fieldoff_s, *fieldstack); + /* If there isn't anything at offset zero, create sth. */ + if (!pair + && offset + foff != 0) + { + pair = VEC_safe_push (fieldoff_s, heap, *fieldstack, NULL); + pair->offset = 0; + pair->size = offset + foff; + pair->has_unknown_size = false; + pair->must_have_pointers = false; + pair->may_have_pointers = false; + pair->only_restrict_pointers = false; + } + if (!DECL_SIZE (field) || !host_integerp (DECL_SIZE (field), 1)) has_unknown_size = true; -- 2.47.2