diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-11-01 19:35:06 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-11-01 19:35:06 +0100 |
commit | 70d288130f1296bebb1dcf30d8585916b7c8c850 (patch) | |
tree | 2920e41a8d3651ef0bff5eaf8128439394b00442 /gcc | |
parent | e592dd625d5ad569561b081a01ff4a6be24693e0 (diff) | |
download | gcc-70d288130f1296bebb1dcf30d8585916b7c8c850.zip gcc-70d288130f1296bebb1dcf30d8585916b7c8c850.tar.gz gcc-70d288130f1296bebb1dcf30d8585916b7c8c850.tar.bz2 |
dwarf2out.c (add_name_and_src_coords_attributes): Add NO_LINKAGE_NAME argument, don't call add_linkage_name if it is true.
* dwarf2out.c (add_name_and_src_coords_attributes): Add NO_LINKAGE_NAME
argument, don't call add_linkage_name if it is true.
(gen_variable_die): For C++ inline static data members, consider the
initial call when old_die is NULL to be declaration and call
add_name_and_src_coords_attributes in that case with true as
NO_LINKAGE_NAME. Add DW_AT_inline attribute if needed.
(gen_member_die): For C++ inline static data members, emit a
definition DIE right away in DW_TAG_compile_unit context.
cp/
* cp-objcp-common.c (cp_decl_dwarf_attribute): Handle DW_AT_inline.
testsuite/
* g++.dg/debug/dwarf2/inline-var-1.C: New test.
From-SVN: r241753
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/cp-objcp-common.c | 10 | ||||
-rw-r--r-- | gcc/dwarf2out.c | 50 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C | 27 |
6 files changed, 101 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 35d9e72..9d162a9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2016-11-01 Jakub Jelinek <jakub@redhat.com> + + * dwarf2out.c (add_name_and_src_coords_attributes): Add NO_LINKAGE_NAME + argument, don't call add_linkage_name if it is true. + (gen_variable_die): For C++ inline static data members, consider the + initial call when old_die is NULL to be declaration and call + add_name_and_src_coords_attributes in that case with true as + NO_LINKAGE_NAME. Add DW_AT_inline attribute if needed. + (gen_member_die): For C++ inline static data members, emit a + definition DIE right away in DW_TAG_compile_unit context. + 2016-11-01 John David Anglin <danglin@gcc.gnu.org> PR target/78166 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f9f34e8..d9ea36b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2016-11-01 Jakub Jelinek <jakub@redhat.com> + + * cp-objcp-common.c (cp_decl_dwarf_attribute): Handle DW_AT_inline. + 2016-11-01 Jason Merrill <jason@redhat.com> * class.c (declared_access): Split out from handle_using_decl. diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index 070b64c..c6f0873 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -199,6 +199,16 @@ cp_decl_dwarf_attribute (const_tree decl, int attr) return 1; break; + case DW_AT_inline: + if (VAR_P (decl) && DECL_INLINE_VAR_P (decl)) + { + if (DECL_VAR_DECLARED_INLINE_P (decl)) + return DW_INL_declared_inlined; + else + return DW_INL_inlined; + } + break; + default: break; } diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 05c9a13..abadc47 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -3511,7 +3511,7 @@ static void add_prototyped_attribute (dw_die_ref, tree); static dw_die_ref add_abstract_origin_attribute (dw_die_ref, tree); static void add_pure_or_virtual_attribute (dw_die_ref, tree); static void add_src_coords_attributes (dw_die_ref, tree); -static void add_name_and_src_coords_attributes (dw_die_ref, tree); +static void add_name_and_src_coords_attributes (dw_die_ref, tree, bool = false); static void add_discr_value (dw_die_ref, dw_discr_value *); static void add_discr_list (dw_die_ref, dw_discr_list_ref); static inline dw_discr_list_ref AT_discr_list (dw_attr_node *); @@ -20056,7 +20056,8 @@ add_linkage_name (dw_die_ref die, tree decl) given decl, but only if it actually has a name. */ static void -add_name_and_src_coords_attributes (dw_die_ref die, tree decl) +add_name_and_src_coords_attributes (dw_die_ref die, tree decl, + bool no_linkage_name) { tree decl_name; @@ -20069,7 +20070,8 @@ add_name_and_src_coords_attributes (dw_die_ref die, tree decl) if (! DECL_ARTIFICIAL (decl)) add_src_coords_attributes (die, decl); - add_linkage_name (die, decl); + if (!no_linkage_name) + add_linkage_name (die, decl); } #ifdef VMS_DEBUGGING_INFO @@ -22451,6 +22453,22 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die) bool declaration = (DECL_EXTERNAL (decl_or_origin) || class_or_namespace_scope_p (context_die)); bool specialization_p = false; + bool no_linkage_name = false; + + /* While C++ inline static data members have definitions inside of the + class, force the first DIE to be a declaration, then let gen_member_die + reparent it to the class context and call gen_variable_die again + to create the outside of the class DIE for the definition. */ + if (!declaration + && old_die == NULL + && decl + && DECL_CONTEXT (decl) + && TYPE_P (DECL_CONTEXT (decl)) + && lang_hooks.decls.decl_dwarf_attribute (decl, DW_AT_inline) != -1) + { + declaration = true; + no_linkage_name = true; + } ultimate_origin = decl_ultimate_origin (decl_or_origin); if (decl || ultimate_origin) @@ -22638,7 +22656,7 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die) } } else - add_name_and_src_coords_attributes (var_die, decl); + add_name_and_src_coords_attributes (var_die, decl, no_linkage_name); if ((origin == NULL && !specialization_p) || (origin != NULL @@ -22698,9 +22716,18 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die) && lang_hooks.decls.decl_dwarf_attribute (decl_or_origin, DW_AT_const_expr) == 1 && !get_AT (var_die, DW_AT_const_expr) - && (origin_die == NULL || get_AT (origin_die, DW_AT_const_expr) == NULL) && !specialization_p) add_AT_flag (var_die, DW_AT_const_expr, 1); + + if (!dwarf_strict) + { + int inl = lang_hooks.decls.decl_dwarf_attribute (decl_or_origin, + DW_AT_inline); + if (inl != -1 + && !get_AT (var_die, DW_AT_inline) + && !specialization_p) + add_AT_unsigned (var_die, DW_AT_inline, inl); + } } /* Generate a DIE to represent a named constant. */ @@ -23859,6 +23886,19 @@ gen_member_die (tree type, dw_die_ref context_die) vlr_ctx.variant_part_offset = NULL_TREE; gen_decl_die (member, NULL, &vlr_ctx, context_die); } + + /* For C++ inline static data members emit immediately a DW_TAG_variable + DIE that will refer to that DW_TAG_member through + DW_AT_specification. */ + if (TREE_STATIC (member) + && (lang_hooks.decls.decl_dwarf_attribute (member, DW_AT_inline) + != -1)) + { + int old_extern = DECL_EXTERNAL (member); + DECL_EXTERNAL (member) = 0; + gen_decl_die (member, NULL, NULL, comp_unit_die ()); + DECL_EXTERNAL (member) = old_extern; + } } /* We do not keep type methods in type variants. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 64cfc53..7572f86 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-11-01 Jakub Jelinek <jakub@redhat.com> + + * g++.dg/debug/dwarf2/inline-var-1.C: New test. + 2016-11-01 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/69544 diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C new file mode 100644 index 0000000..da8014c --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/inline-var-1.C @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-O -std=c++1z -g -dA -gno-strict-dwarf" } +// { dg-require-weak "" } +// { dg-final { scan-assembler-times "0x3\[^\n\r]* DW_AT_inline" 6 } } +// { dg-final { scan-assembler-times "0x1\[^\n\r]* DW_AT_inline" 2 } } +// { dg-final { scan-assembler-times " DW_AT_declaration" 6 } } +// { dg-final { scan-assembler-times " DW_AT_specification" 6 } } +// { dg-final { scan-assembler-times " DW_AT_\[^\n\r]*linkage_name" 7 } } + +inline int a; +struct S +{ + static inline double b = 4.0; + static constexpr int c = 2; + static constexpr inline char d = 3; +} s; +template <int N> +inline int e = N; +int &f = e<2>; +template <int N> +struct T +{ + static inline double g = 4.0; + static constexpr int h = 2; + static inline constexpr char i = 3; +}; +T<5> t; |