From 7315daa68164ae36b4f50df35aab44ccdcb52f10 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 21 May 2014 15:44:59 +0000 Subject: 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. The default implementation will just use type_for_size. The implementation for C++ will use the ENUM_UNDERLYING_TYPE if it exists. 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 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. gcc/cp/ * cp-lang.c (cxx_enum_underlying_base_type): New function. (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define. From-SVN: r210717 --- gcc/langhooks.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/langhooks.c') 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)); +} -- cgit v1.1