+2011-09-20 Roberto Agostino Vitillo <ravitillo@lbl.gov>
+
+ * call.c (build_new_method_call_1): Use non-virtual lookup
+ for final virtual functions.
+
2011-09-16 Jason Merrill <jason@redhat.com>
PR c++/50424
}
else
{
+ /* Optimize away vtable lookup if we know that this function
+ can't be overridden. */
if (DECL_VINDEX (fn) && ! (flags & LOOKUP_NONVIRTUAL)
- && resolves_to_fixed_type_p (instance, 0))
+ && (resolves_to_fixed_type_p (instance, 0)
+ || DECL_FINAL_P (fn) || CLASSTYPE_FINAL (basetype)))
flags |= LOOKUP_NONVIRTUAL;
if (explicit_targs)
flags |= LOOKUP_EXPLICIT_TMPL_ARGS;
+2011-09-20 Roberto Agostino Vitillo <ravitillo@lbl.gov>
+
+ * g++.dg/other/final1.C: new test
+
2011-09-20 Ira Rosen <ira.rosen@linaro.org>
* g++.dg/vect/slp-pr50413.cc: Don't run the test. Remove main ()
--- /dev/null
+/* Verify that final methods are devirtualized */
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-original -std=c++0x" } */
+
+struct A final
+{
+ virtual void foo ()
+ {
+ }
+};
+
+struct B
+{
+ virtual void foo () final
+ {
+ }
+};
+
+void fun(A* a, B* b)
+{
+ a->foo();
+ b->foo();
+}
+
+/* { dg-final { scan-tree-dump-times "A::foo" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "B::foo" 2 "original" } } */