This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ Patch] for c++/51214


2012/2/29 Jason Merrill <jason@redhat.com>:
> On 02/28/2012 05:06 PM, Fabien Chêne wrote:
>>
>> I agree, this is not efficient but I didn't find a better place.
>> perhaps in cp_parser_enumerator_list, ?that would require adding an
>> additional parameter to keep track of all the enum DECLs. Is it what
>> you have in mind ?
>
> I was thinking of finish_enum_value_list.

OK great. I have tried to reuse the existing infrastructure to extend
the CLASSTYPE_SORTED_FIELDS, unfortunately, it does not seem possible
because the code uses a tree chain (chained with DECL_CHAIN), and this
field is already used for enum values to store the enum type.
Among various possibilities, in the end, I think it is clearer to
handle the lately defined enum case separately. That is what I have
done in the attached patch.

>> Unqualified lookup works because when the type is not complete, the
>> lookup uses the non sorted case, which always works.
>
> OK, just make sure we have a test for that.

I have added a check in forw_enum11.C for that.

Boostrapped and tested on x86_64-unknown-linux-gnu, OK to commit ?

gcc/testsuite/ChangeLog

2012-05-06  Fabien Chêne  <fabien@gcc.gnu.org>

	PR c++/51214
	* g++.dg/cpp0x/forw_enum11.C: New.

gcc/cp/ChangeLog

2012-05-06  Fabien Chêne  <fabien@gcc.gnu.org>

	PR c++/51214
	* cp-tree.h (insert_late_enum_def_into_classtype_sorted_fields):
	Declare.
	* class.c (insert_into_classtype_sorted_fields): New.
	(add_enum_fields_to_record_type): New.
	(count_fields): Adjust the comment.
	(add_fields_to_record_type): Likewise.
	(finish_struct_1): Move the code that inserts the fields for the
	sorted case, into insert_into_classtype_sorted_fields, and call
	it.
	(insert_late_enum_def_into_classtype_sorted_fields): Define.
	* decl.c (finish_enum_value_list): Call
	insert_late_enum_def_into_classtype_sorted_fields if a late enum
	definition is encountered.

-- 
Fabien

Attachment: pr51214.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]