From 917c1602aa2bf8905890ee6c19a1624f80b1c8c3 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 28 Mar 2012 22:58:29 -0400 Subject: re PR c++/52746 (Explicit virtual destructor call replaced by direct call in template function) PR c++/52746 * typeck.c (lookup_destructor): Clear BASELINK_QUALIFIED_P if we didn't get an explicit scope. * pt.c (tsubst_baselink): Likewise. From-SVN: r185945 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/pt.c | 10 +++++++--- gcc/cp/typeck.c | 5 +++++ 3 files changed, 19 insertions(+), 3 deletions(-) (limited to 'gcc/cp') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0c96065..b8a6b5c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2012-03-28 Jason Merrill + + PR c++/52746 + * typeck.c (lookup_destructor): Clear BASELINK_QUALIFIED_P if + we didn't get an explicit scope. + * pt.c (tsubst_baselink): Likewise. + 2012-03-28 Richard Guenther * typeck2.c (process_init_constructor_array): Use the proper diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f128947..9b410a7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11814,6 +11814,7 @@ tsubst_baselink (tree baselink, tree object_type, tree optype; tree template_args = 0; bool template_id_p = false; + bool qualified = BASELINK_QUALIFIED_P (baselink); /* A baselink indicates a function from a base class. Both the BASELINK_ACCESS_BINFO and the base class referenced may @@ -11862,9 +11863,12 @@ tsubst_baselink (tree baselink, tree object_type, if (!object_type) object_type = current_class_type; - return adjust_result_of_qualified_name_lookup (baselink, - qualifying_scope, - object_type); + + if (qualified) + baselink = adjust_result_of_qualified_name_lookup (baselink, + qualifying_scope, + object_type); + return baselink; } /* Like tsubst_expr for a SCOPE_REF, given by QUALIFIED_ID. DONE is diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index b68de52..d2ed940 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2415,6 +2415,11 @@ lookup_destructor (tree object, tree scope, tree dtor_name) tf_warning_or_error); expr = (adjust_result_of_qualified_name_lookup (expr, dtor_type, object_type)); + if (scope == NULL_TREE) + /* We need to call adjust_result_of_qualified_name_lookup in case the + destructor names a base class, but we unset BASELINK_QUALIFIED_P so + that we still get virtual function binding. */ + BASELINK_QUALIFIED_P (expr) = false; return expr; } -- cgit v1.1