Commit 62e3d9e6 by Roberto Agostino Vitillo Committed by Jason Merrill

call.c (build_new_method_call_1): Use non-virtual lookup for final virtual functions.

	* call.c (build_new_method_call_1): Use non-virtual lookup
	for final virtual functions.

From-SVN: r179014
parent 47640f40
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> 2011-09-16 Jason Merrill <jason@redhat.com>
PR c++/50424 PR c++/50424
......
...@@ -7282,8 +7282,11 @@ build_new_method_call_1 (tree instance, tree fns, VEC(tree,gc) **args, ...@@ -7282,8 +7282,11 @@ build_new_method_call_1 (tree instance, tree fns, VEC(tree,gc) **args,
} }
else else
{ {
/* Optimize away vtable lookup if we know that this function
can't be overridden. */
if (DECL_VINDEX (fn) && ! (flags & LOOKUP_NONVIRTUAL) 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; flags |= LOOKUP_NONVIRTUAL;
if (explicit_targs) if (explicit_targs)
flags |= LOOKUP_EXPLICIT_TMPL_ARGS; 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> 2011-09-20 Ira Rosen <ira.rosen@linaro.org>
* g++.dg/vect/slp-pr50413.cc: Don't run the test. Remove main () * g++.dg/vect/slp-pr50413.cc: Don't run the test. Remove main ()
......
/* 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" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment