[C++ RFC] Debug info for anonymous aggregates

Devang Patel dpatel@apple.com
Fri Jul 22 00:58:00 GMT 2005


C++ does not generate debug info for anonymous aggregates in cases  
like :

class A
{
     public:
     typedef struct
     {
         int d;
     } mystruct;
     mystruct data;
};

This is because FE sets DECL_IGNORED_P bit. This causes debug info  
generator to
skip debug info when invoked through rest_of_type_compilation(). The  
fix I am
testing over night is to reset DECL_IGNORED_P bit when real name is  
assigned
to anonymous aggregates and invoke debug_hooks again.

Is this the right approach? If yes then based on gcc and gdb dejagnu  
results
I'll prepare actual patch.

Thanks,
-
Devang

Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1364.2.6
diff -Idpatel.pbxuser -c -3 -p -r1.1364.2.6 decl.c
*** decl.c      9 Jul 2005 22:07:00 -0000       1.1364.2.6
--- decl.c      22 Jul 2005 00:51:45 -0000
*************** grokdeclarator (const cp_declarator *dec
*** 7706,7712 ****
           /* Replace the anonymous name with the real name  
everywhere.  */
           for (t = TYPE_MAIN_VARIANT (type); t; t =  
TYPE_NEXT_VARIANT (t))
             if (TYPE_NAME (t) == oldname)
!             TYPE_NAME (t) = decl;

           if (TYPE_LANG_SPECIFIC (type))
             TYPE_WAS_ANONYMOUS (type) = 1;
--- 7706,7722 ----
           /* Replace the anonymous name with the real name  
everywhere.  */
           for (t = TYPE_MAIN_VARIANT (type); t; t =  
TYPE_NEXT_VARIANT (t))
             if (TYPE_NAME (t) == oldname)
!             {
!               TYPE_NAME (t) = decl;
!
!               /* Debug info was not generated earlier for anonymous  
aggregates.
!                  Now is the time generate debug info for such  
types.  */
!               if (ANON_AGGRNAME_P (DECL_NAME(oldname)))
!                 {
!                   DECL_IGNORED_P (TYPE_STUB_DECL (t)) = 0;
!                   debug_hooks->type_decl (TYPE_STUB_DECL (t),  
LOCAL_CLASS_P (t));
!                 }
!             }

           if (TYPE_LANG_SPECIFIC (type))
             TYPE_WAS_ANONYMOUS (type) = 1;
Index: name-lookup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/name-lookup.c,v
retrieving revision 1.109.2.2
diff -Idpatel.pbxuser -c -3 -p -r1.109.2.2 name-lookup.c
*** name-lookup.c       9 Jul 2005 22:07:03 -0000       1.109.2.2
--- name-lookup.c       22 Jul 2005 00:51:45 -0000
*************** pushtag (tree name, tree type, tag_scope
*** 4675,4681 ****
           else
             d = pushdecl_with_scope (d, b);

!         /* FIXME what if it gets a name from typedef?  */
           if (ANON_AGGRNAME_P (name))
             DECL_IGNORED_P (d) = 1;

--- 4675,4682 ----
           else
             d = pushdecl_with_scope (d, b);

!         /* If it gets a name from typedef, reset DECL_IGNORED_P flag
!            and invoke debug_hooks again.  */
           if (ANON_AGGRNAME_P (name))
             DECL_IGNORED_P (d) = 1;




More information about the Gcc mailing list