re PR c++/49092 (ice in tree_add_const_value_attribute)
authorJason Merrill <jason@redhat.com>
Sun, 22 May 2011 04:40:55 +0000 (00:40 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 22 May 2011 04:40:55 +0000 (00:40 -0400)
PR c++/49092
* dwarf2out.c (tree_add_const_value_attribute_for_decl): Check for
static storage duration.

From-SVN: r174024

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/const5.C [new file with mode: 0644]

index 80233d7eff9517f6073ef188cc9cc0f94d46cb25..789f258da3984e42bb2f3f653f6002c1c6a70cef 100644 (file)
@@ -1,3 +1,9 @@
+2011-05-21  Jason Merrill  <jason@redhat.com>
+
+       PR c++/49092
+       * dwarf2out.c (tree_add_const_value_attribute_for_decl): Check for
+       static storage duration.
+
 2011-05-21  Eric Botcazou  <ebotcazou@adacore.com>
 
        * config/sparc/sparc.md (setjmp): Handle PIC mode and use the hard
index b85a55ec67c9ec8e93b5a7821172782cd0483f0c..55453a3622c98ea631fc0adc4dbbc81d09bfce0f 100644 (file)
@@ -17719,7 +17719,9 @@ tree_add_const_value_attribute_for_decl (dw_die_ref var_die, tree decl)
 
   if (!decl
       || (TREE_CODE (decl) != VAR_DECL
-         && TREE_CODE (decl) != CONST_DECL))
+         && TREE_CODE (decl) != CONST_DECL)
+      || (TREE_CODE (decl) == VAR_DECL
+         && !TREE_STATIC (decl)))
     return false;
 
     if (TREE_READONLY (decl)
index 61afdb00e2e02840c603fe3ae3783c60da1b4102..ccc34a7bae35dae4fb007cbaa00ed3b9e1adee92 100644 (file)
@@ -1,3 +1,7 @@
+2011-05-21  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/debug/const5.C: New.
+
 2011-05-20  Jason Merrill  <jason@redhat.com>
 
        * g++.dg/cpp0x/constexpr-static7.C: Extend.
diff --git a/gcc/testsuite/g++.dg/debug/const5.C b/gcc/testsuite/g++.dg/debug/const5.C
new file mode 100644 (file)
index 0000000..e5387ea
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/49092
+
+struct A
+{
+  A();
+};
+
+int i;
+
+A::A()
+{
+  const int j = i;
+}