[C++ Patch] for c++/52126

Fabien Chêne fabien.chene@gmail.com
Thu Feb 16 22:08:00 GMT 2012


Hi,

template<typename T>struct A
{
    int foo;
    struct B : A { using A::foo; }; // (1)
    struct C : A<T> { using A::foo; }; // (2)
};

There are two problems in this PR. Firstly, for (1)  it seems to work,
but in reality the lookup for foo is not performed. Hence, I have
modified dfs_lookup_base so that (1) and (2) be treated equivalently.
For (2), the lookup was failing because the flag
BINFO_DEPENDENT_BASE_P was set. It think it should not be set for this
special case, however, I'm not sure I have unset it at the right
place. A slight tweak was also needed in lookup_field_r so that (1)
work correctly.

Tested x86_64-unknown-linux-gnu without regressions.

gcc/testsuite/ChangeLog

2012-02-16  Fabien Chêne  <fabien@gcc.gnu.org>

	* g++.dg/template/using21.C: New.
	* g++.dg/template/using22.C: Likewise.

gcc/cp/ChangeLog

2012-02-16  Fabien Chêne  <fabien@gcc.gnu.org>

	* search.c (dfs_lookup_base): call TYPE_MAIN_VARIANT.
	(lookup_field_r): Likewise.
	* name-lookup.c (do_class_using_decl): Reset the flag
	BINFO_DEPENDENT_BASE_P so that the call to lookup_member succeed.

-- 
Fabien
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 52126.patch
Type: application/octet-stream
Size: 3719 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120216/4f1ef9df/attachment.obj>


More information about the Gcc-patches mailing list