https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86453
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Component|lto |c
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot
gnu.org
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Anyhow, fixing the ICE yields:
t.ii:2:41: warning: ignoring attribute ‘packed’ because it conflicts with
attribute ‘aligned’ [-Wattributes]
int *__attribute__((aligned, packed)) a;
^
it looks like ->exclude isn't applied before handle_*.
And if I remove aligned then packed flag setting "works", so that is
likely the underlying issue. Which means it is a C family / middle-end
issue after all.
Not sure how to resolve this w/o splitting handlers even more or
merging handle_* and exclusion.
Martin, you added the exclusion mechanism - we likely ran into this issue
before but the exclusion mechanism doesn't "undo" the flag setting effects
of the earlier handle_* routines even though it says the attribute is ignored.
Note that even with just
struct {
int *__attribute__((packed)) a;
} b;
a type variant is built but we do not end up verifying it, it somehow
gets collected. This is all a bit confusing but clearly
static tree
handle_packed_attribute (tree *node, tree name, tree ARG_UNUSED (args),
int flags, bool *no_add_attrs)
{
if (TYPE_P (*node))
{
if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
*node = build_variant_type_copy (*node);
TYPE_PACKED (*node) = 1;
}
is bogus. Maybe it should really build a distinct type copy here. Maybe
the issue is that for ((aligned, packed)) we handle the attributes separately.
Given that aligned is documented to not reduce alignment w/o packed when
used on structs or struct members it's odd that we diagnose its use
on types rather than silently ignoring it:
When used on a struct, or struct member, the @code{aligned} attribute can
only increase the alignment; in order to decrease it, the @code{packed}
attribute must be specified as well. When used as part of a typedef, the
@code{aligned} attribute can both increase and decrease alignment, and
specifying the @code{packed} attribute generates a warning.
I am testing
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index f91add488bb..8cb87eb8154 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -502,8 +502,13 @@ handle_packed_attribute (tree *node, tree name, tree
ARG_UNUSED (args),
if (TYPE_P (*node))
{
if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
- *node = build_variant_type_copy (*node);
- TYPE_PACKED (*node) = 1;
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute ignored for type %qT", name, *node);
+ *no_add_attrs = true;
+ }
+ else
+ TYPE_PACKED (*node) = 1;
}
else if (TREE_CODE (*node) == FIELD_DECL)
{