aboutsummaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.c
diff options
context:
space:
mode:
authorPierre-Marie de Rodat <derodat@adacore.com>2016-10-12 08:29:01 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2016-10-12 08:29:01 +0000
commitc0dbd22d2eebf14210473be5c37da77083dbbf5f (patch)
treec5f5321659839c89f2291ef5a48899111d8d7548 /gcc/dwarf2out.c
parent7d7f92889b79484dc5e13f63e396a9f540b6206a (diff)
downloadgcc-c0dbd22d2eebf14210473be5c37da77083dbbf5f.zip
gcc-c0dbd22d2eebf14210473be5c37da77083dbbf5f.tar.gz
gcc-c0dbd22d2eebf14210473be5c37da77083dbbf5f.tar.bz2
DWARF: fix scoping for descriptions of local types
In Ada, it is possible to have nested subprograms in the following configuration: procedure Parent is type T; [...] procedure Child (Value : T) is begin [...] end Child; begin [...] end Parent; As we currently generate debugging information for Child first before Parent, the debug info for T appears in global scope since the DIE for Parent does not exist yet. This patch makes sure that when we generate early debug info for a nested function, we trigger generation for the parent function first. gcc/ * dwarf2out.c (dwarf2out_early_global_decl): For nested functions, call dwarf2out_decl on the parent function first. gcc/testsuite/ * gnat.dg/debug9.adb: New testcase. From-SVN: r241023
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r--gcc/dwarf2out.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 3f7833f..f03e9aa 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -23902,6 +23902,16 @@ dwarf2out_early_global_decl (tree decl)
if (!DECL_STRUCT_FUNCTION (decl))
goto early_decl_exit;
+ /* For nested functions, emit DIEs for the parents first so that all
+ nested DIEs are generated at the proper scope in the first
+ shot. */
+ tree context = decl_function_context (decl);
+ if (context != NULL)
+ {
+ current_function_decl = context;
+ dwarf2out_decl (context);
+ }
+
current_function_decl = decl;
}
dwarf2out_decl (decl);