dwarf2out.c (gen_variable_die): Treat un-emitted COMDAT variables as declarations...
authorMark Mitchell <mark@codesourcery.com>
Sun, 24 Jul 2005 16:33:53 +0000 (16:33 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 24 Jul 2005 16:33:53 +0000 (16:33 +0000)
* dwarf2out.c (gen_variable_die): Treat un-emitted COMDAT
variables as declarations, rather than definitions.

From-SVN: r102335

gcc/ChangeLog
gcc/dwarf2out.c

index ca336b37758ffce814fd9388233a3f671fba3fb0..77d07239c6914e40e1406cb9aecc1427a5d41775 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-23  Mark Mitchell  <mark@codesourcery.com>
+
+       * dwarf2out.c (gen_variable_die): Treat un-emitted COMDAT
+       variables as declarations, rather than definitions.
+
 2005-07-24  Ira Rosen  <irar@il.ibm.com>
 
         PR tree-optimization/22526
index b4be05218619da7cb5df9f9bab6f37ce8ae0ba06..dd3bd5fb5af7d9a1fdc386cfa2d00faa8678ecb1 100644 (file)
@@ -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 <class T>
+                          struct S { static const int i = 7; };
+
+                          template <class T>
+                          const int S<T>::i;
+
+                          int f() { return S<int>::i; }
+                         
+                       Here, S<int>::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)