aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index d061a04..8ea4251 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5772,10 +5772,16 @@ free_lang_data_in_decl (tree decl, struct free_lang_data_d *fld)
not do well with TREE_CHAIN pointers linking them.
Also do not drop containing types for virtual methods and tables because
- these are needed by devirtualization. */
+ these are needed by devirtualization.
+ C++ destructors are special because C++ frontends sometimes produces
+ virtual destructor as an alias of non-virtual destructor. In
+ devirutalization code we always walk through aliases and we need
+ context to be preserved too. See PR89335 */
if (TREE_CODE (decl) != FIELD_DECL
&& ((TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL)
- || !DECL_VIRTUAL_P (decl)))
+ || (!DECL_VIRTUAL_P (decl)
+ && (TREE_CODE (decl) != FUNCTION_DECL
+ || !DECL_CXX_DESTRUCTOR_P (decl)))))
DECL_CONTEXT (decl) = fld_decl_context (DECL_CONTEXT (decl));
}