diff options
-rw-r--r-- | gcc/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/cp-lang.c | 20 | ||||
-rw-r--r-- | gcc/dwarf2out.c | 5 | ||||
-rw-r--r-- | gcc/langhooks-def.h | 5 | ||||
-rw-r--r-- | gcc/langhooks.c | 9 | ||||
-rw-r--r-- | gcc/langhooks.h | 6 |
7 files changed, 64 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d506727..452b4b0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2014-05-21 Mark Wielaard <mjw@redhat.com> + + PR debug/16063 + * dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if DWARF + version >= 3 or not strict DWARF. + * langhooks.h (struct lang_hooks_for_types): Add + enum_underlying_base_type. + * langhooks.c (lhd_enum_underlying_base_type): New function. + * gcc/langhooks.h (struct lang_hooks_for_types): Add + enum_underlying_base_type. + * langhooks-def.h (lhd_enum_underlying_base_type): New declaration. + (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define. + (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook. + 2014-05-21 Richard Biener <rguenther@suse.de> * doc/invoke.texi (-flto-partition=): Document one and diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index adde47f..b0a06b1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-05-21 Mark Wielaard <mjw@redhat.com> + + PR debug/16063 + * cp-lang.c (cxx_enum_underlying_base_type): New function. + (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define. + 2014-05-21 Richard Sandiford <rsandifo@linux.vnet.ibm.com> * cvt.c (convert_to_void): Use void_node instead of void_zero_node. diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c index c28c07a..014f393 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,21 @@ 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..7c93074 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -17537,6 +17537,11 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die) TREE_ASM_WRITTEN (type) = 1; add_byte_size_attribute (type_die, type); + if (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..d9a1dfd 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -60,6 +60,7 @@ extern size_t lhd_tree_size (enum tree_code); extern HOST_WIDE_INT lhd_to_target_charset (HOST_WIDE_INT); extern tree lhd_expr_to_decl (tree, bool *, bool *); extern tree lhd_builtin_function (tree); +extern tree lhd_enum_underlying_base_type (const_tree); /* Declarations of default tree inlining hooks. */ extern void lhd_initialize_diagnostics (diagnostic_context *); @@ -173,6 +174,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 lhd_enum_underlying_base_type #define LANG_HOOKS_FOR_TYPES_INITIALIZER { \ LANG_HOOKS_MAKE_TYPE, \ @@ -191,7 +193,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.c b/gcc/langhooks.c index d00ebd8..8f65c68 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -678,3 +678,12 @@ lhd_end_section (void) saved_section = NULL; } } + +/* Default implementation of enum_underlying_base_type using type_for_size. */ + +tree +lhd_enum_underlying_base_type (const_tree enum_type) +{ + return lang_hooks.types.type_for_size (TYPE_PRECISION (enum_type), + TYPE_UNSIGNED (enum_type)); +} diff --git a/gcc/langhooks.h b/gcc/langhooks.h index c848b0c..35b47bc 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -137,6 +137,12 @@ 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); + + /* Returns the tree that represents the underlying data type used to + implement the enumeration. The default implementation will just use + type_for_size. Used in dwarf2out.c to add a DW_AT_type base type + reference to a DW_TAG_enumeration. */ + tree (*enum_underlying_base_type) (const_tree); }; /* Language hooks related to decls and the symbol table. */ |