+2005-08-08 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/21166
+ * stor-layout.c (finalize_type_size): Undo DECL_PACKED when possible.
+
2005-08-07 James A. Morrison <phython@gcc.gnu.org>
* tree-vrp.c (simplify_div_or_mod_using_range): Use build2.
void
finish_record_layout (record_layout_info rli, int free_p)
{
+ tree field;
+
/* Compute the final size. */
finalize_record_size (rli);
/* Perform any last tweaks to the TYPE_SIZE, etc. */
finalize_type_size (rli->t);
+ /* We might be able to clear DECL_PACKED on any members that happen
+ to be suitably aligned (not forgetting the alignment of the type
+ itself). */
+ for (field = TYPE_FIELDS (rli->t); field; field = TREE_CHAIN (field))
+ if (TREE_CODE (field) == FIELD_DECL && DECL_PACKED (field)
+ && DECL_OFFSET_ALIGN (field) >= TYPE_ALIGN (TREE_TYPE (field))
+ && TYPE_ALIGN (rli->t) >= TYPE_ALIGN (TREE_TYPE (field)))
+ DECL_PACKED (field) = 0;
+
/* Lay out any static members. This is done now because their type
may use the record's type. */
while (rli->pending_statics)
+2005-08-08 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/21166
+ * g++.dg/other/crash-4.C: Adjust
+ * g++/dg/ext/packed9.C: New.
+
2005-08-08 Richard Sandiford <richard@codesourcery.com>
PR middle-end/21964
--- /dev/null
+// Copyright (C) 2005 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 26 Apr 2005 <nathan@codesourcery.com>
+
+// DR21166. unnecessary error on packed char
+
+struct s1 {
+ char c1;
+} __attribute__((packed));
+
+char&
+f(struct s1 *s)
+{
+ return s->c1;
+}
+
+char *
+g(struct s1 *s)
+{
+ return &s->c1;
+}