From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28219 invoked by alias); 31 Mar 2011 17:22:49 -0000 Received: (qmail 28193 invoked by uid 22791); 31 Mar 2011 17:22:47 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 31 Mar 2011 17:22:42 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2VHMfdR010553 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 31 Mar 2011 13:22:42 -0400 Received: from [127.0.0.1] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p2VHMetR030536; Thu, 31 Mar 2011 13:22:41 -0400 Message-ID: <4D94B85F.1030603@redhat.com> Date: Thu, 31 Mar 2011 17:33:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: Rodrigo Rivas CC: Jonathan Wakely , gcc-patches List Subject: Re: [C++0x] Range-based for statements and ADL References: <4D8A2403.5050708@redhat.com> <4D90A209.2020508@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-03/txt/msg02240.txt.bz2 On 03/28/2011 08:28 PM, Rodrigo Rivas wrote: > A few comments: > 1. I'm not sure about what should happen if the begin/end found in class > scope are not ordinary functions. Whatever range.begin() would mean if written explicitly. > My guess is that if it is a function > (static or non-static) it is called normally, and if it is a member > variable it is searched for an operator()(). If it is a type it should > fail. Yes, because we can't use . syntax to name type members. > + error ("range-based-for expression must be of a complete type"); I like your "range-based %" suggestion. I'd also say "must have complete type". > static void > cp_parser_perform_range_for_lookup (tree range, tree *begin, tree *end) This function needs a comment. > + *end = finish_class_member_access_expr(range, *end, > + false, tf_none); > + > + VEC(tree,gc) *vec; > + vec = make_tree_vector (); The declaration of vec needs to move to the top of the function. > + id_begin = get_identifier ("begin"); > + *begin = build_qualified_name (/*type=*/NULL_TREE, > + TREE_TYPE (range), > + id_begin, > + /*template_p=*/false); > + *begin = finish_class_member_access_expr(range, *begin, > + false, tf_none); > + > + id_end = get_identifier ("end"); > + *end = build_qualified_name (/*type=*/NULL_TREE, > + TREE_TYPE (range), > + id_end, > + /*template_p=*/false); > + *end = finish_class_member_access_expr(range, *end, > + false, tf_none); Don't call build_qualified_name here; the standard doesn't say range.T::begin(), just range.begin(). Also, we can't just call finish_class_member_access_expr here because it returns error_mark_node for any error condition, so we can't tell the difference between a lookup that didn't find anything (in which case we want to fall back to ADL) and an access violation (in which case we want to give an error). We need to do the lookup directly first, and then do finish_class_member_access_expr after we've decided to use the members. Jason