From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9235 invoked by alias); 29 Mar 2011 21:13:49 -0000 Received: (qmail 9225 invoked by uid 22791); 29 Mar 2011 21:13:49 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-pw0-f47.google.com (HELO mail-pw0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 29 Mar 2011 21:13:44 +0000 Received: by pwj9 with SMTP id 9so188363pwj.20 for ; Tue, 29 Mar 2011 14:13:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.195.3 with SMTP id s3mr244596wff.21.1301433224178; Tue, 29 Mar 2011 14:13:44 -0700 (PDT) Received: by 10.142.76.2 with HTTP; Tue, 29 Mar 2011 14:13:44 -0700 (PDT) In-Reply-To: References: <4D8A2403.5050708@redhat.com> <4D90A209.2020508@redhat.com> Date: Tue, 29 Mar 2011 22:00:00 -0000 Message-ID: Subject: Re: [C++0x] Range-based for statements and ADL From: Jonathan Wakely To: Rodrigo Rivas Cc: Gabriel Dos Reis , Jason Merrill , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 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/msg02033.txt.bz2 On 29 March 2011 21:33, Rodrigo Rivas wrote: > On Tue, Mar 29, 2011 at 8:22 PM, Jonathan Wakely wrote: >> How about "No suitable % and % functions found for range >> expression of type %qT in % statement" ? > > Nice. > But the problem here is that there are a lot of different error conditions: > 1. begin member but not end member. > 2. end member but not begin member. I think these cases should say something like "invalid lookup results, member 'begin' and non-member 'end'" (or vice versa) as we had in last week's patch. Or maybe it would be better to say "lookup for 'for' found member 'begin' but no member 'end'" > 3. begin and end member but one or both are not callable/accesible/whatever. I would definitely want to get an "access denied", "deleted function" etc. error for that case. > 3. no begin/end members, a begin global function but not end. > 4. no begin/end members, an end global function but not begin. Maybe something similar to the text I suggested above, but only mentioning the lookup that failed, "no suitable 'begin' found for range expression ..." > 5. no begin/end members, begin and end functions but one or both not > callable/wrong overload/etc. In some cases I would probably want to know the actual error, not just "cannot use range-based for" If a begin() is found but can't be called, showing the "candidates are..." list might be helpful to see the problem e.g. if my::begin(my::type&) can't be called for const my::type. > 6. no begin/end members, no begin/end global functions. Since the > standard headers have the std::begin/std::end templates, this will not > happen when you include (most) STL headers. Maybe this is the only case where the text I suggested is useful, I think a special "can't use range-based for" makes sense in this case, instead of "begin not declared in this scope" > What is the best message for each? Does it make sense to have up to 6 > different messages? Too many? It would be nice for users, but it's certainly more work, and potentially more places for bugs to creep in.