diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2014-10-25 00:08:41 +0000 |
---|---|---|
committer | Aldy Hernandez <aldyh@gcc.gnu.org> | 2014-10-25 00:08:41 +0000 |
commit | c22354fd692dc2b13290fcf441cbc8722baed83b (patch) | |
tree | d0507f6863be7c344f8fca7819b863e172ba38f7 /gcc | |
parent | fbee6d3164ed509ebe08222264f352fecf1c9824 (diff) | |
download | gcc-c22354fd692dc2b13290fcf441cbc8722baed83b.zip gcc-c22354fd692dc2b13290fcf441cbc8722baed83b.tar.gz gcc-c22354fd692dc2b13290fcf441cbc8722baed83b.tar.bz2 |
dwarf2out.c (declare_in_namespace): Only emit external declarations in the local scope once.
* dwarf2out.c (declare_in_namespace): Only emit external
declarations in the local scope once.
From-SVN: r216683
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/dwarf2out.c | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 145ce9d..bc6908d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-10-24 Aldy Hernandez <aldyh@redhat.com> + + * dwarf2out.c (declare_in_namespace): Only emit external + declarations in the local scope once. + 2014-10-24 Jonathan Wakely <jwakely@redhat.com> * ginclude/stdbool.h: Do not define bool, true or false in C++11. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index a87f9c0..3bce20f 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -20476,6 +20476,26 @@ declare_in_namespace (tree thing, dw_die_ref context_die) if (debug_info_level <= DINFO_LEVEL_TERSE) return context_die; + /* External declarations in the local scope only need to be emitted + once, not once in the namespace and once in the scope. + + This avoids declaring the `extern' below in the + namespace DIE as well as in the innermost scope: + + namespace S + { + int i=5; + int foo() + { + int i=8; + extern int i; + return i; + } + } + */ + if (DECL_P (thing) && DECL_EXTERNAL (thing) && local_scope_p (context_die)) + return context_die; + /* If this decl is from an inlined function, then don't try to emit it in its namespace, as we will get confused. It would have already been emitted when the abstract instance of the inline function was emitted anyways. */ |