@@ -18770,7 +18770,20 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
struct dwarf_file_data * file_index = lookup_filename (s.file);
if (((is_cu_die (old_die->die_parent)
|| context_die == NULL
- || dumped_early)
+ || (dumped_early
+ /* 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)
+ || !class_or_namespace_scope_p (old_die->die_parent))))
&& (DECL_ARTIFICIAL (decl)
|| (get_AT_file (old_die, DW_AT_decl_file) == file_index
&& (get_AT_unsigned (old_die, DW_AT_decl_line)