diff options
author | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-11-03 22:18:49 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-11-03 22:18:49 +0100 |
commit | 6905c577d1c41317205f16ea137844f825a9af71 (patch) | |
tree | cc3fb0f31847cda7c470c5f67f99330aa7943907 /gcc/cp | |
parent | 1906d6b4dc4cf6bddb82e9dc3534438230030a8e (diff) | |
download | gcc-6905c577d1c41317205f16ea137844f825a9af71.zip gcc-6905c577d1c41317205f16ea137844f825a9af71.tar.gz gcc-6905c577d1c41317205f16ea137844f825a9af71.tar.bz2 |
re PR debug/28767 (GCC should output DW_TAG_ptr_to_member for member functions)
PR debug/28767
PR debug/56974
* langhooks.h (struct lang_hooks_for_types): Add type_dwarf_attribute
langhook.
* langhooks.c (lhd_type_dwarf_attribute): New function.
* langhooks-def.h (lhd_type_dwarf_attribute): Declare.
(LANG_HOOKS_TYPE_DWARF_ATTRIBUTE): Define.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add
LANG_HOOKS_TYPE_DWARF_ATTRIBUTE.
(check_qualified_type, check_aligned_type): Call it.
* dwarf2out.c (modified_type_die): Don't use type_main_variant
for FUNCTION_TYPE or METHOD_TYPE, instead walk over variants with
check_base_type and check_lang_type.
(gen_ptr_to_mbr_type_die): If lookup_type_die is already non-NULL,
return early. For pointer-to-data-member add DW_AT_use_location
attribute.
(gen_subroutine_type_die): Add DW_AT_{,rvalue_}reference attribute
if needed.
(gen_type_die_with_usage): Don't use type_main_variant
for FUNCTION_TYPE or METHOD_TYPE, instead walk over variants with
check_base_type and check_lang_type. Formatting fixes. Call
get_debug_type langhook.
cp/
* tree.c (cp_check_qualified_type): Use check_base_type and
TYPE_QUALS comparison instead of check_qualified_type.
(cxx_type_hash_eq): Return false if type_memfn_rqual don't match.
* cp-objcp-common.c (cp_get_debug_type): New function.
(cp_decl_dwarf_attribute): Don't handle types here.
(cp_type_dwarf_attribute): New function.
* cp-objcp-common.h (cp_get_debug_type, cp_type_dwarf_attribute):
Declare.
(LANG_HOOKS_GET_DEBUG_TYPE, LANG_HOOKS_TYPE_DWARF_ATTRIBUTE):
Define.
testsuite/
* g++.dg/debug/dwarf2/ptrdmem-1.C: New test.
* g++.dg/debug/dwarf2/ref-3.C: New test.
* g++.dg/debug/dwarf2/ref-4.C: New test.
* g++.dg/debug/dwarf2/refqual-1.C: New test.
* g++.dg/debug/dwarf2/refqual-2.C: New test.
From-SVN: r241832
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 17 | ||||
-rw-r--r-- | gcc/cp/cp-objcp-common.c | 56 | ||||
-rw-r--r-- | gcc/cp/cp-objcp-common.h | 8 |
3 files changed, 70 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c60c81d..d20453b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,20 @@ +2016-11-03 Jakub Jelinek <jakub@redhat.com> + Alexandre Oliva <aoliva@redhat.com> + Jason Merrill <jason@redhat.com> + + PR debug/28767 + PR debug/56974 + * tree.c (cp_check_qualified_type): Use check_base_type and + TYPE_QUALS comparison instead of check_qualified_type. + (cxx_type_hash_eq): Return false if type_memfn_rqual don't match. + * cp-objcp-common.c (cp_get_debug_type): New function. + (cp_decl_dwarf_attribute): Don't handle types here. + (cp_type_dwarf_attribute): New function. + * cp-objcp-common.h (cp_get_debug_type, cp_type_dwarf_attribute): + Declare. + (LANG_HOOKS_GET_DEBUG_TYPE, LANG_HOOKS_TYPE_DWARF_ATTRIBUTE): + Define. + 2016-11-03 Jason Merrill <jason@redhat.com> * tree.c (cp_check_qualified_type): Call check_base_type instead diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index c6f0873..633831c 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -131,6 +131,19 @@ cxx_types_compatible_p (tree x, tree y) return same_type_ignoring_top_level_qualifiers_p (x, y); } +/* Return a type to use in the debug info instead of TYPE, or NULL_TREE to + keep TYPE. */ + +tree +cp_get_debug_type (const_tree type) +{ + if (TYPE_PTRMEMFUNC_P (type) && !typedef_variant_p (type)) + return build_offset_type (TYPE_PTRMEMFUNC_OBJECT_TYPE (type), + TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type))); + + return NULL_TREE; +} + /* Return -1 if dwarf ATTR shouldn't be added for DECL, or the attribute value otherwise. */ int @@ -179,11 +192,6 @@ cp_decl_dwarf_attribute (const_tree decl, int attr) && FUNCTION_REF_QUALIFIED (TREE_TYPE (decl)) && !FUNCTION_RVALUE_QUALIFIED (TREE_TYPE (decl))) return 1; - if ((TREE_CODE (decl) == FUNCTION_TYPE - || TREE_CODE (decl) == METHOD_TYPE) - && FUNCTION_REF_QUALIFIED (decl) - && !FUNCTION_RVALUE_QUALIFIED (decl)) - return 1; break; case DW_AT_rvalue_reference: @@ -192,11 +200,6 @@ cp_decl_dwarf_attribute (const_tree decl, int attr) && FUNCTION_REF_QUALIFIED (TREE_TYPE (decl)) && FUNCTION_RVALUE_QUALIFIED (TREE_TYPE (decl))) return 1; - if ((TREE_CODE (decl) == FUNCTION_TYPE - || TREE_CODE (decl) == METHOD_TYPE) - && FUNCTION_REF_QUALIFIED (decl) - && FUNCTION_RVALUE_QUALIFIED (decl)) - return 1; break; case DW_AT_inline: @@ -216,6 +219,39 @@ cp_decl_dwarf_attribute (const_tree decl, int attr) return -1; } +/* Return -1 if dwarf ATTR shouldn't be added for TYPE, or the attribute + value otherwise. */ +int +cp_type_dwarf_attribute (const_tree type, int attr) +{ + if (type == NULL_TREE) + return -1; + + switch (attr) + { + case DW_AT_reference: + if ((TREE_CODE (type) == FUNCTION_TYPE + || TREE_CODE (type) == METHOD_TYPE) + && FUNCTION_REF_QUALIFIED (type) + && !FUNCTION_RVALUE_QUALIFIED (type)) + return 1; + break; + + case DW_AT_rvalue_reference: + if ((TREE_CODE (type) == FUNCTION_TYPE + || TREE_CODE (type) == METHOD_TYPE) + && FUNCTION_REF_QUALIFIED (type) + && FUNCTION_RVALUE_QUALIFIED (type)) + return 1; + break; + + default: + break; + } + + return -1; +} + /* Stubs to keep c-opts.c happy. */ void push_file_scope (void) diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h index 9dd847e..65ac95c 100644 --- a/gcc/cp/cp-objcp-common.h +++ b/gcc/cp/cp-objcp-common.h @@ -21,12 +21,14 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_CP_OBJCP_COMMON #define GCC_CP_OBJCP_COMMON -/* In cp/cp-lang.c and objcp/objcp-lang.c. */ +/* In cp/objcp-common.c, cp/cp-lang.c and objcp/objcp-lang.c. */ +extern tree cp_get_debug_type (const_tree); extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t, tree, bool); extern int cp_decl_dwarf_attribute (const_tree, int); +extern int cp_type_dwarf_attribute (const_tree, int); extern void cp_common_init_ts (void); /* Lang hooks that are shared between C++ and ObjC++ are defined here. Hooks @@ -125,12 +127,16 @@ extern void cp_common_init_ts (void); #define LANG_HOOKS_REGISTER_BUILTIN_TYPE c_register_builtin_type #undef LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE #define LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE cp_reconstruct_complex_type +#undef LANG_HOOKS_GET_DEBUG_TYPE +#define LANG_HOOKS_GET_DEBUG_TYPE cp_get_debug_type #undef LANG_HOOKS_TO_TARGET_CHARSET #define LANG_HOOKS_TO_TARGET_CHARSET c_common_to_target_charset #undef LANG_HOOKS_GIMPLIFY_EXPR #define LANG_HOOKS_GIMPLIFY_EXPR cp_gimplify_expr #undef LANG_HOOKS_DECL_DWARF_ATTRIBUTE #define LANG_HOOKS_DECL_DWARF_ATTRIBUTE cp_decl_dwarf_attribute +#undef LANG_HOOKS_TYPE_DWARF_ATTRIBUTE +#define LANG_HOOKS_TYPE_DWARF_ATTRIBUTE cp_type_dwarf_attribute #undef LANG_HOOKS_OMP_PREDETERMINED_SHARING #define LANG_HOOKS_OMP_PREDETERMINED_SHARING cxx_omp_predetermined_sharing #undef LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR |