From d282264edf36116d5c55d0da59a612468608d9ca Mon Sep 17 00:00:00 2001 From: Martin Jambor Date: Wed, 2 May 2012 21:50:37 +0200 Subject: [PATCH] re PR lto/52605 (LTO -g ICE when looking up context of VMTs of classes defined within functions) 2012-05-02 Martin Jambor 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. From-SVN: r187063 --- gcc/ChangeLog | 6 +++++ gcc/dwarf2out.c | 4 ++- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/lto/pr52605_0.C | 39 ++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/lto/pr52605_0.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7611f01ad35..8367cb6af25 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-05-02 Martin Jambor + + PR lto/52605 + * dwarf2out.c (dwarf2out_decl): Only lookup die representing context + of a variable when the contect is a function. + 2012-05-02 Michael Matz * coretypes.h (gimple_seq, const_gimple_seq): Typedef as gimple. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 8bbf95477a7..10a53894f63 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -19122,7 +19122,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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c447969966b..4f831b1cecf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-05-02 Martin Jambor + + PR lto/52605 + * g++.dg/lto/pr52605_0.C: New test. + 2012-05-02 Kirill Yukhin * gcc.target/i386/hle-cmpxchg-acq-1.c: New. diff --git a/gcc/testsuite/g++.dg/lto/pr52605_0.C b/gcc/testsuite/g++.dg/lto/pr52605_0.C new file mode 100644 index 00000000000..22540abf9e4 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr52605_0.C @@ -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; +} + -- 2.30.2