From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 9100E384843A for ; Mon, 19 Jul 2021 14:08:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9100E384843A Received: by mail-wr1-x431.google.com with SMTP id m2so22252868wrq.2 for ; Mon, 19 Jul 2021 07:08:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AtX6aixVwTaAfMDS3jYPlq7L50DoT732FChtUtWbGt4=; b=mE8pFxtZqpmmdn74OJyErfb4wsBPyxPaqWvZ/sOg6+M+EKPgZGYkNJ69fSoZRImYt5 LE+gULmjqE0EX32+ZPb99NKugtqnDGZVBZ2NicPMQwI6F+IXOws5kay4Y0AqtKW0pGQK ZCl7ejWcrwi9FRaHBTb8bLSO/3Jel1bg+bOILVHuxLVzHpEOSxrI7mg5hoOmUeyxxUjF yPL8QkOfXOUvJuDmRbrokEq6ATLrFILkl1hgiIXCdBZ77cJieabYQxtXbAEclLBbkHF3 R4BQxM9g3bYftIfHYymYoFy80cyfuaZtu8LuIfltmo24axjHE0sXY86Nsc7OWYnJyEop 7HgQ== X-Gm-Message-State: AOAM532iVvfcRqQHSEfd3foZKcH5X/5DnmTzYo9DpaLCyvY/yyo7PwKr Q3YRMa9spsLCR0oyhF0YTVYuHWZhajyVzUfIAJ0= X-Google-Smtp-Source: ABdhPJzKkzB49MF8yjr7QiHOn3r8mRu+t5XI21lwVkt1UiFth8rNL3BSsSuW/v6ZUWrcl7jZla/e5svxB+UFeTAfrt4= X-Received: by 2002:a5d:64ac:: with SMTP id m12mr29142139wrp.89.1626703729606; Mon, 19 Jul 2021 07:08:49 -0700 (PDT) MIME-Version: 1.0 References: <0a8b77ba-1d54-1eff-b54d-d2cb1e769e09@linux.ibm.com> In-Reply-To: <0a8b77ba-1d54-1eff-b54d-d2cb1e769e09@linux.ibm.com> From: Jonathan Wakely Date: Mon, 19 Jul 2021 15:08:38 +0100 Message-ID: Subject: Re: [RFC/PATCH] Use range-based for loops for traversing loops To: "Kewen.Lin" Cc: GCC Patches , Martin Sebor , Richard Biener , Richard Sandiford , Jakub Jelinek , Trevor Saunders , Segher Boessenkool Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jul 2021 14:08:54 -0000 On Mon, 19 Jul 2021 at 07:20, Kewen.Lin wrote: > > Hi, > > This patch follows Martin's suggestion here[1], to support > range-based for loops for traversing loops, analogously to > the patch for vec[2]. > > Bootstrapped and regtested on powerpc64le-linux-gnu P9, > x86_64-redhat-linux and aarch64-linux-gnu, also > bootstrapped on ppc64le P9 with bootstrap-O3 config. > > Any comments are appreciated. In the loops_list::iterator type, this looks a little strange: + bool + operator!= (const iterator &rhs) const + { + return this->curr_idx < rhs.curr_idx; + } + This works fine when the iterator type is used implicitly in a range-based for loop, but it wouldn't work for explicit uses of the iterator type where somebody does the != comparison with the past-the-end iterator on on the LHS: auto&& list ALL_LOOPS(foo); auto end = list.end(); auto begin = list.begin(); while (--end != begin)