From patchwork Fri Jun 15 18:53:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cary Coutant X-Patchwork-Id: 165217 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 39C9AB70E8 for ; Sat, 16 Jun 2012 04:54:14 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1340391255; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:To:Subject:Message-Id:Date: From:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=qYWrBEr bfePa462nTwbzD8Aar9M=; b=rdjUpI4Muq4tHOxJAduTL+iFzDS99xrrDBQcJVa WzKVuDNPnUIcxGLM8j3GlHgdnbGJbrQvNL1y4ajiohUFfVZK8yb5mJF+KyDYhSB6 IUoUd00PKMilVQ7sBoxbMILE2jLQrFgQijiy133ks+D/+8LdQZqtfimpLNzUZKT5 6KnM= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:Received:Received:To:Subject:Message-Id:Date:From:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=C93A+NefXWeMhFSJGoKd/+5VtiFIY3ej2i4IQcdJR8QLo/QDzYnyxjEdEGx9Xp XvCwfioKHp3Xd3ZbfANLCdJHIH2IV4RRpcWN6Nk6FLarUDResaHIDt+dAeicRxiu hAqZIaxf0rAvg/pyf6A81cOZSqtPDgyl2uItGDbF3J6ic=; Received: (qmail 19453 invoked by alias); 15 Jun 2012 18:54:06 -0000 Received: (qmail 19440 invoked by uid 22791); 15 Jun 2012 18:54:02 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_CX, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-lb0-f201.google.com (HELO mail-lb0-f201.google.com) (209.85.217.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 15 Jun 2012 18:53:47 +0000 Received: by lbdb5 with SMTP id b5so236797lbd.2 for ; Fri, 15 Jun 2012 11:53:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=to:subject:message-id:date:from:x-gm-message-state; bh=6Uj59sFIapt0RHxthSbBQlm5Ei4j7xHcVQcXA63S9us=; b=V+QDKY580XF2VegmwpS7dD7LMhgMGR/gGGMjMTPdwfApxQ2h+kBXPMP4jNHCptUWht EIBNdlCo0jNp68PBPxNsOLEUtO7p5xqIJeuNHFiqqfPpt4YpBlzogrtGpKN1sXaEEgDg e3Y4SjioB4pwm7q8FlTfDY22Ux9sZUcVol3JsZqt2oFYp+coTKUa62/jPW7qWeL3yhHV QgK3xC4WSj9ntKPITuhC1h7/HuKib/ugsVcbbz+uy62gXnqnYt79cSIZk8huvn/Il77O H6YpCA5xMCTTiAsLqdMHgUvx3VjqfSu5p/QtshK8e8fYQPz7WBjNzSdCkNTIL8lOQRJX SBbQ== Received: by 10.14.187.129 with SMTP id y1mr2172088eem.10.1339786425656; Fri, 15 Jun 2012 11:53:45 -0700 (PDT) Received: by 10.14.187.129 with SMTP id y1mr2172084eem.10.1339786425556; Fri, 15 Jun 2012 11:53:45 -0700 (PDT) Received: from hpza9.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id b15si9134930een.0.2012.06.15.11.53.45 (version=TLSv1/SSLv3 cipher=AES128-SHA); Fri, 15 Jun 2012 11:53:45 -0700 (PDT) Received: from ccoutant.mtv.corp.google.com (ccoutant.mtv.corp.google.com [172.18.110.42]) by hpza9.eem.corp.google.com (Postfix) with ESMTP id 0B2835C0050; Fri, 15 Jun 2012 11:53:45 -0700 (PDT) Received: by ccoutant.mtv.corp.google.com (Postfix, from userid 62097) id 40B4FE047E; Fri, 15 Jun 2012 11:53:44 -0700 (PDT) To: reply@codereview.appspotmail.com, saugustine@google.com, gcc-patches@gcc.gnu.org Subject: [google/gcc-4_7] Revert preliminary Fission patches (issue6303084) Message-Id: <20120615185344.40B4FE047E@ccoutant.mtv.corp.google.com> Date: Fri, 15 Jun 2012 11:53:44 -0700 (PDT) From: ccoutant@google.com (Cary Coutant) X-Gm-Message-State: ALoCoQmiBLRoi7cD4ydKHV0KLUsNuoHXdh/dABCgmTCpbrjRFMex33sv5GxzU70Z9gSNZLZOLyx70YLwygMO8RIspNpXnaHSP+Vj61k5CY27Jvf7KnXjEdXQfylfHB4ir7kRC/et9FITIvqxO6GCk20rJaVL3EhS4g== X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch is for google/gcc-4_7. Revert Fission patches r182490, r182891, r183042, and r183320. This will clear the way to backport the final patches from trunk. r182490: gcc/c-family/ 2011-12-19 Sterling Augustine * c-pretty-print.c (pp_c_specifier_qualifier_list): Move conditional from beginning to end. gcc/cp/ 2011-12-19 Sterling Augustine * error.c (dump_decl): Reformat return value to "(anonymous namespace)". (lang_decl_name): Return "(anonymous namespace)" when appropriate. gcc/ 2011-12-19 Sterling Augustine * dwarf2out.c (DEBUG_PUBNAMES_SECTION_LABEL, DEBUG_PUBTYPES_SECTION_LABEL): Define. (debug_pubnames_section_label, debug_pubtypes_section_label): Declare. (is_namespace_die, is_class_die): New functions. (add_enumerator_pubname): New function. (add_pubname): Call is_namespace_die, is_cu_die, and is_class_die in conditional. (add_pubtype): Call is_namespace_die. Rework name calculation. Call type_tag, lang_hooks.dwarf_name and add_enumerator_pubname. (output_pubnames): Output debug_pubnames_section_label or debug_pubtypes_section_label. (base_type_die): Call add_pubtype. (gen_namespace_die): Call add_pubname_string and lang_hooks.dwarf_name. (dwarf2_out_init): Generate debug_pubnames_section_label and debug_pubtypes_section_label. (pubtypes_section_empty): New function. (dwarf2_out_finish): Call add_AT_lineptr if pubnames or pubtypes is non-empty. When dealing with pubnames, change assertion to conditional. Call pubtypes_section_empty. Likewise when dealing with pubtypes. Move code checking for empty section to... (pubtypes_section_empty): Here. * target.def: Switch boolean to enable pubnames and pubtypes. r182891: gcc/ 2012-01-04 Sterling Augustine * dwarf2out.c (add_pubname): Move conditional clause from outer to inner if-statement. (dwarf2out_finish): Fix conditions to output DW_AT_GNU_pubnames and DW_AT_GNU_pubtypes. Move decision to output pubnames and pubtypes from here... (output_pubnames): ...to here. (pubtypes_section_empty): Delete unused function. gcc/testsuite/ 2012-01-04 Sterling Augustine * g++.dg/diagnostic/bindings1.C: Adjust expected output. * g++.dg/ext/pretty3.C: Likewise. * g++.dg/pr44486.C: Likewise. * g++.dg/warn/Wuninitializable-member.C: Likewise. * g++.dg/warn/pr35711.C: Likewise. * g++.old-deja/g++.pt/memtemp77.C: Likewise. r183042: gcc/ 2012-01-09 Sterling Augustine * dwarf2out.c (output_pubnames): Add check for info_section_emitted. r183320: gcc/ 2012-01-19 Sterling Augustine * dwarf2out.c (break_out_comdat_types): Add DW_AT_GNU_pubnames and DW_AT_GNU_pubtypes attributes. --- This patch is available for review at http://codereview.appspot.com/6303084 Index: gcc/c-family/c-pretty-print.c =================================================================== --- gcc/c-family/c-pretty-print.c (revision 188679) +++ gcc/c-family/c-pretty-print.c (working copy) @@ -446,6 +446,8 @@ pp_c_specifier_qualifier_list (c_pretty_ { const enum tree_code code = TREE_CODE (t); + if (TREE_CODE (t) != POINTER_TYPE) + pp_c_type_qualifier_list (pp, t); switch (code) { case REFERENCE_TYPE: @@ -492,8 +494,6 @@ pp_c_specifier_qualifier_list (c_pretty_ pp_simple_type_specifier (pp, t); break; } - if (TREE_CODE (t) != POINTER_TYPE) - pp_c_type_qualifier_list (pp, t); } /* parameter-type-list: Index: gcc/target.def =================================================================== --- gcc/target.def (revision 188679) +++ gcc/target.def (working copy) @@ -2813,7 +2813,7 @@ DEFHOOKPOD "True if the @code{.debug_pubtypes} and @code{.debug_pubnames} sections\ should be emitted. These sections are not used on most platforms, and\ in particular GDB does not use them.", - bool, true) + bool, false) DEFHOOKPOD (delay_sched2, "True if sched2 is not to be run at its normal place. \ Index: gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C =================================================================== --- gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C (revision 188679) +++ gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C (working copy) @@ -19,7 +19,7 @@ const char* S3::h(int) { return __ int main() { if (strcmp (S3::h(7), - "static char const* S3::h(U) [with U = int; T = double]") == 0) + "static const char* S3::h(U) [with U = int; T = double]") == 0) return 0; else return 1; Index: gcc/testsuite/g++.dg/ext/pretty3.C =================================================================== --- gcc/testsuite/g++.dg/ext/pretty3.C (revision 188679) +++ gcc/testsuite/g++.dg/ext/pretty3.C (working copy) @@ -16,4 +16,4 @@ int main () { printf ("%s\n", D().foo (0)); } -// { dg-final { scan-assembler "char const\\* D::foo\\(typename B::X\\)" } } +// { dg-final { scan-assembler "const char\\* D::foo\\(typename B::X\\)" } } Index: gcc/testsuite/g++.dg/diagnostic/bindings1.C =================================================================== --- gcc/testsuite/g++.dg/diagnostic/bindings1.C (revision 188679) +++ gcc/testsuite/g++.dg/diagnostic/bindings1.C (working copy) @@ -10,7 +10,7 @@ struct x {typedef int type;}; int main() { - if (strcmp (foo(x(), 3), "char const* foo(T, typename T::type) " + if (strcmp (foo(x(), 3), "const char* foo(T, typename T::type) " "[with T = x; typename T::type = int]") == 0) return 0; else Index: gcc/testsuite/g++.dg/warn/Wuninitializable-member.C =================================================================== --- gcc/testsuite/g++.dg/warn/Wuninitializable-member.C (revision 188679) +++ gcc/testsuite/g++.dg/warn/Wuninitializable-member.C (working copy) @@ -8,7 +8,7 @@ public: }; class Y { - const int var;// { dg-warning "non-static const member 'int const Y::var' in class without a constructor" } + const int var;// { dg-warning "non-static const member 'const int Y::var' in class without a constructor" } public: int g(){ return 2*var; } }; Index: gcc/testsuite/g++.dg/warn/pr35711.C =================================================================== --- gcc/testsuite/g++.dg/warn/pr35711.C (revision 188679) +++ gcc/testsuite/g++.dg/warn/pr35711.C (working copy) @@ -4,5 +4,5 @@ int* foo (volatile int *p) { - return (int*)p; // { dg-warning "cast from type 'int volatile\\*' to type 'int\\*' casts away qualifiers" } + return (int*)p; // { dg-warning "cast from type 'volatile int\\*' to type 'int\\*' casts away qualifiers" } } Index: gcc/testsuite/g++.dg/pr44486.C =================================================================== --- gcc/testsuite/g++.dg/pr44486.C (revision 188679) +++ gcc/testsuite/g++.dg/pr44486.C (working copy) @@ -7,4 +7,4 @@ namespace { S f() { const char * s = __P int main() { f(); } -// { dg-final { scan-assembler "S \\(anonymous namespace\\)::f" } } +// { dg-final { scan-assembler "S \{anonymous\}::f" } } Index: gcc/cp/error.c =================================================================== --- gcc/cp/error.c (revision 188679) +++ gcc/cp/error.c (working copy) @@ -1028,7 +1028,7 @@ dump_decl (tree t, int flags) dump_scope (CP_DECL_CONTEXT (t), flags); flags &= ~TFF_UNQUALIFIED_NAME; if (DECL_NAME (t) == NULL_TREE) - pp_cxx_ws_string (cxx_pp, M_("(anonymous namespace)")); + pp_cxx_ws_string (cxx_pp, M_("{anonymous}")); else pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t)); } @@ -2595,8 +2595,6 @@ lang_decl_name (tree decl, int v, bool t if (TREE_CODE (decl) == FUNCTION_DECL) dump_function_name (decl, TFF_PLAIN_IDENTIFIER); - else if (DECL_NAME (decl) == NULL && TREE_CODE (decl) == NAMESPACE_DECL) - pp_string (cxx_pp, M_("(anonymous namespace)")); else dump_decl (DECL_NAME (decl), TFF_PLAIN_IDENTIFIER); Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 188679) +++ gcc/dwarf2out.c (working copy) @@ -3353,7 +3353,6 @@ static void output_comp_unit (dw_die_ref static void output_comdat_type_unit (comdat_type_node *); static const char *dwarf2_name (tree, int); static void add_pubname (tree, dw_die_ref); -static void add_enumerator_pubname (const char *, const char *, dw_die_ref); static void add_pubname_string (const char *, dw_die_ref); static void add_pubtype (tree, dw_die_ref); static void output_pubnames (VEC (pubname_entry,gc) *); @@ -3557,12 +3556,6 @@ static void gen_scheduled_generic_parms_ #ifndef COLD_TEXT_SECTION_LABEL #define COLD_TEXT_SECTION_LABEL "Ltext_cold" #endif -#ifndef DEBUG_PUBNAMES_SECTION_LABEL -#define DEBUG_PUBNAMES_SECTION_LABEL "Ldebug_pubnames" -#endif -#ifndef DEBUG_PUBTYPES_SECTION_LABEL -#define DEBUG_PUBTYPES_SECTION_LABEL "Ldebug_pubtypes" -#endif #ifndef DEBUG_LINE_SECTION_LABEL #define DEBUG_LINE_SECTION_LABEL "Ldebug_line" #endif @@ -3599,8 +3592,6 @@ static char cold_end_label[MAX_ARTIFICIA static char abbrev_section_label[MAX_ARTIFICIAL_LABEL_BYTES]; static char debug_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES]; static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES]; -static char debug_pubnames_section_label[MAX_ARTIFICIAL_LABEL_BYTES]; -static char debug_pubtypes_section_label[MAX_ARTIFICIAL_LABEL_BYTES]; static char macinfo_section_label[MAX_ARTIFICIAL_LABEL_BYTES]; static char loc_section_label[MAX_ARTIFICIAL_LABEL_BYTES]; static char ranges_section_label[2 * MAX_ARTIFICIAL_LABEL_BYTES]; @@ -6735,22 +6726,6 @@ is_cu_die (dw_die_ref c) return c && c->die_tag == DW_TAG_compile_unit; } -/* Returns true iff C is a namespace DIE. */ - -static inline bool -is_namespace_die (dw_die_ref c) -{ - return c && c->die_tag == DW_TAG_namespace; -} - -/* Returns true iff C is a class DIE. */ - -static inline bool -is_class_die (dw_die_ref c) -{ - return c && c->die_tag == DW_TAG_class_type; -} - static char * gen_internal_sym (const char *prefix) { @@ -7323,15 +7298,6 @@ break_out_comdat_types (dw_die_ref die) type_node->root_die = unit; type_node->next = comdat_type_list; comdat_type_list = type_node; - if (targetm.want_debug_pub_sections) - { - /* FIXME: Should use add_AT_pubnamesptr. This works because most - targets don't care what the base section is. */ - add_AT_lineptr (unit, DW_AT_GNU_pubnames, - debug_pubnames_section_label); - add_AT_lineptr (unit, DW_AT_GNU_pubtypes, - debug_pubtypes_section_label); - } /* Generate the type signature. */ generate_type_signature (c, type_node); @@ -8738,35 +8704,16 @@ add_pubname_string (const char *str, dw_ static void add_pubname (tree decl, dw_die_ref die) { - if (!GENERATE_MINIMUM_LINE_TABLE && targetm.want_debug_pub_sections) + if (!GENERATE_MINIMUM_LINE_TABLE + && targetm.want_debug_pub_sections + && TREE_PUBLIC (decl)) { - if ((TREE_PUBLIC (decl) && !is_class_die (die->die_parent)) - || is_cu_die (die->die_parent) || is_namespace_die (die->die_parent)) - { - const char *name = dwarf2_name (decl, 1); - if (name) - add_pubname_string (name, die); - } + const char *name = dwarf2_name (decl, 1); + if (name) + add_pubname_string (name, die); } } -/* Add an enumerator to the pubnames section. */ - -static void -add_enumerator_pubname (const char *scope_name, const char *sep, dw_die_ref die) -{ - const char *name; - pubname_entry e; - - if (scope_name) - name = concat (scope_name, sep, get_AT_string (die, DW_AT_name), NULL); - else - name = xstrdup (get_AT_string (die, DW_AT_name)); - e.name = name; - e.die = die; - VEC_safe_push (pubname_entry, gc, pubtype_table, &e); -} - /* Add a new entry to .debug_pubtypes if appropriate. */ static void @@ -8779,47 +8726,34 @@ add_pubtype (tree decl, dw_die_ref die) e.name = NULL; if ((TREE_PUBLIC (decl) - || is_cu_die (die->die_parent) || is_namespace_die (die->die_parent)) + || is_cu_die (die->die_parent)) && (die->die_tag == DW_TAG_typedef || COMPLETE_TYPE_P (decl))) { - tree scope = NULL; - const char *scope_name = NULL; - const char *sep = is_cxx () ? "::" : "."; - const char *name = NULL; - + e.die = die; if (TYPE_P (decl)) - name = type_tag (decl); + { + if (TYPE_NAME (decl)) + { + if (TREE_CODE (TYPE_NAME (decl)) == IDENTIFIER_NODE) + e.name = IDENTIFIER_POINTER (TYPE_NAME (decl)); + else if (TREE_CODE (TYPE_NAME (decl)) == TYPE_DECL + && DECL_NAME (TYPE_NAME (decl))) + e.name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (decl))); + else + e.name = xstrdup ((const char *) get_AT_string (die, DW_AT_name)); + } + } else - name = lang_hooks.dwarf_name (decl, 1); + { + e.name = dwarf2_name (decl, 1); + if (e.name) + e.name = xstrdup (e.name); + } /* If we don't have a name for the type, there's no point in adding it to the table. */ - if (name == NULL || name[0] == '\0') - return; - - e.die = die; - e.name = xstrdup (name); - - scope = TYPE_P (decl) ? TYPE_CONTEXT (decl) : NULL; - if (scope && TREE_CODE (scope) == NAMESPACE_DECL) - { - scope_name = lang_hooks.dwarf_name (scope, 1); - if (scope_name != NULL) - e.name = concat (scope_name, sep, e.name, NULL); - } - VEC_safe_push (pubname_entry, gc, pubtype_table, &e); - - /* Although it might be more consistent to add the pubinfo for the - enumerators as their dies are created, they should only be added if the - enum type meets the criteria above. So rather than re-check the parent - enum type whenever an enumerator die is created, just output them all - here. */ - if (die->die_tag == DW_TAG_enumeration_type) - { - dw_die_ref c; - - FOR_EACH_CHILD (die, c, add_enumerator_pubname (scope_name, sep, c)); - } + if (e.name && e.name[0] != '\0') + VEC_safe_push (pubname_entry, gc, pubtype_table, &e); } } @@ -8833,18 +8767,6 @@ output_pubnames (VEC (pubname_entry, gc) unsigned long pubnames_length = size_of_pubnames (names); pubname_ref pub; - if (!targetm.want_debug_pub_sections || !info_section_emitted) - return; - if (names == pubname_table) - { - switch_to_section (debug_pubnames_section); - ASM_OUTPUT_LABEL (asm_out_file, debug_pubnames_section_label); - } - else - { - switch_to_section (debug_pubtypes_section); - ASM_OUTPUT_LABEL (asm_out_file, debug_pubtypes_section_label); - } if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) dw2_asm_output_data (4, 0xffffffff, "Initial length escape value indicating 64-bit DWARF extension"); @@ -9756,7 +9678,6 @@ base_type_die (tree type) add_AT_unsigned (base_type_result, DW_AT_byte_size, int_size_in_bytes (type)); add_AT_unsigned (base_type_result, DW_AT_encoding, encoding); - add_pubtype (type, base_type_result); return base_type_result; } @@ -19562,8 +19483,6 @@ gen_namespace_die (tree decl, dw_die_ref add_AT_die_ref (namespace_die, DW_AT_import, origin_die); equate_decl_number_to_die (decl, namespace_die); } - /* Bypass dwarf2_name's check for DECL_NAMELESS. */ - add_pubname_string (lang_hooks.dwarf_name (decl, 1), namespace_die); } /* Generate Dwarf debug information for a decl described by DECL. @@ -21267,10 +21186,6 @@ dwarf2out_init (const char *filename ATT ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label, DEBUG_INFO_SECTION_LABEL, 0); - ASM_GENERATE_INTERNAL_LABEL (debug_pubnames_section_label, - DEBUG_PUBNAMES_SECTION_LABEL, 0); - ASM_GENERATE_INTERNAL_LABEL (debug_pubtypes_section_label, - DEBUG_PUBTYPES_SECTION_LABEL, 0); ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label, DEBUG_LINE_SECTION_LABEL, 0); ASM_GENERATE_INTERNAL_LABEL (ranges_section_label, @@ -22613,7 +22528,6 @@ optimize_location_lists (dw_die_ref die) htab_delete (htab); } - /* Output stuff that dwarf requires at the end of every file, and generate the DWARF-2 debugging info. */ @@ -22874,17 +22788,6 @@ dwarf2out_finish (const char *filename) } htab_delete (comdat_type_table); - /* Add the DW_AT_GNU_pubnames and DW_AT_GNU_pubtypes attributes. */ - if (targetm.want_debug_pub_sections) - { - /* FIXME: Should use add_AT_pubnamesptr. This works because most targets - don't care what the base section is. */ - add_AT_lineptr (comp_unit_die (), DW_AT_GNU_pubnames, - debug_pubnames_section_label); - add_AT_lineptr (comp_unit_die (), DW_AT_GNU_pubtypes, - debug_pubtypes_section_label); - } - /* Output the main compilation unit if non-empty or if .debug_macinfo or .debug_macro will be emitted. */ output_comp_unit (comp_unit_die (), have_macinfo); @@ -22908,12 +22811,42 @@ dwarf2out_finish (const char *filename) output_location_lists (comp_unit_die ()); } - /* Output public names and types tables if necessary. */ - output_pubnames (pubname_table); + /* Output public names table if necessary. */ + if (!VEC_empty (pubname_entry, pubname_table)) + { + gcc_assert (info_section_emitted); + switch_to_section (debug_pubnames_section); + output_pubnames (pubname_table); + } + + /* Output public types table if necessary. */ /* ??? Only defined by DWARF3, but emitted by Darwin for DWARF2. It shouldn't hurt to emit it always, since pure DWARF2 consumers simply won't look for the section. */ - output_pubnames (pubtype_table); + if (!VEC_empty (pubname_entry, pubtype_table)) + { + bool empty = false; + + if (flag_eliminate_unused_debug_types) + { + /* The pubtypes table might be emptied by pruning unused items. */ + unsigned i; + pubname_ref p; + empty = true; + FOR_EACH_VEC_ELT (pubname_entry, pubtype_table, i, p) + if (p->die->die_offset != 0) + { + empty = false; + break; + } + } + if (!empty) + { + gcc_assert (info_section_emitted); + switch_to_section (debug_pubtypes_section); + output_pubnames (pubtype_table); + } + } /* Output the address range information if a CU (.debug_info section) was emitted. We output an empty table even if we had no functions