commit bf6ab23aad749d927108ace21ee01a94af31a38b Author: Cary Coutant <ccout...@google.com> Date: Mon Apr 25 13:54:19 2011 -0700
Check for classes that contain defining declarations of subprograms, and do not move such classes into a comdat type unit. I've updated the patch to assert that a type definition does not contain a subprogram definition. OK for trunk? Tested: Bootstrapped on x86_64, no new regressions. gcc/ChangeLog: 2011-05-05 Cary Coutant <ccout...@google.com> * dwarf2out.c (contains_subprogram_definition): New function. (should_move_die_to_comdat): Call it. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index fb1dd9c..a43f5f6 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -10018,6 +10018,20 @@ is_nested_in_subprogram (dw_die_ref die) return local_scope_p (decl); } +/* Return non-zero if this DIE contains a defining declaration of a + subprogram. */ + +static int +contains_subprogram_definition (dw_die_ref die) +{ + dw_die_ref c; + + if (die->die_tag == DW_TAG_subprogram && ! is_declaration_die (die)) + return 1; + FOR_EACH_CHILD (die, c, if (contains_subprogram_definition(c)) return 1); + return 0; +} + /* Return non-zero if this is a type DIE that should be moved to a COMDAT .debug_types section. */ @@ -10036,6 +10050,8 @@ should_move_die_to_comdat (dw_die_ref die) || get_AT (die, DW_AT_abstract_origin) || is_nested_in_subprogram (die)) return 0; + /* A type definition should never contain a subprogram definition. */ + gcc_assert (!contains_subprogram_definition (die)); return 1; case DW_TAG_array_type: case DW_TAG_interface_type: -- This patch is available for review at http://codereview.appspot.com/4433068