On 03/20/2015 02:21 PM, Jason Merrill wrote:
I think we want to drop the debug_early check there entirely; the added
conditions seem to be gutting it.  If is_cu_die (old_die->die_parent) is
false, then class_or_namespace_scope_p (old_die->die_parent) ought to be
true.

Jason


Good catch. I am so glad you are keeping track of all this spaghetti, but in my defense, it was pasta already.

With the attached I also got rid of one superfluous check for `old_die', as well as your suggestion. We get rid of one more gdb regression. Yay.

I'll wait for your high-five (or OK) before committing to branch.

Thanks.
Aldy
commit b3d910713d27dc29801f3ddbe8671a4a6e0de4c1
Author: Aldy Hernandez <al...@redhat.com>
Date:   Fri Mar 20 09:55:31 2015 -0700

    Handle specification of class scoped static functions.
    
    Remove superfluous check for old_die.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 8884afd..7a52dc8 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -18735,7 +18735,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
      much as possible.  */
   else if (old_die)
     {
-      dumped_early = old_die && old_die->dumped_early;
+      dumped_early = old_die->dumped_early;
 
       /* A declaration that has been previously dumped needs no
         additional information.  */
@@ -18768,13 +18768,23 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
         apply; we just use the old DIE.  */
       expanded_location s = expand_location (DECL_SOURCE_LOCATION (decl));
       struct dwarf_file_data * file_index = lookup_filename (s.file);
-      if (((is_cu_die (old_die->die_parent)
-           || context_die == NULL
-           || dumped_early)
+      if ((is_cu_die (old_die->die_parent)
+          || context_die == NULL
+          /* For class scoped static functions, the dumped early
+             version was the declaration, whereas the next time
+             around with a different context should be the
+             specification.  In this case, avoid reusing the DIE, but
+             generate a specification below. E.g.:
+
+             class C {
+             public:
+               static void moo () {}
+             };  */
+          || !is_cu_die (context_die))
           && (DECL_ARTIFICIAL (decl)
               || (get_AT_file (old_die, DW_AT_decl_file) == file_index
                   && (get_AT_unsigned (old_die, DW_AT_decl_line)
-                      == (unsigned) s.line)))))
+                      == (unsigned) s.line))))
        {
          subr_die = old_die;
 

Reply via email to