Commit 7315daa6 by Mark Wielaard Committed by Mark Wielaard

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
parent ab65e21a
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
......
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.
......
......@@ -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"
......@@ -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));
......
......@@ -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. */
......
......@@ -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));
}
......@@ -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. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment