From: Jakub Jelinek Date: Sat, 29 Jul 2017 07:52:16 +0000 (+0200) Subject: debug.h (struct gcc_debug_hooks): Add IMPLICIT argument to imported_module_or_decl... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e071b7678195f4176938730e348503cddc2a87b4;p=gcc.git debug.h (struct gcc_debug_hooks): Add IMPLICIT argument to imported_module_or_decl hook. * debug.h (struct gcc_debug_hooks): Add IMPLICIT argument to imported_module_or_decl hook. (debug_nothing_tree_tree_tree_bool): Remove. (debug_nothing_tree_tree_tree_bool_bool): New declaration. * debug.c (do_nothing_debug_hooks): Use debug_nothing_tree_tree_tree_bool_bool instead of debug_nothing_tree_tree_tree_bool. * vmsdbgout.c (vmsdbg_debug_hooks): Likewise. * dbxout.c (dbx_debug_hooks, xcoff_debug_hooks): Likewise. * sdbout.c (sdb_debug_hooks): Likewise. * dwarf2out.c (dwarf2_lineno_debug_hooks): Likewise. (gen_namespace_die): Add DW_AT_export_symbols attribute if langhook wants it. (dwarf2out_imported_module_or_decl): Add IMPLICIT argument, if true, -gdwarf-5 and decl will have DW_AT_export_symbols attribute, don't add anything. cp/ * cp-objcp-common.c (cp_decl_dwarf_attribute): Handle DW_AT_export_symbols. * name-lookup.c (emit_debug_info_using_namespace): Add IMPLICIT argument, pass it through to the debug hook. (finish_namespace_using_directive): Adjust emit_debug_info_using_namespace caller. (push_namespace): Likewise. Call it after setting DECL_NAMESPACE_INLINE_P. (cp_emit_debug_info_for_using): Pass false as new argument to the imported_module_or_decl debug hook. fortran/ * trans-decl.c (gfc_trans_use_stmts): Pass false as new argument to the imported_module_or_decl debug hook. ada/ * gcc-interface/utils.c (gnat_write_global_declarations): Pass false as new argument to the imported_module_or_decl debug hook. testsuite/ * g++.dg/debug/dwarf2/inline-ns-1.C: New test. * g++.dg/debug/dwarf2/inline-ns-2.C: New test. From-SVN: r250713 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2aafa710294..ad347ad9754 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,22 @@ +2017-07-29 Jakub Jelinek + + * debug.h (struct gcc_debug_hooks): Add IMPLICIT argument + to imported_module_or_decl hook. + (debug_nothing_tree_tree_tree_bool): Remove. + (debug_nothing_tree_tree_tree_bool_bool): New declaration. + * debug.c (do_nothing_debug_hooks): Use + debug_nothing_tree_tree_tree_bool_bool instead of + debug_nothing_tree_tree_tree_bool. + * vmsdbgout.c (vmsdbg_debug_hooks): Likewise. + * dbxout.c (dbx_debug_hooks, xcoff_debug_hooks): Likewise. + * sdbout.c (sdb_debug_hooks): Likewise. + * dwarf2out.c (dwarf2_lineno_debug_hooks): Likewise. + (gen_namespace_die): Add DW_AT_export_symbols attribute if + langhook wants it. + (dwarf2out_imported_module_or_decl): Add IMPLICIT argument, + if true, -gdwarf-5 and decl will have DW_AT_export_symbols + attribute, don't add anything. + 2017-07-28 Trevor Saunders * fold-const.c (fold_build1_stat_loc): Remove _stat from name. diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 3daed1e1f35..dda51d423b6 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2017-07-29 Jakub Jelinek + + * gcc-interface/utils.c (gnat_write_global_declarations): Pass false + as new argument to the imported_module_or_decl debug hook. + 2017-07-25 Javier Miranda * checks.adb (Apply_Divide_Checks): Ensure that operands are not diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 9e656579dda..475261b3682 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -5553,7 +5553,7 @@ gnat_write_global_declarations (void) FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter) if (TREE_CODE (iter) == IMPORTED_DECL && !DECL_IGNORED_P (iter)) debug_hooks->imported_module_or_decl (iter, DECL_NAME (iter), - DECL_CONTEXT (iter), 0); + DECL_CONTEXT (iter), false, false); } /* ************************************************************************ diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 806235fcd75..3d988a67b77 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,16 @@ +2017-07-29 Jakub Jelinek + + * cp-objcp-common.c (cp_decl_dwarf_attribute): Handle + DW_AT_export_symbols. + * name-lookup.c (emit_debug_info_using_namespace): Add IMPLICIT + argument, pass it through to the debug hook. + (finish_namespace_using_directive): Adjust + emit_debug_info_using_namespace caller. + (push_namespace): Likewise. Call it after setting + DECL_NAMESPACE_INLINE_P. + (cp_emit_debug_info_for_using): Pass false as new argument to + the imported_module_or_decl debug hook. + 2017-07-28 Trevor Saunders * lex.c (copy_decl): Adjust. diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index 5a7da5b4957..4475b6cb911 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -212,6 +212,13 @@ cp_decl_dwarf_attribute (const_tree decl, int attr) } break; + case DW_AT_export_symbols: + if (TREE_CODE (decl) == NAMESPACE_DECL + && (DECL_NAMESPACE_INLINE_P (decl) + || (DECL_NAME (decl) == NULL_TREE && dwarf_version >= 5))) + return 1; + break; + default: break; } diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index cd7428a4ea4..4dc19da6ade 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -6045,11 +6045,12 @@ add_using_namespace (vec *&usings, tree target) /* Tell the debug system of a using directive. */ static void -emit_debug_info_using_namespace (tree from, tree target) +emit_debug_info_using_namespace (tree from, tree target, bool implicit) { /* Emit debugging info. */ tree context = from != global_namespace ? from : NULL_TREE; - debug_hooks->imported_module_or_decl (target, NULL_TREE, context, false); + debug_hooks->imported_module_or_decl (target, NULL_TREE, context, false, + implicit); } /* Process a namespace-scope using directive. */ @@ -6064,7 +6065,7 @@ finish_namespace_using_directive (tree target, tree attribs) add_using_namespace (DECL_NAMESPACE_USING (current_namespace), ORIGINAL_NAMESPACE (target)); emit_debug_info_using_namespace (current_namespace, - ORIGINAL_NAMESPACE (target)); + ORIGINAL_NAMESPACE (target), false); if (attribs == error_mark_node) return; @@ -6223,14 +6224,14 @@ push_namespace (tree name, bool make_inline) else if (TREE_PUBLIC (current_namespace)) TREE_PUBLIC (ns) = 1; - if (name == anon_identifier || make_inline) - emit_debug_info_using_namespace (current_namespace, ns); - if (make_inline) { DECL_NAMESPACE_INLINE_P (ns) = true; vec_safe_push (DECL_NAMESPACE_INLINEES (current_namespace), ns); } + + if (name == anon_identifier || make_inline) + emit_debug_info_using_namespace (current_namespace, ns, true); } } @@ -6358,8 +6359,8 @@ cp_emit_debug_info_for_using (tree t, tree context) if (building_stmt_list_p ()) add_stmt (build_stmt (input_location, USING_STMT, fn)); else - debug_hooks->imported_module_or_decl (fn, - NULL_TREE, context, false); + debug_hooks->imported_module_or_decl (fn, NULL_TREE, context, + false, false); } } } diff --git a/gcc/dbxout.c b/gcc/dbxout.c index b278c6da1d4..3d9268c3d1d 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -371,7 +371,7 @@ const struct gcc_debug_hooks dbx_debug_hooks = dbxout_early_global_decl, /* early_global_decl */ dbxout_late_global_decl, /* late_global_decl */ dbxout_type_decl, /* type_decl */ - debug_nothing_tree_tree_tree_bool, /* imported_module_or_decl */ + debug_nothing_tree_tree_tree_bool_bool,/* imported_module_or_decl */ debug_nothing_tree, /* deferred_inline_function */ debug_nothing_tree, /* outlining_inline_function */ debug_nothing_rtx_code_label, /* label */ @@ -411,7 +411,7 @@ const struct gcc_debug_hooks xcoff_debug_hooks = dbxout_early_global_decl, /* early_global_decl */ dbxout_late_global_decl, /* late_global_decl */ dbxout_type_decl, /* type_decl */ - debug_nothing_tree_tree_tree_bool, /* imported_module_or_decl */ + debug_nothing_tree_tree_tree_bool_bool,/* imported_module_or_decl */ debug_nothing_tree, /* deferred_inline_function */ debug_nothing_tree, /* outlining_inline_function */ debug_nothing_rtx_code_label, /* label */ diff --git a/gcc/debug.c b/gcc/debug.c index 860f1e312b9..d68c30ff2b9 100644 --- a/gcc/debug.c +++ b/gcc/debug.c @@ -47,7 +47,7 @@ const struct gcc_debug_hooks do_nothing_debug_hooks = debug_nothing_tree, /* early_global_decl */ debug_nothing_tree, /* late_global_decl */ debug_nothing_tree_int, /* type_decl */ - debug_nothing_tree_tree_tree_bool, /* imported_module_or_decl */ + debug_nothing_tree_tree_tree_bool_bool,/* imported_module_or_decl */ debug_nothing_tree, /* deferred_inline_function */ debug_nothing_tree, /* outlining_inline_function */ debug_nothing_rtx_code_label, /* label */ @@ -80,10 +80,11 @@ debug_nothing_tree_tree (tree t1 ATTRIBUTE_UNUSED, } void -debug_nothing_tree_tree_tree_bool (tree t1 ATTRIBUTE_UNUSED, - tree t2 ATTRIBUTE_UNUSED, - tree t3 ATTRIBUTE_UNUSED, - bool b1 ATTRIBUTE_UNUSED) +debug_nothing_tree_tree_tree_bool_bool (tree t1 ATTRIBUTE_UNUSED, + tree t2 ATTRIBUTE_UNUSED, + tree t3 ATTRIBUTE_UNUSED, + bool b1 ATTRIBUTE_UNUSED, + bool b2 ATTRIBUTE_UNUSED) { } diff --git a/gcc/debug.h b/gcc/debug.h index 395365861f7..bfb72213631 100644 --- a/gcc/debug.h +++ b/gcc/debug.h @@ -145,7 +145,8 @@ struct gcc_debug_hooks /* Debug information for imported modules and declarations. */ void (* imported_module_or_decl) (tree decl, tree name, - tree context, bool child); + tree context, bool child, + bool implicit); /* DECL is an inline function, whose body is present, but which is not being output at this point. */ @@ -206,7 +207,8 @@ extern void debug_nothing_int_int (unsigned int, unsigned int); extern void debug_nothing_tree (tree); extern void debug_nothing_tree_tree (tree, tree); extern void debug_nothing_tree_int (tree, int); -extern void debug_nothing_tree_tree_tree_bool (tree, tree, tree, bool); +extern void debug_nothing_tree_tree_tree_bool_bool (tree, tree, tree, + bool, bool); extern bool debug_true_const_tree (const_tree); extern void debug_nothing_rtx_insn (rtx_insn *); extern void debug_nothing_rtx_code_label (rtx_code_label *); diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 5231683ee9e..4a3b3c1d0f4 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -2680,7 +2680,7 @@ static bool dwarf2out_ignore_block (const_tree); static void dwarf2out_early_global_decl (tree); static void dwarf2out_late_global_decl (tree); static void dwarf2out_type_decl (tree, int); -static void dwarf2out_imported_module_or_decl (tree, tree, tree, bool); +static void dwarf2out_imported_module_or_decl (tree, tree, tree, bool, bool); static void dwarf2out_imported_module_or_decl_1 (tree, tree, tree, dw_die_ref); static void dwarf2out_abstract_function (tree); @@ -2764,7 +2764,7 @@ const struct gcc_debug_hooks dwarf2_lineno_debug_hooks = debug_nothing_tree, /* early_global_decl */ debug_nothing_tree, /* late_global_decl */ debug_nothing_tree_int, /* type_decl */ - debug_nothing_tree_tree_tree_bool, /* imported_module_or_decl */ + debug_nothing_tree_tree_tree_bool_bool,/* imported_module_or_decl */ debug_nothing_tree, /* deferred_inline_function */ debug_nothing_tree, /* outlining_inline_function */ debug_nothing_rtx_code_label, /* label */ @@ -25166,6 +25166,11 @@ gen_namespace_die (tree decl, dw_die_ref context_die) add_AT_die_ref (namespace_die, DW_AT_import, origin_die); equate_decl_number_to_die (decl, namespace_die); } + if ((dwarf_version >= 5 || !dwarf_strict) + && lang_hooks.decls.decl_dwarf_attribute (decl, + DW_AT_export_symbols) == 1) + add_AT_flag (namespace_die, DW_AT_export_symbols, 1); + /* Bypass dwarf2_name's check for DECL_NAMELESS. */ if (want_pubnames ()) add_pubname_string (lang_hooks.dwarf_name (decl, 1), namespace_die); @@ -25579,11 +25584,13 @@ dwarf2out_imported_module_or_decl_1 (tree decl, /* Output debug information for imported module or decl DECL. NAME is non-NULL name in context if the decl has been renamed. CHILD is true if decl is one of the renamed decls as part of - importing whole module. */ + importing whole module. + IMPLICIT is set if this hook is called for an implicit import + such as inline namespace. */ static void dwarf2out_imported_module_or_decl (tree decl, tree name, tree context, - bool child) + bool child, bool implicit) { /* dw_die_ref at_import_die; */ dw_die_ref scope_die; @@ -25593,6 +25600,16 @@ dwarf2out_imported_module_or_decl (tree decl, tree name, tree context, gcc_assert (decl); + /* For DWARF5, just DW_AT_export_symbols on the DW_TAG_namespace + should be enough, for DWARF4 and older even if we emit as extension + DW_AT_export_symbols add the implicit DW_TAG_imported_module anyway + for the benefit of consumers unaware of DW_AT_export_symbols. */ + if (implicit + && dwarf_version >= 5 + && lang_hooks.decls.decl_dwarf_attribute (decl, + DW_AT_export_symbols) == 1) + return; + set_early_dwarf s; /* To emit DW_TAG_imported_module or DW_TAG_imported_decl, we need two DIEs. diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2b9aba6d8f7..81b220ad776 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2017-07-29 Jakub Jelinek + + * trans-decl.c (gfc_trans_use_stmts): Pass false as new argument to + the imported_module_or_decl debug hook. + 2017-07-28 Trevor Saunders * resolve.c (find_reachable_labels): Adjust. diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index b2f73b78466..74d860689ee 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -4875,7 +4875,7 @@ gfc_trans_use_stmts (gfc_namespace * ns) (*debug_hooks->imported_module_or_decl) (entry->namespace_decl, NULL_TREE, ns->proc_name->backend_decl, - false); + false, false); for (rent = use_stmt->rename; rent; rent = rent->next) { tree decl, local_name; @@ -4952,7 +4952,8 @@ gfc_trans_use_stmts (gfc_namespace * ns) gfc_set_backend_locus (&rent->where); (*debug_hooks->imported_module_or_decl) (decl, local_name, ns->proc_name->backend_decl, - !use_stmt->only_flag); + !use_stmt->only_flag, + false); } } } diff --git a/gcc/sdbout.c b/gcc/sdbout.c index 84798ac9fb3..a67f9d64cb1 100644 --- a/gcc/sdbout.c +++ b/gcc/sdbout.c @@ -301,7 +301,7 @@ const struct gcc_debug_hooks sdb_debug_hooks = sdbout_early_global_decl, /* early_global_decl */ sdbout_late_global_decl, /* late_global_decl */ sdbout_symbol, /* type_decl */ - debug_nothing_tree_tree_tree_bool, /* imported_module_or_decl */ + debug_nothing_tree_tree_tree_bool_bool,/* imported_module_or_decl */ debug_nothing_tree, /* deferred_inline_function */ debug_nothing_tree, /* outlining_inline_function */ sdbout_label, /* label */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d2682dc7094..8e83a732a5f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-07-29 Jakub Jelinek + + * g++.dg/debug/dwarf2/inline-ns-1.C: New test. + * g++.dg/debug/dwarf2/inline-ns-2.C: New test. + 2017-07-28 Peter Bergner * gcc.target/powerpc/cpu-builtin-1.c (darn, scv): Add tests. diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/inline-ns-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/inline-ns-1.C new file mode 100644 index 00000000000..cae380a21eb --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/inline-ns-1.C @@ -0,0 +1,23 @@ +// { dg-options "-O2 -gdwarf-4 -dA -gno-strict-dwarf" } +// { dg-final { scan-assembler-times " DW_AT_export_symbols" 1 } } +// { dg-final { scan-assembler-times "DIE \\(\[^\n\r\]*\\) DW_TAG_imported_module" 2 } } + +namespace A +{ + int i = 5; + inline namespace B + { + int j = 6; + namespace C + { + int k = 7; + }; + }; +}; +int l = A::i + A::j + A::C::k; +int m = A::i + A::B::j + A::B::C::k; +namespace +{ + int n = 8; +}; +int o = n; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/inline-ns-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/inline-ns-2.C new file mode 100644 index 00000000000..4d9aed7e219 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/inline-ns-2.C @@ -0,0 +1,23 @@ +// { dg-options "-O2 -gdwarf-5 -dA" } +// { dg-final { scan-assembler-times " DW_AT_export_symbols" 2 } } +// { dg-final { scan-assembler-not "DIE \\(\[^\n\r\]*\\) DW_TAG_imported_module" } } + +namespace A +{ + int i = 5; + inline namespace B + { + int j = 6; + namespace C + { + int k = 7; + }; + }; +}; +int l = A::i + A::j + A::C::k; +int m = A::i + A::B::j + A::B::C::k; +namespace +{ + int n = 8; +}; +int o = n; diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c index 41928a400a9..42300e2d538 100644 --- a/gcc/vmsdbgout.c +++ b/gcc/vmsdbgout.c @@ -197,7 +197,7 @@ const struct gcc_debug_hooks vmsdbg_debug_hooks vmsdbgout_early_global_decl, vmsdbgout_late_global_decl, vmsdbgout_type_decl, /* type_decl */ - debug_nothing_tree_tree_tree_bool, /* imported_module_or_decl */ + debug_nothing_tree_tree_tree_bool_bool, /* imported_module_or_decl */ debug_nothing_tree, /* deferred_inline_function */ vmsdbgout_abstract_function, debug_nothing_rtx_code_label, /* label */