diff options
author | Jason Merrill <jason@redhat.com> | 2007-09-28 18:07:57 +0000 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2007-09-28 18:07:57 +0000 |
commit | b024f211ff1aa7c9a08d9d712f47530b0e1107b7 (patch) | |
tree | c0601f8dd3b95792f0db5c5bd35d56980a712650 /gcc | |
parent | ed2dd6846950586c1e493a62772889997deb52d5 (diff) |
PR c++/10179
* class.c (layout_empty_base): Take rli parameter, update
rli->record_align if empty base has user-specified alignment.
(build_base_field): Pass rli to it.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@128871 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/class.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/align2.C | 14 |
3 files changed, 35 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7d70e13d2d5..44a4d901aa7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2007-09-28 Jason Merrill <jason@redhat.com> + + PR c++/10179 + * class.c (layout_empty_base): Take rli parameter, update + rli->record_align if empty base has user-specified alignment. + (build_base_field): Pass rli to it. + 2007-09-28 Paolo Carlini <pcarlini@suse.de> PR c++/33213 @@ -26,6 +33,7 @@ 2007-09-27 Jason Merrill <jason@redhat.com> + PR c++/33571 * decl2.c (is_late_template_attribute): Don't crash on unknown attribute. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 5c3e0548044..4419813b6b6 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -179,7 +179,7 @@ static void initialize_vtable (tree, tree); static void layout_nonempty_base_or_field (record_layout_info, tree, tree, splay_tree); static tree end_of_class (tree, int); -static bool layout_empty_base (tree, tree, splay_tree); +static bool layout_empty_base (record_layout_info, tree, tree, splay_tree); static void accumulate_vtbl_inits (tree, tree, tree, tree, tree); static tree dfs_accumulate_vtbl_inits (tree, tree, tree, tree, tree); @@ -3517,7 +3517,8 @@ empty_base_at_nonzero_offset_p (tree type, type. Return nonzero iff we added it at the end. */ static bool -layout_empty_base (tree binfo, tree eoc, splay_tree offsets) +layout_empty_base (record_layout_info rli, tree binfo, + tree eoc, splay_tree offsets) { tree alignment; tree basetype = BINFO_TYPE (binfo); @@ -3563,6 +3564,15 @@ layout_empty_base (tree binfo, tree eoc, splay_tree offsets) propagate_binfo_offsets (binfo, alignment); } } + + if (CLASSTYPE_USER_ALIGN (basetype)) + { + rli->record_align = MAX (rli->record_align, CLASSTYPE_ALIGN (basetype)); + if (warn_packed) + rli->unpacked_align = MAX (rli->unpacked_align, CLASSTYPE_ALIGN (basetype)); + TYPE_USER_ALIGN (rli->t) = 1; + } + return atend; } @@ -3626,7 +3636,7 @@ build_base_field (record_layout_info rli, tree binfo, byte-aligned. */ eoc = round_up (rli_size_unit_so_far (rli), CLASSTYPE_ALIGN_UNIT (basetype)); - atend = layout_empty_base (binfo, eoc, offsets); + atend = layout_empty_base (rli, binfo, eoc, offsets); /* A nearly-empty class "has no proper base class that is empty, not morally virtual, and at an offset other than zero." */ if (!BINFO_VIRTUAL_P (binfo) && CLASSTYPE_NEARLY_EMPTY_P (t)) diff --git a/gcc/testsuite/g++.dg/ext/align2.C b/gcc/testsuite/g++.dg/ext/align2.C new file mode 100644 index 00000000000..da54bd9386b --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/align2.C @@ -0,0 +1,14 @@ +// PR c++/10179 + +struct __attribute((aligned(__alignof(double)))) A +{ /* empty */ }; + +struct T : public A +{ + char c; +}; + +template<bool> struct StaticAssert; +template<> struct StaticAssert<true> {}; + +StaticAssert<__alignof(T) == __alignof(double)> d; |