This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Make C11 _Alignof return least not greatest alignment for a type (PR c/52023)
- From: Marek Polacek <polacek at redhat dot com>
- To: Andreas Schwab <schwab at linux-m68k dot org>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 5 Dec 2013 12:43:03 +0100
- Subject: Re: Make C11 _Alignof return least not greatest alignment for a type (PR c/52023)
- Authentication-results: sourceware.org; auth=none
- References: <Pine dot LNX dot 4 dot 64 dot 1312042257070 dot 21433 at digraph dot polyomino dot org dot uk> <87eh5rilu9 dot fsf at igel dot home>
On Thu, Dec 05, 2013 at 12:22:22PM +0100, Andreas Schwab wrote:
> "Joseph S. Myers" <joseph@codesourcery.com> writes:
>
> > @@ -4994,6 +4997,22 @@ c_sizeof_or_alignof_type (location_t loc,
> > value = size_binop_loc (loc, CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
> > size_int (TYPE_PRECISION (char_type_node)
> > / BITS_PER_UNIT));
> > + else if (min_alignof)
> > + {
> > + unsigned int align = TYPE_ALIGN (type);
> > + align = MIN (align, BIGGEST_ALIGNMENT);
> > +#ifdef BIGGEST_FIELD_ALIGNMENT
> > + align = MIN (align, BIGGEST_FIELD_ALIGNMENT);
> > +#endif
> > + tree field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE,
> > + type);
> > + unsigned int field_align = align;
> > +#ifdef ADJUST_FIELD_ALIGN
> > + field_align = ADJUST_FIELD_ALIGN (field, field_align);
> > +#endif
> > + align = MIN (align, field_align);
> > + value = size_int (align / BITS_PER_UNIT);
> > + }
> > else
> > value = size_int (TYPE_ALIGN_UNIT (type));
> > }
>
> ../../gcc/c-family/c-common.c: In function âtree_node* c_sizeof_or_alignof_type(location_t, tree, bool, bool, int)â:
> ../../gcc/c-family/c-common.c:5007:9: error: unused variable âfieldâ [-Werror=unused-variable]
> tree field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE,
The following should fix it.
2013-12-05 Marek Polacek <polacek@redhat.com>
c-family/
* c-common.c (c_sizeof_or_alignof_type): Move a declaration into
[ADJUST_FIELD_ALIGN].
--- gcc/c-family/c-common.c.mp2 2013-12-05 12:35:38.585732312 +0100
+++ gcc/c-family/c-common.c 2013-12-05 12:36:03.351820193 +0100
@@ -5004,10 +5004,10 @@ c_sizeof_or_alignof_type (location_t loc
#ifdef BIGGEST_FIELD_ALIGNMENT
align = MIN (align, BIGGEST_FIELD_ALIGNMENT);
#endif
- tree field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE,
- type);
unsigned int field_align = align;
#ifdef ADJUST_FIELD_ALIGN
+ tree field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE,
+ type);
field_align = ADJUST_FIELD_ALIGN (field, field_align);
#endif
align = MIN (align, field_align);
Marek