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
This commit is contained in:
parent
47640f4069
commit
62e3d9e6f8
4 changed files with 39 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
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
|
||||
|
|
|
@ -7282,8 +7282,11 @@ build_new_method_call_1 (tree instance, tree fns, VEC(tree,gc) **args,
|
|||
}
|
||||
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;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
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 ()
|
||||
|
|
26
gcc/testsuite/g++.dg/other/final1.C
Normal file
26
gcc/testsuite/g++.dg/other/final1.C
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* 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" } } */
|
Loading…
Add table
Reference in a new issue