From 3b456f8da3721618ae706b0c4eaa438cccb0dbd2 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Wed, 2 Jan 2019 16:23:27 +0100 Subject: [PATCH] re PR lto/88130 (ICE in copy_function_or_variable, at lto-streamer-out.c:2315 since r260963) PR lto/88130 * varpool.c (varpool_node::ctor_useable_for_folding_p): Also return false at WPA time when body was removed. * g++.dg/torture/pr88130.C: New testcase. From-SVN: r267515 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/torture/pr88130.C | 27 ++++++++++++++++++++++++++ gcc/varpool.c | 10 +++++----- 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr88130.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f79bab55746..708eb500cf2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-01-02 Jan Hubicka + + PR lto/88130 + * varpool.c (varpool_node::ctor_useable_for_folding_p): Also return + false at WPA time when body was removed. + 2019-01-02 Martin Liska PR tree-optimization/88650 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 269d780e465..613f048e778 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-02 Jan Hubicka + + PR lto/88130 + * g++.dg/torture/pr88130.C: New testcase. + 2019-01-02 Martin Liska PR tree-optimization/88650 diff --git a/gcc/testsuite/g++.dg/torture/pr88130.C b/gcc/testsuite/g++.dg/torture/pr88130.C new file mode 100644 index 00000000000..911cf6c84c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr88130.C @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-flto" } */ +/* { dg-require-effective-target lto } */ +class a { +public: + static const long b = 1; +}; +struct c { + enum d { e }; +}; +class C; +class f { +public: + f(c::d); + template C operator<=(g); +}; +class C { +public: + template void operator!=(h &); +}; +void i() { + f j(c::e); + try { + j <= 0 != a::b; + } catch (...) { + } +} diff --git a/gcc/varpool.c b/gcc/varpool.c index 2aa59f95a00..edffa551ee6 100644 --- a/gcc/varpool.c +++ b/gcc/varpool.c @@ -335,16 +335,16 @@ varpool_node::ctor_useable_for_folding_p (void) if (TREE_THIS_VOLATILE (decl)) return false; + /* Avoid attempts to load constructors that was not streamed. */ + if (in_lto_p && DECL_INITIAL (real_node->decl) == error_mark_node + && real_node->body_removed) + return false; + /* If we do not have a constructor, we can't use it. */ if (DECL_INITIAL (real_node->decl) == error_mark_node && !real_node->lto_file_data) return false; - /* Avoid attempts to load constructors that was not streamed. */ - if (flag_ltrans && DECL_INITIAL (real_node->decl) == error_mark_node - && real_node->body_removed) - return false; - /* Vtables are defined by their types and must match no matter of interposition rules. */ if (DECL_VIRTUAL_P (decl)) -- 2.30.2