re PR lto/64043 (ICE (segfault) with LTO: in tree_check/tree.h:2758 get_binfo_at_offs...
authorJan Hubicka <hubicka@gcc.gnu.org>
Mon, 15 Dec 2014 03:41:41 +0000 (03:41 +0000)
committerJan Hubicka <hubicka@gcc.gnu.org>
Mon, 15 Dec 2014 03:41:41 +0000 (03:41 +0000)
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
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lto/pr64043_0.C [new file with mode: 0644]
gcc/tree.c

index 3e9e2c5393f9c024c9e94652558624a802f5ca8b..1c637f6a4152b17cecfa84233106442878c5464d 100644 (file)
@@ -1,4 +1,14 @@
-2014-12-14  Jan HUbicka  <hubicka@ucw.cz>
+2014-12-14  Jan Hubicka  <hubicka@ucw.cz>
+
+       * cgraphunit.c (analyze_functions): Always analyze targets of aliases.
+
+2014-12-14  Jan Hubicka  <hubicka@ucw.cz>
+
+       PR lto/64043
+       * tree.c (virtual_method_call_p): Return false when OTR type has
+       no BINFO.
+
+2014-12-14  Jan Hubicka  <hubicka@ucw.cz>
 
        * cgraphunit.c (analyze_functions): Do not analyze extern inline
        funtions when not optimizing; skip comdat locals.
index c42c3fe5a5f5a0ce968af59f44cf78a8701a0240..bc4e0da32ec609bc86a51a6efe47094f70c9716c 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-14  Jan HUbicka  <hubicka@ucw.cz>
+
+       PR lto/64043
+       * g++.dg/lto/pr64043_0.C: New testcase.
+
 2014-12-14  H.J. Lu  <hongjiu.lu@intel.com>
 
        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 (file)
index 0000000..9cc5596
--- /dev/null
@@ -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; }
index 3a857c0073442ed2d52d47de331980479ed77dcb..4fc3db00269e47c7a512d9967743de86849f8ad7 100644 (file)
@@ -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;
 }