http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47939

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.03.01 14:11:28
                 CC|                            |jsm28 at gcc dot gnu.org
          Component|debug                       |c
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-03-01 
14:11:28 UTC ---
Happens because when finishing the TYPE_DECL

      if (is_naming_typedef_decl (decl))
        /* We want that all subsequent calls to lookup_type_die with
           TYPE in argument yield the DW_TAG_typedef we have just
           created.  */
        equate_type_number_to_die (type, type_die);

returns false.  Which is because is_cxx () is returning false.

The VAR_DECL itself is not using the type-def id:

 <var_decl 0x7ffff5b49000 george
    type <record_type 0x7ffff5b2a498 _George readonly type_0 SI
        size <integer_cst 0x7ffff7ed36e0 constant 32>
        unit size <integer_cst 0x7ffff7ed33e8 constant 4>
        align 32 symtab -172776352 alias set -1 canonical type 0x7ffff5b2a498
        fields <field_decl 0x7ffff5b36130 dummy type <integer_type
0x7ffff7ee6498 int>
            SI file t.c line 1 col 36 size <integer_cst 0x7ffff7ed36e0 32> unit
size <integer_cst 0x7ffff7ed33e8 4>
            align 32 offset_align 128
            offset <integer_cst 0x7ffff7ed3410 constant 0>
            bit offset <integer_cst 0x7ffff7ed3b68 constant 0> context
<record_type 0x7ffff5b2a3f0 _George>> context <translation_unit_decl
0x7ffff7efca10 D.1588>>
    readonly asm_written public static common SI file t.c line 2 col 10 size
<integer_cst 0x7ffff7ed36e0 32> unit size <integer_cst 0x7ffff7ed33e8 4>
    align 32 context <translation_unit_decl 0x7ffff7efca10 D.1588>
    (mem/s/u/c:SI (symbol_ref:DI ("george") <var_decl 0x7ffff5b49000 george>)
[0 george+0 S4 A32])>

already grokdeclarator creates this by re-applying qualifiers via

  if (!flag_gen_aux_info && (TYPE_QUALS (element_type)))
    type = TYPE_MAIN_VARIANT (type);
  type_quals = ((constp ? TYPE_QUAL_CONST : 0)
                | (restrictp ? TYPE_QUAL_RESTRICT : 0)
                | (volatilep ? TYPE_QUAL_VOLATILE : 0)
                | ENCODE_QUAL_ADDR_SPACE (address_space));

and

6010    type = c_build_qualified_type (type, type_quals);

thereby stripping all uses of typedef ids.

Thus, it doesn't seem to distinguish between qualifiers applied at the
declaration and qualifiers that are part of the typedef.

c_build_qualified_type would handle choosing a variant with the same
name just fine - but we feed it the main variant instead of the original
type.

Index: gcc/c-decl.c
===================================================================
--- gcc/c-decl.c        (revision 170589)
+++ gcc/c-decl.c        (working copy)
@@ -6007,7 +6007,7 @@ grokdeclarator (const struct c_declarato
        /* An uninitialized decl with `extern' is a reference.  */
        int extern_ref = !initialized && storage_class == csc_extern;

-       type = c_build_qualified_type (type, type_quals);
+       type = c_build_qualified_type (declspecs->type, type_quals);

        /* C99 6.2.2p7: It is invalid (compile-time undefined
           behavior) to create an 'extern' declaration for a

fixes this particular testcase.

Joseph?

Reply via email to