From patchwork Mon Aug 12 17:55:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Coplan X-Patchwork-Id: 1971654 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=g9P0PIq9; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=g9P0PIq9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WjMdH0HZCz1yYl for ; Tue, 13 Aug 2024 03:56:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3A4D53858C31 for ; Mon, 12 Aug 2024 17:56:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2062f.outbound.protection.outlook.com [IPv6:2a01:111:f403:2606::62f]) by sourceware.org (Postfix) with ESMTPS id 936083858D20 for ; Mon, 12 Aug 2024 17:55:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 936083858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 936083858D20 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2606::62f ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1723485334; cv=pass; b=ZLVrBcQ3odqCLt1dhl2CnakH96yQPSnS8+ZtBNlU6B3KCQ9/5eAxRTA/j2MVsv3KJ4rXm+L7Dnk7HfSGzRJ7IpTs6Sxy/RlSTiGzuXogmvdUBZwlKdfdhX0UaYI+gYIXf8/VHa+BfH+hp/dA6r5x9wPEUA3mPJUxKJpfHfPPsLE= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1723485334; c=relaxed/simple; bh=a8EWUyYHZsiTH+mkb4G/1ht7FoZIRELgh7j+lLZBJxc=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=cP0bUmxBOEIGif+9/3/jo+cgaLf/lXMCj9ZjKC0nLgUYEQMUDbgEqEJuxjj+JuZbO9lKa9oMdFN6xtLq/TaRTJeKjmebUqpm6GrgBVK7DJA/PKJN9gCmmf7BgnhPJJxgWFEoUpz+gUU7YLf9AWmrt8nRuLtTLCRdBEiiUO0AJAQ= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=lGOSSf0FkWpR7N5NLPgUnZXdoFmJqMLg6MBb2WmD9tpzRTnvb642JBh6UfLL7rz8dZQ55lkdyyDusKWW3pouQ5jUWsdrRGecQFlHKejbUmNYLCG4Aq0LpL2XD4wtQA4oEuUHQd+Nh2g8A7SAzqxfhQLpf3dQUUFE1SublAXcRwDpX5psaKw9/js3IYXmolbJO6FACClDJmYQlADfe6RcoZR2rzkyPgxWb9ulCeen2V7X+GL4cFX8zNgAxvpMl5oaP5Dhw3VoK1lGDW+EuquRn46hCmr+QHdVd82FQaO+v/rrsi157ejOEfPrxuyWYqbOtO5yeQ2IwQrBdoEG8u95Ig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PxowZxTKqgAc+IJjNl+ieLPy536To8ofiLGViPCY+IQ=; b=lms+HzzmuzO5JSoV2zsp1dwoqVUQzG1e0uViHQQHQppNo682Nrh1Awy+4isGF/KeIKUts9syQB8wtp/G2Cq6JQAKWZE5ZzYp3+ZJNr8D1Fbanb7IsHPyrTyQ7gu19IhIgI4Fy3sl6lBMckndA8yAmb7BqViFRnHtevQ6M95wTsjhUevihtFlHiYpnmzF9TPZ3m8kqJY111Ec4LCGXCi8LIxlFS9IOQR42hWwgJ4I84v5aHdieuCf2ef2QBd8jXmzCBG9HYDwdK7tglGszKcOWG4WeudeS4Q02tDgeUVj+qXFwAaBG0GH0Nta7gGgMhxmjvUH26FzQWLaoK7TrX//NA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PxowZxTKqgAc+IJjNl+ieLPy536To8ofiLGViPCY+IQ=; b=g9P0PIq9+J+0wPkr5RHo+HAxxOqWGRniRCNb2Q8H9AQLq4wavGfKUiUlcPuUxeS+YlEo6ueELH7oMR+gJh/wWyZ63MTv+zM0sU9EkpnXqMHIT3n1QlP0zCqWh3jUSJzmMVZ4Tro1/TRmtJS1V/PO9n6+CcE8Gtf+3KyYiMgCvjI= Received: from DUZPR01CA0301.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b7::18) by DB4PR08MB8199.eurprd08.prod.outlook.com (2603:10a6:10:381::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.13; Mon, 12 Aug 2024 17:55:26 +0000 Received: from DU2PEPF0001E9C3.eurprd03.prod.outlook.com (2603:10a6:10:4b7:cafe::4b) by DUZPR01CA0301.outlook.office365.com (2603:10a6:10:4b7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.22 via Frontend Transport; Mon, 12 Aug 2024 17:55:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DU2PEPF0001E9C3.mail.protection.outlook.com (10.167.8.72) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Mon, 12 Aug 2024 17:55:26 +0000 Received: ("Tessian outbound 4a25380d73a2:v403"); Mon, 12 Aug 2024 17:55:26 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4be4ff478cf4922b X-CR-MTA-TID: 64aa7808 Received: from Ledd88836d696.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4F97464C-D420-45A2-A1D4-FA9A88205348.1; Mon, 12 Aug 2024 17:55:18 +0000 Received: from EUR03-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Ledd88836d696.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 12 Aug 2024 17:55:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lZzaXsFtx4yirZ+MCiJVrt3TW9Y9zHy1QpwuUJ1+1tAk+6JCjeIcinD2a5gwbRDttQNR/5GnoXvuF1NxWyEBQ7ymJ/7veqAtf3TVxd0zQdOwBIR+syz0nf5Ou7+kfK8WM+mzN1o/oAlHslapvDcOEsKTeF0rPyhWdJHTTL8gLGhJnuxkN2KukcywtgEZPqWs9HuUlL0zDM8UarFSf9EFOecbNlLSVzECAu+icesmA7ysRAFWasAyB4/aPo+5TxiMWiArKXmU0QlB3P8XQeQlpr1hkKx77oc2Y6XGKI3oASKZRinFIUU5fNUUGk/bWDD7XQUxR0ImqFJZui+2RssgOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PxowZxTKqgAc+IJjNl+ieLPy536To8ofiLGViPCY+IQ=; b=Gt+fwzcipFH3pu6xHl4uOyZfNPFIk1RLo9024FkUb3GBtY/H5XhXwkWXnMMetBdH+o+wk6h8jfB/vbiY6a5LNjNDTj1s/7BwDcThccpx+GoAfD+vJOIhqJzcr13jwojYKCo1j+5nUkevLacZLcRNAz+9vnPSf+U2tboyG0CgNfqO/PJKZ+jGvDKHsXFzuetioYkDSLhW1i8l9btcXYq4g1/V6ojbm2mAlfKuJszJ4v1c/gkqYOIZFuOiLGYM0MvhNNBr7blLzZ6BJD6y/WZ2U2BfKZlsLjcNmPt7JeUHwmDwNF7pVcPd74VPhgHovWeK3we9W43bA8OZ5qLDOX9HjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PxowZxTKqgAc+IJjNl+ieLPy536To8ofiLGViPCY+IQ=; b=g9P0PIq9+J+0wPkr5RHo+HAxxOqWGRniRCNb2Q8H9AQLq4wavGfKUiUlcPuUxeS+YlEo6ueELH7oMR+gJh/wWyZ63MTv+zM0sU9EkpnXqMHIT3n1QlP0zCqWh3jUSJzmMVZ4Tro1/TRmtJS1V/PO9n6+CcE8Gtf+3KyYiMgCvjI= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) by GV2PR08MB8654.eurprd08.prod.outlook.com (2603:10a6:150:b6::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.12; Mon, 12 Aug 2024 17:55:15 +0000 Received: from PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::9f32:dc2a:5bec:aeac]) by PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::9f32:dc2a:5bec:aeac%4]) with mapi id 15.20.7875.012; Mon, 12 Aug 2024 17:55:15 +0000 Date: Mon, 12 Aug 2024 18:55:12 +0100 From: Alex Coplan To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell , Jakub Jelinek Subject: [PATCH v2] c++: Ensure ANNOTATE_EXPRs remain outermost expressions in conditions [PR116140] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO4P123CA0249.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a7::20) To PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAWPR08MB8958:EE_|GV2PR08MB8654:EE_|DU2PEPF0001E9C3:EE_|DB4PR08MB8199:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e40b388-9cd3-4fb9-31f0-08dcbaf7f22e x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: 8L2gJwKgbV+1W1/WA+pzKOSrcudpA9w16Mg6ir7NJg1Ss6htsMbyQxMNWBmdiiI4eDOzj1MMklkFF7f9USUYIofqPoPO+HCGOa5zuTCllPxFxFnpKGdc9TnIFROefWrdiZoVnZelU1sxdnpgk6KoGGRjw3IF3AVqhB8lEKLdDDqgeXVIrBVM/IGR1Vg8ErtgNNvsByVID6sPWWQ4BT2R4HrSnUsMMIkTLCba3+ExmcrrI3pXWLJQHmxMTiTwAwJ29SgSISXTuazW94GuUeWMuXHy7Ce4LjnmHSiYHMnNeqq9EFQd6ST9oAgzUGkCk7LzrM1t9Ygi7L9u3Ukn7N4IfFfquTw4Xw/lwZJf+XE1Ma+eCIqLn5/qRfDDfe+cI1rv9D0zRFgxH2gheJZP0iEWW6dXpp2ZCg7pqhis9y3ScSFwairD2fjrK/UBy91ytKqYRdcp380Qx5UIxbADOh9NVntnTx6LUqi7HQFhiZmDh/0Cie5jpzH4kjUj+9DXYxm2oRr3ybu7zuAROwwEP1/H+MhG874UE6xZNkENndChlSfumh8N3lWqys7VFYSoJp2E8LGU5rhY1u9HaMdLSaDduahVeVJ86yF6NdVotfVKZyzXVwmehrsPY8vhWyN+etxsJdOyvsYecwS0baqTdqUWl6L4OLLzAm07pM/fLhAQa6GaSP9TbOhi6tZ6gcbYKnxGDrx+uEbNjUcg+qEAy9kBWGAN+pUHHJT6SeJZR+JVJv0NKKtYsEsPla4jX9yPw5dEy405KIVPD6g25brUJeO3rpGaF5yJ+BZYt2MVUcYWFWACm1N/L6AQ9FisIDyY05NOmA4m0KXJE8m6AslIjushhZX66EF4bW7zWVQCAhwBtSMKIJbBXBqMrBRIOlHkFNV//rEzGxfU+rWwOSZaFmzyhfc4Yb1tWRAdNPyaLoLKV1RBNTMvj/KEdesWf30Ee0sbPHu6A+WgxyxwtRW7cYl2jfF5a/8UOPcBxb/zpUVJ3pq3thrDOeQd/rGEs555f6T8DNPo7wi1UwBJt2dcCcxKAqxqTYIfM12gaGUMFBN8oVQzsAprk/MsVbto7BcFGCnuEKI3dvS3E5OJat8G7YZgNJw8/8X9r845TcDuf1pWk1qSVSFa84dC/4UZW8oWrlpJ+jnY1X/e2KRme1Iaff245j8dfO4wJI/VZLov6xkhT3JrHDAv8H3GIGxtQlPJAE495lVey1jREDXxEAR7bi/WXKBqh+HKd9RWhbv+9cEx7+tIULzetANHb6cQmTS7JT4RmIK/dWFAKujRanJcA3opTWq1QQI5vrO8+U81igl1+js= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAWPR08MB8958.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8654 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-SkipListedInternetSender: ip=[2603:10a6:102:33e::15]; domain=PAWPR08MB8958.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU2PEPF0001E9C3.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d19905f6-72de-4aef-6c17-08dcbaf7eb67 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|82310400026|1800799024|35042699022; X-Microsoft-Antispam-Message-Info: =?utf-8?q?R3TE42PcsWVF7byIXE3NiFsmJN6DS4J?= =?utf-8?q?eSJM1IdtmDwzBWSfkLvyuabJen4NhRwboe7z3UgV8E7reSBmIbWw/VV2Z8ymd4+aD?= =?utf-8?q?6zEACYhgxPyd0lX8i9oDDFe17KfDPENZpn2QJD1kRaXV8EkGP/7oSjbkBlP6lB0ll?= =?utf-8?q?mJguJNYGea7Lg/Mf5sX11F5fRT2Kfqm0TjaapOxClE5kztrp0Lk4NpjwC5EtiiXFs?= =?utf-8?q?SKol935KIhFzx/VE600ccSz6/IHSN0NOVi0P3tbCkxYDOuBchD1mZk6bVV/rlk18I?= =?utf-8?q?+5hSr/VuoZ27fUIEs+rZeuVQRdHEcFhuiruw98CRJgq6C+EMgnY50Nqv8MulAul4a?= =?utf-8?q?fRNJGOM1OtDy0PlAlBL4lpusffl7N6xRZmJFF1PQ3l1kx/kV3pOn+7DtqMOn3rjAo?= =?utf-8?q?72Cm0VvS5jaEjHXQjwdJzPfM8Ph1NCy10xIMARo3lwYR1zkBEGtTf84hTCmB6P2pv?= =?utf-8?q?e1Rm3ds/s9Fd2nS3UuZGZpag0GsL6mQHCCmHSo3hXLXOIrDGCctuux8CzkOber0es?= =?utf-8?q?/7Ewep1bFm+mmt/xKm+vw1ame23ckt99HdNGuR4jDtV1AZO9xpINnN2Eeqc+Crsp5?= =?utf-8?q?HSBuHceWxB70aQ7JzgiSjn3inoHVjJVBaJVdCL58MR6x/OPfi87RHrE2rVMxGwJhs?= =?utf-8?q?lLvt2pO3Sja2+zSWekRXDq4giLTLTJ7e09SGC25vqISEh4LBvHa9fn9bivpfDEt3W?= =?utf-8?q?24vG04qvRt0iCEgD3oQvUQT9+D4gjKpYmMNogG6DmdVVUu0Ra6NMG/sS2avTbA2tU?= =?utf-8?q?rezqT5JjRwO3WgNGJhH4Er8p6EJ4kU9k1pBRTTkbIOIwfAVxB2eRbKAXb5899+Ssh?= =?utf-8?q?DSCVCP4P9qq8igbJnHJxYRMJ+C8t0NXb78n+ESZii8DM6Om6ozDSt4l9kVx1TV5eL?= =?utf-8?q?3Eetew0ygC9uLJOcMw4pdjpQ/r4Fxrkpphvx6kynYi2S0gkQy7cHTtQT22sqNBcHA?= =?utf-8?q?H9PMAFHtHRzzlbcHJXbm+WEvN1O4Olfyg9suIdwOcae5az1jktcbaOzRbUdZD1tMx?= =?utf-8?q?dgCe8RWFekZ53OIbbB7MHn1djKdoMQWYDUrLpPZxsuIUpF/ct0daE6XjbfUovMT8L?= =?utf-8?q?Q7SuOI2DXu1bgP/lYil/GsHg6By+CT5qOEgSPrfN4EKibdMnwIFN2pOrKbGgxiJmY?= =?utf-8?q?lqquBHE50l3edlj6h/jHPZBxEW4V3X8nsJaKgPAHdWNi6/yhrJsl0bXolKTAW7yb+?= =?utf-8?q?BY41EdH5waX9MgPf4+FNDoR/w+ZtZ8r16wUtQMaCH5+aaBCiYQR1zEgpp02aKE0RU?= =?utf-8?q?r/4CDJckaNAE3QFISzHCECPKitpeB6NQvT1wa2Xx/+xpwOeLg5oXDlCPSUFsgw7dS?= =?utf-8?q?PBo8JmL/ryI0BOxn92hC8PAyaq83AxzdiQ=3D=3D?= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230040)(36860700013)(376014)(82310400026)(1800799024)(35042699022); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2024 17:55:26.2101 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e40b388-9cd3-4fb9-31f0-08dcbaf7f22e X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF0001E9C3.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB8199 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! This is a v2 patch of: https://gcc.gnu.org/pipermail/gcc-patches/2024-August/659968.html that addresses Jakub's feedback. FWIW, I tried to contrive a testcase where convert_from_reference kicks in and we get called with an ANNOTATE_EXPR in maybe_convert_cond, but to no avail. However, I did see cases (both in hand-written testcases and in the testsuite, e.g. g++.dg/ext/pr114409-2.C) where the subsequent call to condition_conversion would change the type (e.g. from int to bool), which shows the need for updating the types in the ANNOTATE_EXPR chain -- thanks for pointing that out, Jakub! Personally, I feel the handling of the flags (in this patch, as per Jakub's suggestion) is a bit of a premature optimization. It seems cleaner (and safer) to me just to re-build the annotations if needed (i.e. in the case that the type changed). You could even have a nice abstraction that encapsulates the stripping and re-building of ANNOTATE_EXPRs, so that it doesn't clutter the caller quite so much. However, I understand the desire to avoid re-allocating here (even if this should be a fairly uncommon case), hence this patch goes with the approach suggested by Jakub. I'm happy to be persuaded to do otherwise by C++ maintainers :) Bootstrapped/regtested on aarch64-linux-gnu, OK for trunk? Thanks, Alex -- >8 -- For the testcase added with this patch, we would end up losing the: #pragma GCC unroll 4 and emitting "warning: ignoring loop annotation". That warning comes from tree-cfg.cc:replace_loop_annotate, and means that we failed to process the ANNOTATE_EXPR in tree-cfg.cc:replace_loop_annotate_in_block. That function walks backwards over the GIMPLE in an exiting BB for a loop, skipping over the final gcond, and looks for any ANNOTATE_EXPRS immediately preceding the gcond. The function documents the following pre-condition: /* [...] We assume that the annotations come immediately before the condition in BB, if any. */ now looking at the exiting BB of the loop, we have: : D.4524 = .ANNOTATE (iftmp.1, 1, 4); retval.0 = D.4524; if (retval.0 != 0) goto ; [INV] else goto ; [INV] and crucially there is an intervening assignment between the gcond and the preceding .ANNOTATE ifn call. To see where this comes from, we can look to the IR given by -fdump-tree-original: if (<::operator() (&pred, *first), unroll 4>>>) goto ; else goto ; here the problem is that we've wrapped a CLEANUP_POINT_EXPR around the ANNOTATE_EXPR, meaning the ANNOTATE_EXPR is no longer the outermost expression in the condition. The CLEANUP_POINT_EXPR gets added by the following call chain: finish_while_stmt_cond -> maybe_convert_cond -> condition_conversion -> fold_build_cleanup_point_expr this patch chooses to fix the issue in maybe_convert_cond by walking through any ANNOTATE_EXPRs and doing any condition conversion on the inner expression, leaving the ANNOTATE_EXPRs (if any) as the outermost expressions in the condition. With this patch, we don't get any such warning and the loop gets unrolled as expected at -O2. gcc/cp/ChangeLog: PR libstdc++/116140 * semantics.cc (maybe_convert_cond): Ensure any ANNOTATE_EXPRs remain the outermost expression(s) of the condition. gcc/testsuite/ChangeLog: PR libstdc++/116140 * g++.dg/ext/pragma-unroll-lambda.C: New test. Co-Authored-By: Jakub Jelinek diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index e58612660c9..e128061e93d 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -966,25 +966,62 @@ maybe_convert_cond (tree cond) if (type_dependent_expression_p (cond)) return cond; + /* If the condition has any ANNOTATE_EXPRs, those must remain the outermost + expressions of the condition. Walk through these, performing the condition + conversion in place on the inner expression. */ + tree *condp = &cond; + while (TREE_CODE (*condp) == ANNOTATE_EXPR) + condp = &TREE_OPERAND (*condp, 0); + + tree orig_inner = *condp; + /* For structured binding used in condition, the conversion needs to be evaluated before the individual variables are initialized in the std::tuple_{size,elemenet} case. cp_finish_decomp saved the conversion result in a TARGET_EXPR, pick it up from there. */ - if (DECL_DECOMPOSITION_P (cond) - && DECL_DECOMP_IS_BASE (cond) - && DECL_DECOMP_BASE (cond) - && TREE_CODE (DECL_DECOMP_BASE (cond)) == TARGET_EXPR) - cond = TARGET_EXPR_SLOT (DECL_DECOMP_BASE (cond)); + if (DECL_DECOMPOSITION_P (*condp) + && DECL_DECOMP_IS_BASE (*condp) + && DECL_DECOMP_BASE (*condp) + && TREE_CODE (DECL_DECOMP_BASE (*condp)) == TARGET_EXPR) + *condp = TARGET_EXPR_SLOT (DECL_DECOMP_BASE (*condp)); if (warn_sequence_point && !processing_template_decl) - verify_sequence_points (cond); + verify_sequence_points (*condp); - maybe_warn_unparenthesized_assignment (cond, /*nested_p=*/false, + maybe_warn_unparenthesized_assignment (*condp, /*nested_p=*/false, tf_warning_or_error); /* Do the conversion. */ - cond = convert_from_reference (cond); - return condition_conversion (cond); + *condp = convert_from_reference (*condp); + *condp = condition_conversion (*condp); + + /* Either of the above two calls could have changed the type of *CONDP, in + which case the type (and possibly the flags) of any outer ANNOTATE_EXPRs + need updating. */ + if (TREE_TYPE (cond) != TREE_TYPE (*condp)) + { + /* If the type of *CONDP changed (e.g. due to convert_from_reference) then + the flags may have changed too. The logic in the loop below relies on + the flags only being changed in the following directions (if at all): + TREE_SIDE_EFFECTS : 0 -> 1 + TREE_READONLY : 1 -> 0 + thus avoiding re-computing the flags from scratch (e.g. via build3), so + let's verify that this precondition holds. */ +#define CHECK_FLAG_CHANGE(prop, value)\ + gcc_checking_assert (prop (orig_inner) == prop (*condp) || prop (*condp) == value) + CHECK_FLAG_CHANGE (TREE_SIDE_EFFECTS, 1); + CHECK_FLAG_CHANGE (TREE_READONLY, 0); +#undef CHECK_FLAG_CHANGE + for (tree c = cond; c != *condp; c = TREE_OPERAND (c, 0)) + { + gcc_checking_assert (TREE_CODE (c) == ANNOTATE_EXPR); + TREE_TYPE (c) = TREE_TYPE (*condp); + TREE_SIDE_EFFECTS (c) |= TREE_SIDE_EFFECTS (*condp); + TREE_READONLY (c) &= TREE_READONLY (*condp); + } + } + + return cond; } /* Finish an expression-statement, whose EXPRESSION is as indicated. */ diff --git a/gcc/testsuite/g++.dg/ext/pragma-unroll-lambda.C b/gcc/testsuite/g++.dg/ext/pragma-unroll-lambda.C new file mode 100644 index 00000000000..f410f6d8d25 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pragma-unroll-lambda.C @@ -0,0 +1,17 @@ +// { dg-do compile { target c++11 } } + +template +inline Iter +my_find(Iter first, Iter last, Pred pred) +{ +#pragma GCC unroll 4 + while (first != last && !pred(*first)) + ++first; + return first; +} + +short *use_find(short *p) +{ + auto pred = [](short x) { return x == 42; }; + return my_find(p, p + 1024, pred); +}