aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-01-02 14:03:04 -0500
committerJason Merrill <jason@gcc.gnu.org>2013-01-02 14:03:04 -0500
commite78167f298583c1770b2889cc49a2b31dd42c137 (patch)
tree9a488488943c24223d38fd70d5904cca475fa417 /gcc/cp
parentcc1863452c2ebf3696ac7247aa9e4ae9db633c49 (diff)
downloadgcc-e78167f298583c1770b2889cc49a2b31dd42c137.zip
gcc-e78167f298583c1770b2889cc49a2b31dd42c137.tar.gz
gcc-e78167f298583c1770b2889cc49a2b31dd42c137.tar.bz2
re PR c++/55804 (GCC omits required call to constructor)
PR c++/55804 PR c++/55032 PR c++/55245 * tree.c (build_array_type_1): Revert earlier change. * cp/tree.c (build_cplus_array_type): Copy layout information to main variant if necessary. From-SVN: r194811
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/tree.c36
2 files changed, 37 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a57051e..6264556 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2013-01-02 Jason Merrill <jason@redhat.com>
+
+ PR c++/55032
+ PR c++/55245
+ * tree.c (build_cplus_array_type): Copy layout information
+ to main variant if necessary.
+
2012-12-28 Kai Tietz <ktietz@redhat.com>
* rtti.c (LONGPTR_T): New helper-macro.
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index c430237..c658582 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -809,6 +809,15 @@ build_cplus_array_type (tree elt_type, tree index_type)
t = build_array_type (elt_type, index_type);
}
+ /* Push these needs up so that initialization takes place
+ more easily. */
+ bool needs_ctor
+ = TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (elt_type));
+ TYPE_NEEDS_CONSTRUCTING (t) = needs_ctor;
+ bool needs_dtor
+ = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TYPE_MAIN_VARIANT (elt_type));
+ TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) = needs_dtor;
+
/* We want TYPE_MAIN_VARIANT of an array to strip cv-quals from the
element type as well, so fix it up if needed. */
if (elt_type != TYPE_MAIN_VARIANT (elt_type))
@@ -818,6 +827,27 @@ build_cplus_array_type (tree elt_type, tree index_type)
if (TYPE_MAIN_VARIANT (t) != m)
{
+ if (COMPLETE_TYPE_P (t) && !COMPLETE_TYPE_P (m))
+ {
+ /* m was built before the element type was complete, so we
+ also need to copy the layout info from t. */
+ tree size = TYPE_SIZE (t);
+ tree size_unit = TYPE_SIZE_UNIT (t);
+ unsigned int align = TYPE_ALIGN (t);
+ unsigned int user_align = TYPE_USER_ALIGN (t);
+ enum machine_mode mode = TYPE_MODE (t);
+ for (tree var = m; var; var = TYPE_NEXT_VARIANT (var))
+ {
+ TYPE_SIZE (var) = size;
+ TYPE_SIZE_UNIT (var) = size_unit;
+ TYPE_ALIGN (var) = align;
+ TYPE_USER_ALIGN (var) = user_align;
+ SET_TYPE_MODE (var, mode);
+ TYPE_NEEDS_CONSTRUCTING (var) = needs_ctor;
+ TYPE_HAS_NONTRIVIAL_DESTRUCTOR (var) = needs_dtor;
+ }
+ }
+
TYPE_MAIN_VARIANT (t) = m;
TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
TYPE_NEXT_VARIANT (m) = t;
@@ -828,12 +858,6 @@ build_cplus_array_type (tree elt_type, tree index_type)
if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
TREE_NO_WARNING (TYPE_SIZE (t)) = 1;
- /* Push these needs up so that initialization takes place
- more easily. */
- TYPE_NEEDS_CONSTRUCTING (t)
- = TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (elt_type));
- TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)
- = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TYPE_MAIN_VARIANT (elt_type));
return t;
}