summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2012-03-29 02:58:29 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2012-03-29 02:58:29 +0000
commit47a1eb5eddde1269571b4def9b0425302cc491c9 (patch)
tree4946f8b06c2a67368948ab16136b0306ad0cf725
parentb79534243ebecbf6fd9edcc627fbe3f30d304983 (diff)
downloadgcc-47a1eb5eddde1269571b4def9b0425302cc491c9.tar.gz
PR c++/52746
* typeck.c (lookup_destructor): Clear BASELINK_QUALIFIED_P if we didn't get an explicit scope. * pt.c (tsubst_baselink): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@185945 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/pt.c10
-rw-r--r--gcc/cp/typeck.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/overload/virtual2.C31
5 files changed, 55 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0c96065f9df..b8a6b5cb4c5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2012-03-28 Jason Merrill <jason@redhat.com>
+
+ 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 <rguenther@suse.de>
* typeck2.c (process_init_constructor_array): Use the proper
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f128947ead8..9b410a75fd4 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 b68de52a13e..d2ed940cbc0 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;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b16a490b58c..954e8fb1b4b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-03-28 Jason Merrill <jason@redhat.com>
+
+ PR c++/52746
+ * g++.dg/overload/virtual2.C: New.
+
2012-03-28 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/vect7.ad[sb]: New test.
diff --git a/gcc/testsuite/g++.dg/overload/virtual2.C b/gcc/testsuite/g++.dg/overload/virtual2.C
new file mode 100644
index 00000000000..c93ba9e2988
--- /dev/null
+++ b/gcc/testsuite/g++.dg/overload/virtual2.C
@@ -0,0 +1,31 @@
+// PR c++/52746
+// { dg-do run }
+
+extern "C" int printf(const char*,...);
+extern "C" void abort();
+bool db;
+
+struct A
+{
+ virtual ~A() {}
+};
+
+struct B : public A
+{
+ virtual ~B() { db = true; }
+};
+
+template<int> void test()
+{
+ B * b = new B;
+ A * a = b;
+ a->~A();
+ ::operator delete(b);
+}
+
+int main()
+{
+ test<0>();
+ if (!db)
+ abort();
+}