X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fstor-layout.c;h=67e4c25fbdc25104e25947f5c3d20a6026baf888;hb=534468ec8c35ec1997d76617a3b711b22ed10730;hp=ea658a86aa0f85147b320c89b3aa95ce56a1ff7f;hpb=06f0b99c264712365d4142ee12ae9e8133b2f4c0;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index ea658a86aa0..67e4c25fbdc 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -388,13 +388,13 @@ layout_decl (tree decl, unsigned int known_align) { enum machine_mode xmode = mode_for_size_tree (DECL_SIZE (decl), MODE_INT, 1); + unsigned int xalign = GET_MODE_ALIGNMENT (xmode); if (xmode != BLKmode - && (known_align == 0 - || known_align >= GET_MODE_ALIGNMENT (xmode))) + && !(xalign > BITS_PER_UNIT && DECL_PACKED (decl)) + && (known_align == 0 || known_align >= xalign)) { - DECL_ALIGN (decl) = MAX (GET_MODE_ALIGNMENT (xmode), - DECL_ALIGN (decl)); + DECL_ALIGN (decl) = MAX (xalign, DECL_ALIGN (decl)); DECL_MODE (decl) = xmode; DECL_BIT_FIELD (decl) = 0; } @@ -414,18 +414,11 @@ layout_decl (tree decl, unsigned int known_align) else do_type_align (type, decl); - /* If the field is of variable size, we can't misalign it since we - have no way to make a temporary to align the result. But this - isn't an issue if the decl is not addressable. Likewise if it - is of unknown size. - - Note that do_type_align may set DECL_USER_ALIGN, so we need to - check old_user_align instead. */ + /* If the field is packed and not explicitly aligned, give it the + minimum alignment. Note that do_type_align may set + DECL_USER_ALIGN, so we need to check old_user_align instead. */ if (packed_p - && !old_user_align - && (DECL_NONADDRESSABLE_P (decl) - || DECL_SIZE_UNIT (decl) == 0 - || TREE_CODE (DECL_SIZE_UNIT (decl)) == INTEGER_CST)) + && !old_user_align) DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), BITS_PER_UNIT); if (! packed_p && ! DECL_USER_ALIGN (decl)) @@ -471,9 +464,9 @@ layout_decl (tree decl, unsigned int known_align) int size_as_int = TREE_INT_CST_LOW (size); if (compare_tree_int (size, size_as_int) == 0) - warning (0, "size of %q+D is %d bytes", decl, size_as_int); + warning (OPT_Wlarger_than_eq, "size of %q+D is %d bytes", decl, size_as_int); else - warning (0, "size of %q+D is larger than %wd bytes", + warning (OPT_Wlarger_than_eq, "size of %q+D is larger than %wd bytes", decl, larger_than_size); } } @@ -503,17 +496,6 @@ relayout_decl (tree decl) layout_decl (decl, 0); } -/* Hook for a front-end function that can modify the record layout as needed - immediately before it is finalized. */ - -static void (*lang_adjust_rli) (record_layout_info) = 0; - -void -set_lang_adjust_rli (void (*f) (record_layout_info)) -{ - lang_adjust_rli = f; -} - /* Begin laying out type T, which may be a RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE. Return a pointer to a struct record_layout_info which is to be passed to all other layout functions for this record. It is the @@ -1873,9 +1855,6 @@ layout_type (tree type) if (TREE_CODE (type) == QUAL_UNION_TYPE) TYPE_FIELDS (type) = nreverse (TYPE_FIELDS (type)); - if (lang_adjust_rli) - (*lang_adjust_rli) (rli); - /* Finish laying out the record. */ finish_record_layout (rli, /*free_p=*/true); } @@ -1893,13 +1872,10 @@ layout_type (tree type) && TREE_CODE (type) != QUAL_UNION_TYPE) finalize_type_size (type); - /* If an alias set has been set for this aggregate when it was incomplete, - force it into alias set 0. - This is too conservative, but we cannot call record_component_aliases - here because some frontends still change the aggregates after - layout_type. */ - if (AGGREGATE_TYPE_P (type) && TYPE_ALIAS_SET_KNOWN_P (type)) - TYPE_ALIAS_SET (type) = 0; + /* We should never see alias sets on incomplete aggregates. And we + should not call layout_type on not incomplete aggregates. */ + if (AGGREGATE_TYPE_P (type)) + gcc_assert (!TYPE_ALIAS_SET_KNOWN_P (type)); } /* Create and return a type for signed integers of PRECISION bits. */