From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 9F32F3988024 for ; Tue, 20 Jul 2021 08:57:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9F32F3988024 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16K8Y4DQ140576; Tue, 20 Jul 2021 04:56:58 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 39wu0d8ttf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Jul 2021 04:56:57 -0400 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 16K8Y66F140970; Tue, 20 Jul 2021 04:56:57 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 39wu0d8tt1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Jul 2021 04:56:57 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16K8lLd4008901; Tue, 20 Jul 2021 08:56:55 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03ams.nl.ibm.com with ESMTP id 39upu89653-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Jul 2021 08:56:55 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16K8urmM24838478 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Jul 2021 08:56:53 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4876F11C064; Tue, 20 Jul 2021 08:56:53 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 92F9711C04C; Tue, 20 Jul 2021 08:56:49 +0000 (GMT) Received: from KewenLins-MacBook-Pro.local (unknown [9.197.247.15]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Jul 2021 08:56:49 +0000 (GMT) Subject: Re: [RFC/PATCH] Use range-based for loops for traversing loops To: Jonathan Wakely Cc: GCC Patches , Martin Sebor , Richard Biener , Richard Sandiford , Jakub Jelinek , Trevor Saunders , Segher Boessenkool References: <0a8b77ba-1d54-1eff-b54d-d2cb1e769e09@linux.ibm.com> From: "Kewen.Lin" Message-ID: <3fb94cbe-e643-3b0a-8a4c-21f9fd9aa6c9@linux.ibm.com> Date: Tue, 20 Jul 2021 16:56:47 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: aRPyVh4epUkKmgJlIhjIGMm5nk0Kl2y5 X-Proofpoint-ORIG-GUID: K9Znn5CUMwkPnNH309I0e7wc3Oqrz1yB X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-20_04:2021-07-19, 2021-07-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 priorityscore=1501 mlxscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 adultscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107200051 X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H2, 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: Tue, 20 Jul 2021 08:57:01 -0000 on 2021/7/19 下午10:08, Jonathan Wakely wrote: > 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) > Thanks for the comments, Jonathan. Yeah, to use "!=" is better for clear meaning and later extension. It was under the assumption that the index can only increase (only supports operator++()), so I simply used "<". Will fix it in V2. BR, Kewen