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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|debug                       |c++

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
The particular reason we even stream the CONST_DECL is that it appears in

int __attribute__((aligned (A))) foo;

via the attribute list:

 <var_decl 0x7ffff6a1ae10 foo
    type <integer_type 0x7ffff6a305e8 int asm_written public type_6 SI
        size <integer_cst 0x7ffff6a2a408 constant 32>
        unit-size <integer_cst 0x7ffff6a2a420 constant 4>
        align:32 warn_if_not_align:0 symtab:-157035984 alias-set 2
canonical-type 0x7ffff6a305e8 precision:32 min <integer_cst 0x7ffff6a2a3c0
-2147483648> max <integer_cst 0x7ffff6a2a3d8 2147483647>
        pointer_to_this <pointer_type 0x7ffff6a37b28>>
    addressable public static SI pr50459.c:13:34 size <integer_cst
0x7ffff6a2a408 32> unit-size <integer_cst 0x7ffff6a2a420 4>
    user align:1024 warn_if_not_align:0 context <translation_unit_decl
0x7ffff6a19168 pr50459.c>
    attributes <tree_list 0x7ffff6bc6000
        purpose <identifier_node 0x7ffff6a2c980 aligned>
        value <tree_list 0x7ffff6bb9be0 value <const_decl 0x7ffff6bc5000 A>>>
chain <var_decl 0x7ffff6a1ad80 a>>

where we "failed" to replace the CONST_DECL with its value.  When handling
the attribute we're doing

      align_expr = TREE_VALUE (args);
      if (align_expr && TREE_CODE (align_expr) != IDENTIFIER_NODE
          && TREE_CODE (align_expr) != FUNCTION_DECL)
        align_expr = default_conversion (align_expr);

and that resolves it to an INTEGER_CST for further processing.

I'll note that streaming out debug references from certain contexts like
attribute arguments is also unnecessary but it's difficult to selectively
disable it.

IMO the correct thing to do is for the C++ frontend to, like the C frontend,
resolve the enumerators before calling common_handle_aligned_attribute.

It's also possible to more gracefully handle the assert it's still a bug.
I'm going to handle it gracefully when not checking.

Reply via email to