From e3b127e818dd591031a9cee6fbccd55c612cd643 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Mon, 11 Jun 2012 14:14:09 +0000 Subject: [PATCH] re PR debug/53470 (ICE when linking with -g in splice_child_die, at dwarf2out.c:4264) 2012-06-11 Richard Guenther PR middle-end/53470 * tree.c (free_lang_data_in_type): Do not clear TYPE_CONTEXT but replace it with the first non-BLOCK context. * g++.dg/lto/pr53470_0.C: New testcase. * gcc.dg/lto/pr53470_0.c: Likewise. From-SVN: r188387 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/lto/pr53470_0.C | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/lto/pr53470_0.c | 9 +++++++++ gcc/tree.c | 16 +++++++++++----- 5 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/lto/pr53470_0.C create mode 100644 gcc/testsuite/gcc.dg/lto/pr53470_0.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d3127b00bb0..fa5a6728c7a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-06-11 Richard Guenther + + PR middle-end/53470 + * tree.c (free_lang_data_in_type): Do not clear TYPE_CONTEXT but + replace it with the first non-BLOCK context. + 2012-06-11 Richard Guenther * alias.c (aliases_everything_p): Remove. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index baa04c04ad2..b57f1713f50 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-06-11 Richard Guenther + + PR middle-end/53470 + * g++.dg/lto/pr53470_0.C: New testcase. + * gcc.dg/lto/pr53470_0.c: Likewise. + 2012-06-11 Richard Guenther PR c++/53616 diff --git a/gcc/testsuite/g++.dg/lto/pr53470_0.C b/gcc/testsuite/g++.dg/lto/pr53470_0.C new file mode 100644 index 00000000000..217c02a482b --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr53470_0.C @@ -0,0 +1,26 @@ +// { dg-lto-do link } +// { dg-lto-options { { -g -flto } } } + +class sp_counted_base; +class shared_count { + sp_counted_base *pi_; +public: + template shared_count(Y) : pi_() {} + ~shared_count() {} +}; +template struct shared_ptr { + T element_type; + template shared_ptr(Y) : pn(0) {} + shared_count pn; +}; +template class ECGetterBase; +template struct ExtensionCord { + struct Holder { + ECGetterBase *getter_; + }; + ExtensionCord() : holder_(new Holder) {} + + shared_ptr holder_; +}; +ExtensionCord a; +int main() {} diff --git a/gcc/testsuite/gcc.dg/lto/pr53470_0.c b/gcc/testsuite/gcc.dg/lto/pr53470_0.c new file mode 100644 index 00000000000..3c799f60cc7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr53470_0.c @@ -0,0 +1,9 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options { { -flto } { -flto -g } } } */ + +int main () +{ + { + union A { } v; + } +} diff --git a/gcc/tree.c b/gcc/tree.c index e180340c12c..d3c2a19d7d6 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -4575,11 +4575,17 @@ free_lang_data_in_type (tree type) free_lang_data_in_one_sizepos (&TYPE_SIZE (type)); free_lang_data_in_one_sizepos (&TYPE_SIZE_UNIT (type)); - if (debug_info_level < DINFO_LEVEL_TERSE - || (TYPE_CONTEXT (type) - && TREE_CODE (TYPE_CONTEXT (type)) != FUNCTION_DECL - && TREE_CODE (TYPE_CONTEXT (type)) != NAMESPACE_DECL)) - TYPE_CONTEXT (type) = NULL_TREE; + if (TYPE_CONTEXT (type) + && TREE_CODE (TYPE_CONTEXT (type)) == BLOCK) + { + tree ctx = TYPE_CONTEXT (type); + do + { + ctx = BLOCK_SUPERCONTEXT (ctx); + } + while (ctx && TREE_CODE (ctx) == BLOCK); + TYPE_CONTEXT (type) = ctx; + } }