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++0x] Range-based for statements and ADL


On Fri, Apr 8, 2011 at 5:45 PM, Jason Merrill <jason@redhat.com> wrote:
>> + Â Â Â Â error ("range-based %<for%> expression must have complete
>> type");
>> + Â Â Â Â Â error ("range-based %<for%> expression has an %<end%> member "
>> + Â Â Â Â Â Â Â Â Â"but not a %<begin%>");
>
> Let's give the type of the range initializer in these error messages.

Ok. I've changed the first one to:
+	  error ("range-based %<for%> expression of type %qT "
+		 "has incomplete type", TREE_TYPE (range));
Because the type of the expression must have complete type *only* if
it is an array. That could be stated in the error, but I don't think
it is necessary.

>> +static tree
>> +cp_parser_range_for_member_function (tree range, tree identifier)
>> ...
> Instead of handling this difference here, let's teach finish_call_expr to
> handle a COMPONENT_REF around a BASELINK.
Well, I just did that, but I'm not sure this is totally correct, I've
just begun to understand finish_call_expr. It works, if only because
I'm the only one using this new code path. Fell free to
revise/change/comment about it.

Also, I added a few more test cases: one with begin/end as member
functions with default arguments and member template functions with
default template arguments; other with begin/end member functions as
virtual functions.

And since we are approaching the acceptability, here it is the changelog:

gcc/cp

2011-04-11  Rodrigo Rivas Costa <rodrigorivascosta@gmail.com>

	* parser.c (cp_convert_range_for): Split into
	cp_parser_perform_range_for_lookup.
	(cp_parser_perform_range_for_lookup): New.
	(cp_parser_range_for_member_function): New.
	(cp_parser_for_init_statement): Correct error message.
	* semantics.c (finish_call_expr): Accept COMPONENT_REF.

gcc/testsuite

2011-04-11  Rodrigo Rivas Costa <rodrigorivascosta@gmail.com>

	* g++.dg/cpp0x/range-for2.C: Correct for declaration.
	* g++.dg/cpp0x/range-for3.C: Likewise.
	* g++.dg/cpp0x/range-for9.C: Correct error message.
	* g++.dg/cpp0x/range-for11.C: New.
	* g++.dg/cpp0x/range-for12.C: New.
	* g++.dg/cpp0x/range-for13.C: New.
	* g++.dg/cpp0x/range-for14.C: New.
	* g++.dg/cpp0x/range-for15.C: New.
	* g++.dg/cpp0x/range-for16.C: New.

Best regards.
--
Rodrigo

Attachment: range-for.txt
Description: Text document


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