From 2b4029550fba3d7d2c413e285eab58c3a5e40f55 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Sun, 24 Jul 2005 16:33:53 +0000 Subject: [PATCH] dwarf2out.c (gen_variable_die): Treat un-emitted COMDAT variables as declarations, rather than definitions. * dwarf2out.c (gen_variable_die): Treat un-emitted COMDAT variables as declarations, rather than definitions. From-SVN: r102335 --- gcc/ChangeLog | 5 +++++ gcc/dwarf2out.c | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ca336b37758..77d07239c69 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2005-07-23 Mark Mitchell + + * dwarf2out.c (gen_variable_die): Treat un-emitted COMDAT + variables as declarations, rather than definitions. + 2005-07-24 Ira Rosen PR tree-optimization/22526 diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index b4be0521861..dd3bd5fb5af 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -11626,6 +11626,25 @@ gen_variable_die (tree decl, dw_die_ref context_die) dw_die_ref old_die = lookup_decl_die (decl); int declaration = (DECL_EXTERNAL (decl) + /* If DECL is COMDAT and has not actually been + emitted, we cannot take its address; there + might end up being no definition anywhere in + the program. For example, consider the C++ + test case: + + template + struct S { static const int i = 7; }; + + template + const int S::i; + + int f() { return S::i; } + + Here, S::i is not DECL_EXTERNAL, but no + definition is required, so the compiler will + not emit a definition. */ + || (TREE_CODE (decl) == VAR_DECL + && DECL_COMDAT (decl) && !TREE_ASM_WRITTEN (decl)) || class_or_namespace_scope_p (context_die)); if (origin != NULL)