[C++ Patch] for c++/52126
Hi, templatetypename Tstruct A { int foo; struct B : A { using A::foo; }; // (1) struct C : AT { 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 fab...@gcc.gnu.org * g++.dg/template/using21.C: New. * g++.dg/template/using22.C: Likewise. gcc/cp/ChangeLog 2012-02-16 Fabien Chêne fab...@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 52126.patch Description: Binary data
Re: [C++ Patch] for c++/52126
On 02/16/2012 01:47 PM, Fabien Chêne wrote: + tree binfo_type = TYPE_MAIN_VARIANT (BINFO_TYPE (binfo)); BINFO_TYPE should already be its TYPE_MAIN_VARIANT. Why isn't it here? 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. I think we should avoid setting it in the first place, perhaps by changing dependent_type_p to dependent_scope_p in xref_basetypes. Jason
Re: [C++ Patch] for c++/52126
2012/2/16 Jason Merrill ja...@redhat.com: On 02/16/2012 01:47 PM, Fabien Chêne wrote: + tree binfo_type = TYPE_MAIN_VARIANT (BINFO_TYPE (binfo)); BINFO_TYPE should already be its TYPE_MAIN_VARIANT. Why isn't it here? 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. I think we should avoid setting it in the first place, perhaps by changing dependent_type_p to dependent_scope_p in xref_basetypes. Well, where it takes me ages to figure out what goes wrong and to fix it in the wrong way, it only takes you a few seconds... Never mind ;-) Your suggestion fixes the problem above with BINFOs as well, thank you ! complete regtest is running... OK to commit if it succeeds ? gcc/testsuite/ChangeLog 2012-02-16 Fabien Chêne fab...@gcc.gnu.org * g++.dg/template/using21.C: New. * g++.dg/template/using22.C: Likewise. gcc/cp/ChangeLog 2012-02-16 Fabien Chêne fab...@gcc.gnu.org * decl.c (xref_basetypes): call dependent_scope_p instead of dependent_type_p. -- Fabien 52126_2.patch Description: Binary data
Re: [C++ Patch] for c++/52126
OK. Jason