From patchwork Mon May 19 19:29:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wielaard X-Patchwork-Id: 350374 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 377CE140079 for ; Tue, 20 May 2014 05:30:02 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version; q=dns; s=default; b=N2kifkJBxoN0EU//z9 bxEn2xpdRvA5kn8A389U4BBsWf/+VaqvKeYgvb4MkYTqf0pplXJr2rlm4a1XRusS DIwNzd8g7BaoZ2oI1Hsc+vg6rdJMZ4vovzNvkWE+USqpQ9qfbgcZ5TRF7xL8Ru4y pKM6Zed/Re/vsvoCz4HGC8B30= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version; s=default; bh=pS0HKmtoVpRGbV29NDeBRA3E Pzg=; b=vkShtCRKQ6f4iLP/2lFkevbiUQ73QMerDfKvJpNkVKgIviYGWx/BUmHv FJOAh3sAots9etI4FAA60DWNsHle/FXDFvx0BRu1CCUnpfPLvKbLN4lJOZRtZ8p6 BVdrBP1crYFu+t9Kgw9I+p/JkzSMihcH6Fb6kbgOyKugdmc6LRk= Received: (qmail 3557 invoked by alias); 19 May 2014 19:29:54 -0000 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 Received: (qmail 3535 invoked by uid 89); 19 May 2014 19:29:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 May 2014 19:29:50 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4JJTm5A017214 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 May 2014 15:29:48 -0400 Received: from [10.36.116.47] (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4JJTjvx027413; Mon, 19 May 2014 15:29:45 -0400 Subject: Ping4: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration. From: Mark Wielaard To: Jason Merrill Cc: Jakub Jelinek , Cary Coutant , Tom Tromey , gcc-patches , Richard Henderson In-Reply-To: <20140513072108.GA11487@toonder.wildebeest.org> References: <87ha61qiug.fsf@fleche.redhat.com> <1397202952.8924.1.camel@bordewijk.wildebeest.org> <1397510343.5633.44.camel@bordewijk.wildebeest.org> <1398162670.29199.127.camel@bordewijk.wildebeest.org> <1398683852.4016.30.camel@bordewijk.wildebeest.org> <20140428122313.GE1817@tucnak.redhat.com> <1398688641.4016.35.camel@bordewijk.wildebeest.org> <53718FE3.9090108@redhat.com> <20140513072108.GA11487@toonder.wildebeest.org> Date: Mon, 19 May 2014 21:29:45 +0200 Message-ID: <1400527785.4005.133.camel@bordewijk.wildebeest.org> Mime-Version: 1.0 Rebased patch to current master attached. DWARF parts approved by Cary Coutant, GDB already contains Tom Tromey's code to take advantage of the new information. Earlier discussions: https://gcc.gnu.org/ml/gcc-patches/2014-04/msg00713.html https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01859.html https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00922.html If there are any unanswered questions that might help getting this reviewed, please let me know. commit aa9d60cddb82d009055262b98aff97f395d73ba9 Author: Mark Wielaard Date: Sun Mar 23 12:05:16 2014 +0100 PR debug/16063. Add DW_AT_type to DW_TAG_enumeration. Add a new lang-hook that provides the underlying base type of an ENUMERAL_TYPE. Including implementations for C and C++. Use this enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type base type reference to a DW_TAG_enumeration. gcc/ * dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if enum_underlying_base_type defined and DWARF version > 3. * langhooks.h (struct lang_hooks_for_types): Add enum_underlying_base_type. * langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define. (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook. gcc/c-family/ * c-common.c (c_enum_underlying_base_type): New function. * c-common.h (c_enum_underlying_base_type): Add declaration. gcc/c/ * c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define. gcc/cp/ * cp-lang.c (cxx_enum_underlying_base_type): New function. (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c69a30c..c368854 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2014-03-21 Mark Wielaard + + PR debug/16063 + * dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if + enum_underlying_base_type defined and DWARF version > 3. + * langhooks.h (struct lang_hooks_for_types): Add + enum_underlying_base_type. + * langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define. + (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook. + 2014-05-19 Richard Biener PR tree-optimization/61184 diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index c88cf59..6ff8466 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2014-03-21 Mark Wielaard + + PR debug/16063 + * c-common.c (c_enum_underlying_base_type): New function. + * c-common.h (c_enum_underlying_base_type): Add declaration. + 2014-05-17 Trevor Saunders * c-common.h (sorted_fields_type): Remove variable_size GTY attribute. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index a120b5c..fdc02b4 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -3921,6 +3921,14 @@ c_register_builtin_type (tree type, const char* name) registered_builtin_types = tree_cons (0, type, registered_builtin_types); } + +/* The C version of the enum_underlying_base_type langhook. */ +tree +c_enum_underlying_base_type (const_tree type) +{ + return c_common_type_for_size (TYPE_PRECISION (type), TYPE_UNSIGNED (type)); +} + /* Print an error message for invalid operands to arith operation CODE with TYPE0 for operand 0, and TYPE1 for operand 1. diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 59e809a..478d8cb 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -833,6 +833,7 @@ extern void c_common_finish (void); extern void c_common_parse_file (void); extern alias_set_type c_common_get_alias_set (tree); extern void c_register_builtin_type (tree, const char*); +extern tree c_enum_underlying_base_type (const_tree); extern bool c_promoting_integer_type_p (const_tree); extern int self_promoting_args_p (const_tree); extern tree strip_pointer_operator (tree); diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 1266d4e..431490d 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2014-03-21 Mark Wielaard + + PR debug/16063 + * c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define. + 2014-05-17 Trevor Saunders * c-decl.c (finish_struct): Adjust. diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h index 92cf60f..0651db7 100644 --- a/gcc/c/c-objc-common.h +++ b/gcc/c/c-objc-common.h @@ -84,6 +84,8 @@ along with GCC; see the file COPYING3. If not see #define LANG_HOOKS_TO_TARGET_CHARSET c_common_to_target_charset #undef LANG_HOOKS_EXPR_TO_DECL #define LANG_HOOKS_EXPR_TO_DECL c_expr_to_decl +#undef LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE +#define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE c_enum_underlying_base_type /* The C front end's scoping structure is very different from that expected by the language-independent code; it is best diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b5ad1af..fb82778 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-03-21 Mark Wielaard + + PR debug/16063 + * cp-lang.c (cxx_enum_underlying_base_type): New function. + (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define. + 2014-05-17 Trevor Saunders * class.c (sorted_fields_type_new): Adjust. diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c index c28c07a..6a40d29 100644 --- a/gcc/cp/cp-lang.c +++ b/gcc/cp/cp-lang.c @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "tm.h" #include "tree.h" +#include "stor-layout.h" #include "cp-tree.h" #include "c-family/c-common.h" #include "langhooks.h" @@ -40,6 +41,7 @@ static enum classify_record cp_classify_record (tree type); static tree cp_eh_personality (void); static tree get_template_innermost_arguments_folded (const_tree); static tree get_template_argument_pack_elems_folded (const_tree); +static tree cxx_enum_underlying_base_type (const_tree); /* Lang hooks common to C++ and ObjC++ are declared in cp/cp-objcp-common.h; consequently, there should be very few hooks below. */ @@ -81,6 +83,8 @@ static tree get_template_argument_pack_elems_folded (const_tree); #define LANG_HOOKS_EH_PERSONALITY cp_eh_personality #undef LANG_HOOKS_EH_RUNTIME_TYPE #define LANG_HOOKS_EH_RUNTIME_TYPE build_eh_type_type +#undef LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE +#define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE cxx_enum_underlying_base_type /* Each front end provides its own lang hook initializer. */ struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; @@ -219,5 +223,19 @@ get_template_argument_pack_elems_folded (const_tree t) return fold_cplus_constants (get_template_argument_pack_elems (t)); } +/* The C++ version of the enum_underlying_base_type langhook. + See also cp/semantics.c (finish_underlying_type). */ +static tree cxx_enum_underlying_base_type (const_tree type) +{ + tree underlying_type = ENUM_UNDERLYING_TYPE (type); + + if (! ENUM_FIXED_UNDERLYING_TYPE_P (type)) + underlying_type + = c_common_type_for_mode (TYPE_MODE (underlying_type), + TYPE_UNSIGNED (underlying_type)); + + return underlying_type; +} + #include "gt-cp-cp-lang.h" #include "gtype-cp.h" diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 4ea05a5..2d5546a 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -17537,6 +17537,12 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die) TREE_ASM_WRITTEN (type) = 1; add_byte_size_attribute (type_die, type); + if (lang_hooks.types.enum_underlying_base_type != NULL + && (dwarf_version >= 3 || !dwarf_strict)) + { + tree underlying = lang_hooks.types.enum_underlying_base_type (type); + add_type_attribute (type_die, underlying, 0, 0, context_die); + } if (TYPE_STUB_DECL (type) != NULL_TREE) { add_src_coords_attributes (type_die, TYPE_STUB_DECL (type)); diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index 95bd379..b8e0d97 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -173,6 +173,7 @@ extern tree lhd_make_node (enum tree_code); #define LANG_HOOKS_GET_SUBRANGE_BOUNDS NULL #define LANG_HOOKS_DESCRIPTIVE_TYPE NULL #define LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE reconstruct_complex_type +#define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE NULL #define LANG_HOOKS_FOR_TYPES_INITIALIZER { \ LANG_HOOKS_MAKE_TYPE, \ @@ -191,7 +192,8 @@ extern tree lhd_make_node (enum tree_code); LANG_HOOKS_GET_ARRAY_DESCR_INFO, \ LANG_HOOKS_GET_SUBRANGE_BOUNDS, \ LANG_HOOKS_DESCRIPTIVE_TYPE, \ - LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE \ + LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE, \ + LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE \ } /* Declaration hooks. */ diff --git a/gcc/langhooks.h b/gcc/langhooks.h index c848b0c..667298b 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -137,6 +137,8 @@ struct lang_hooks_for_types return values from functions. The argument TYPE is the top of the chain, and BOTTOM is the new type which we will point to. */ tree (*reconstruct_complex_type) (tree, tree); + + tree (*enum_underlying_base_type) (const_tree); }; /* Language hooks related to decls and the symbol table. */