[Patch] PR c++/26256

Fabien Chêne fabien.chene@gmail.com
Tue May 11 19:44:00 GMT 2010


Hello,

Here is a patch to fix PR c++/26256, which deals with using
declarations. I've tried a naive approach: basically, when a field
decl is ambiguous, lookup_member (invoked with protect = 1) returns a
TREE_LIST. So when we are in this case, I have implemented a lookup in
the object scope, which try to disambiguate the field decl using
'using decl'. If the lookup succeeds, just return the selected field
decl in the TREE_LIST.

I've also implemented the dual fix for type fields. The principle is
the same than above, if a field type is ambiguous, lookup_name_real
returns a TREE_LIST. In this case, we have to do a lookup in the
appropriate class scope, and return the selected field type in the
TREE_LIST if the lookup succeds.

Thought ?

Bootstrapped with all default languages, tested x86_64/Linux.

gcc/testsuite/ChangeLog:

2010-05-11  Fabien Chêne  <fabien.chene@gmail.com>
	PR c++/26256
	* g++.dg/lookup/using23.C: New.
	* g++.dg/lookup/using24.C: New.
	* g++.dg/lookup/using25.C: New.
	* g++.dg/lookup/using26.C: New.
	* g++.dg/lookup/using27.C: New.
	* g++.dg/debug/using4.C: New.
	* g++.dg/debug/using5.C: New.


gcc/cp/ChangeLog:

2010-05-11  Fabien Chêne  <fabien.chene@gmail.com>
	PR c++/26256
	* cp-tree.h (disambiguate_with_using_decl): Declare.
	* name-lookup.c (disambiguate_with_using_decl): Define. Try to
	disambiguate a field type or a field decl with using declarations.
	* search.c (lookup-member): Call disambiguate_with_using_decl when
	a field decl is ambiguous.
	* parser.c (cp_parser_lookup_name): Call
	disambiguate_with_using_decl when a field type is ambiguous.
	* class.c (count_fields): Ignore using declarations.
	(add_fields_to_record_type): Likewise.
	(check_field_decls): Keep using declarations.

gcc/ChangeLog:

2010-05-11  Fabien Chêne  <fabien.chene@gmail.com>
	PR c++/26256
	* dbxout.c (dbxout_type_fields): Ignore using declarations.

-- 
Fabien
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr26256.patch
Type: application/octet-stream
Size: 10399 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100511/19f62412/attachment.obj>


More information about the Gcc-patches mailing list