[C++ Patch] for c++/11750
Fabien Chêne
fabien.chene@gmail.com
Mon Aug 13 20:49:00 GMT 2012
Hi,
Here, we were setting the LOOKUP_NONVIRTUAL flag wrongly. Actually, we
need to check if the function context is the same than the instance
type -- yes that might happen that they be different in presence of
using-declarations.
It happens that it was working if the call was invoked through a
pointer, that's because we were failing to determine the dynamic type
(in resolved_fixed_type_p). On the contrary, it wasn't working if the
call was done through a reference because we manage to determine the
dynamic_type thanks to a special case in fixed_type_or_null. There is
probably room for improvement here, though I'm not sure the C++ front
end is the better place to de-virtualize.
Tested x84_64-unknown-linux-gnu without regressions. OK to commit ?
gcc/testsuite/ChangeLog
2012-08-12 Fabien Chêne <fabien@gcc.gnu.org>
PR c++/11750
* g++.dg/inherit/vitual9.C: New.
gcc/cp/ChangeLog
2012-08-12 Fabien Chêne <fabien@gcc.gnu.org>
PR c++/11750
* call.c (build_new_method_call_1): Check that the instance type
and the function context are the same before setting the flag
LOOKUP_NONVIRTUAL.
--
Fabien
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr11750.patch
Type: application/octet-stream
Size: 1699 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120813/f7b3597f/attachment.obj>
More information about the Gcc-patches
mailing list