* 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/branches/gcc-4_7-branch@185961
138bc75d-0d04-0410-961f-
82ee72b054a4
+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-22 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/52487
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
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
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;
}
+2012-03-28 Jason Merrill <jason@redhat.com>
+
+ PR c++/52746
+ * g++.dg/overload/virtual2.C: New.
+
2012-03-28 Martin Jambor <mjambor@suse.cz>
Backported from mainline
--- /dev/null
+// 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();
+}