From bebecd51b6d2bb0f29423a582b0294183392e0d4 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Mon, 15 Dec 2014 03:41:41 +0000 Subject: [PATCH] re PR lto/64043 (ICE (segfault) with LTO: in tree_check/tree.h:2758 get_binfo_at_offset/tree.c:11914) PR lto/64043 * tree.c (virtual_method_call_p): Return false when OTR type has no BINFO. * g++.dg/lto/pr64043_0.C: New testcase. From-SVN: r218727 --- gcc/ChangeLog | 12 +++++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/lto/pr64043_0.C | 14 ++++++++++++++ gcc/tree.c | 15 ++++++++++----- 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/lto/pr64043_0.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3e9e2c5393f..1c637f6a415 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,14 @@ -2014-12-14 Jan HUbicka +2014-12-14 Jan Hubicka + + * cgraphunit.c (analyze_functions): Always analyze targets of aliases. + +2014-12-14 Jan Hubicka + + PR lto/64043 + * tree.c (virtual_method_call_p): Return false when OTR type has + no BINFO. + +2014-12-14 Jan Hubicka * cgraphunit.c (analyze_functions): Do not analyze extern inline funtions when not optimizing; skip comdat locals. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c42c3fe5a5f..bc4e0da32ec 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-12-14 Jan HUbicka + + PR lto/64043 + * g++.dg/lto/pr64043_0.C: New testcase. + 2014-12-14 H.J. Lu PR rtl-optimization/64037 diff --git a/gcc/testsuite/g++.dg/lto/pr64043_0.C b/gcc/testsuite/g++.dg/lto/pr64043_0.C new file mode 100644 index 00000000000..9cc5596c358 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr64043_0.C @@ -0,0 +1,14 @@ +// { dg-lto-do link } +// { dg-lto-options { { -flto -std=c++11 } } } +// { dg-extra-ld-options "-r -nostdlib -O2" } +class Validator +{ +public: + virtual ~Validator (); +}; +class FooWriter +{ + Validator *validator; + ~FooWriter (); +}; +FooWriter::~FooWriter () { delete validator; } diff --git a/gcc/tree.c b/gcc/tree.c index 3a857c00734..4fc3db00269 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -11864,12 +11864,17 @@ virtual_method_call_p (tree target) { if (TREE_CODE (target) != OBJ_TYPE_REF) return false; - target = TREE_TYPE (target); - gcc_checking_assert (TREE_CODE (target) == POINTER_TYPE); - target = TREE_TYPE (target); - if (TREE_CODE (target) == FUNCTION_TYPE) + tree t = TREE_TYPE (target); + gcc_checking_assert (TREE_CODE (t) == POINTER_TYPE); + t = TREE_TYPE (t); + if (TREE_CODE (t) == FUNCTION_TYPE) + return false; + gcc_checking_assert (TREE_CODE (t) == METHOD_TYPE); + /* If we do not have BINFO associated, it means that type was built + without devirtualization enabled. Do not consider this a virtual + call. */ + if (!TYPE_BINFO (obj_type_ref_class (target))) return false; - gcc_checking_assert (TREE_CODE (target) == METHOD_TYPE); return true; } -- 2.30.2