https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108910

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
To be exact, it is more complicated than that.
Some types with extra types are created using build_variant_type_copy and so
their TYPE_MAIN_VARIANT is without the attributes.
Example is handle_aligned_attribute -> common_handle_aligned_attribute ->
build_variant_type_copy.
Others are created as build_distinct_type_copy and don't have TYPE_MAIN_VARIANT
without it, e.g. build_type_attribute_variant ->
build_type_attribute_qual_variant -> build_distinct_type_copy.

Compare e.g. the #c0 testcase vs.
extern void foo (float, float *, float *);

void
bar (void *p)
{
  typedef float *FP;
  typedef FP FP2 __attribute__((aligned (64)));
  FP2 q = __builtin_assume_aligned (p, 64);
  foo (0.0f, q, q);
}
which doesn't ICE.
#0  build_distinct_type_copy (type=<pointer_type 0x7fffea274a80>) at
../../gcc/tree.cc:5693
#1  0x0000000000c143bb in build_type_attribute_qual_variant
(otype=<pointer_type 0x7fffea274a80>, attribute=<tree_list 0x7fffea2728c0>,
quals=0) at ../../gcc/attribs.cc:1298
#2  0x0000000000c156f0 in build_type_attribute_variant (ttype=<pointer_type
0x7fffea274a80>, attribute=<tree_list 0x7fffea2728c0>) at
../../gcc/attribs.cc:1591
#3  0x0000000000c13465 in decl_attributes (node=0x7fffffffd1f8,
attributes=<tree_list 0x7fffea272898>, flags=1, last_decl=<tree 0x0>) at
../../gcc/attribs.cc:964
#4  0x0000000000c32a69 in grokdeclarator (declarator=0x3716e40,
declspecs=0x3716cc0, decl_context=NORMAL, initialized=true, width=0x0,
decl_attrs=0x7fffffffd3d0, 
    expr=0x7fffffffd3f0, expr_const_operands=0x7fffffffd1ef,
deprecated_state=DEPRECATED_NORMAL) at ../../gcc/c/c-decl.cc:6967
#5  0x0000000000c2d270 in start_decl (declarator=0x3716e70,
declspecs=0x3716cc0, initialized=true, attributes=<tree 0x0>, do_push=true,
lastloc=0x0) at ../../gcc/c/c-decl.cc:5364
on #c0 while this one:
#1  0x000000000191494b in build_variant_type_copy (type=<pointer_type
0x7fffea274a80 FP>) at ../../gcc/tree.cc:5727
#2  0x0000000000dbaeba in common_handle_aligned_attribute (node=0x7fffffffd270,
name=<identifier_node 0x7fffea288dc0 aligned>, args=<tree_list 0x7fffea272848>,
flags=0, 
    no_add_attrs=0x7fffffffd28f, warn_if_not_aligned_p=false) at
../../gcc/c-family/c-attribs.cc:2386
#3  0x0000000000dbb633 in handle_aligned_attribute (node=0x7fffffffd270,
name=<identifier_node 0x7fffea288dc0 aligned>, args=<tree_list 0x7fffea272848>,
flags=0, 
    no_add_attrs=0x7fffffffd28f) at ../../gcc/c-family/c-attribs.cc:2499
#4  0x0000000000c12dcd in decl_attributes (node=0x7fffffffd3f8,
attributes=<tree_list 0x7fffea272898>, flags=0, last_decl=<tree 0x0>) at
../../gcc/attribs.cc:878
#5  0x0000000000c2d1bc in c_decl_attributes (node=0x7fffffffd3f8,
attributes=<tree_list 0x7fffea272898>, flags=0) at ../../gcc/c/c-decl.cc:5323
#6  0x0000000000c2d699 in start_decl (declarator=0x3716f60,
declspecs=0x3716ea0, initialized=false, attributes=<tree_list 0x7fffea272898>,
do_push=true, lastloc=0x7fffffffd584)
    at ../../gcc/c/c-decl.cc:5460

Reply via email to