OSDN Git Service

2012-05-03 Martin Jambor <mjambor@suse.cz>
authorjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 May 2012 17:00:32 +0000 (17:00 +0000)
committerjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 May 2012 17:00:32 +0000 (17:00 +0000)
PR lto/52605
* dwarf2out.c (dwarf2out_decl): Only lookup die representing context
of a variable when the contect is a function.

* gcc/testsuite/g++.dg/lto/pr52605_0.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@187109 138bc75d-0d04-0410-961f-82ee72b054a4

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

index e99e3d6..8efd672 100644 (file)
@@ -1,3 +1,12 @@
+2012-05-04  Martin Jambor  <mjambor@suse.cz>
+
+       Backport from mainline
+       2012-05-02  Martin Jambor  <mjambor@suse.cz>
+
+       PR lto/52605
+       * dwarf2out.c (dwarf2out_decl): Only lookup die representing context
+       of a variable when the contect is a function.
+
 2012-05-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR plugins/53126
index 63c46c0..109ede0 100644 (file)
@@ -19889,7 +19889,9 @@ dwarf2out_decl (tree decl)
        return;
 
       /* For local statics lookup proper context die.  */
-      if (TREE_STATIC (decl) && decl_function_context (decl))
+      if (TREE_STATIC (decl)
+         && DECL_CONTEXT (decl)
+         && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)
        context_die = lookup_decl_die (DECL_CONTEXT (decl));
 
       /* If we are in terse mode, don't generate any DIEs to represent any
index 0451651..bb66b56 100644 (file)
@@ -1,3 +1,11 @@
+2012-05-03  Martin Jambor  <mjambor@suse.cz>
+
+       Backport from mainline
+       2012-05-02  Martin Jambor  <mjambor@suse.cz>
+
+       PR lto/52605
+       * g++.dg/lto/pr52605_0.C: New test.
+
 2012-05-03  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/53186
diff --git a/gcc/testsuite/g++.dg/lto/pr52605_0.C b/gcc/testsuite/g++.dg/lto/pr52605_0.C
new file mode 100644 (file)
index 0000000..22540ab
--- /dev/null
@@ -0,0 +1,39 @@
+// { dg-lto-do link }
+// { dg-lto-options {{-flto -g}} }
+
+extern "C" void abort (void);
+
+class A
+{
+public:
+  virtual int foo (int i);
+};
+
+int A::foo (int i)
+{
+  return i + 1;
+}
+
+int __attribute__ ((noinline,noclone)) get_input(void)
+{
+  return 1;
+}
+
+int main (int argc, char *argv[])
+{
+
+  class B : public A
+  {
+  public:
+    int bar (int i)
+    {
+      return foo (i) + 2;
+    }
+  };
+  class B b;
+
+  if (b.bar (get_input ()) != 4)
+    abort ();
+  return 0;
+}
+