From patchwork Wed Dec 11 17:22:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunilkumar.dora@windriver.com X-Patchwork-Id: 53947 X-Patchwork-Delegate: steve@sakoman.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BFA9E7717D for ; Wed, 11 Dec 2024 17:23:15 +0000 (UTC) Received: from mx0b-0064b401.pphosted.com (mx0b-0064b401.pphosted.com [205.220.178.238]) by mx.groups.io with SMTP id smtpd.web10.336.1733937786193956559 for ; Wed, 11 Dec 2024 09:23:06 -0800 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: windriver.com, ip: 205.220.178.238, mailfrom: prvs=2075040ffa=sunilkumar.dora@windriver.com) Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BB6qCCv028259 for ; Wed, 11 Dec 2024 17:23:05 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 43cx4xcf1h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 11 Dec 2024 17:23:05 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=U2XzpkR75cWCIfrcDM3EWlZX1riC7eX6F1sv6UT0caYESDcZbLBw3Qhv7a5wmKVwTW7J5Tb1i6kZWVpDOCzsDOEfWtPxxZJE/KXp9QMLV3sZnAruRLJNvVcho9E2rpZ3nNdEKwbY96lyDBdO5+xjSsliuy/4dvvHlw17TFoiFHg7FHN38Z3YcVERyDq4xIB0fwLPwSNWpAL9msNDRhpivWzPKbC5QAmRSpp9hkKs+7Uf4YjZll+xsy+g6fgVRNJiPbz+xDj4Zb80wIPcLVV61Ayc1ARikNJ4p2H5ZcEwv9CO7YPUcQpnnZ4pNefaalsbV9f7RrAgx+YqyKdqtR7QJA== 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=aP/cz4YtBzmSVlsCKMVR2BQnTbVzyZb4I0tQd+2CGsY=; b=FvhuDKaQYvU3xD35NQYD9Z81trF/UrwPBwHArqcIxnq8RBFaUgd386J2sdAbwSV4TIbjhIQ7AzjZr46cnXX71SnKyBFVhH/rLCR3BYV6zsXP8tRcglQDjpv22Vo7sDxHjIvKrneEIb5BTjwSiP00V2s1kbFPBAq87oYFuAtDHjx6QEwpbKBQHCzaUvH+ilqCUOz/pe5hW7Bz0+lF6hQ/bu+nty9+Axf1V+QVyc3TxExULxfvI6MvTo3ktdzzwU/dgABxJET1p552bDZ08Q8Br86jSwVAd2vmgL/+I7+K2XsjMJmRzy+EN5hb4ZHhMt4SLLiRdNpUCIFlwErVSZ/uOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DS0PR11MB7901.namprd11.prod.outlook.com (2603:10b6:8:f4::20) by DM4PR11MB5232.namprd11.prod.outlook.com (2603:10b6:5:38b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Wed, 11 Dec 2024 17:22:57 +0000 Received: from DS0PR11MB7901.namprd11.prod.outlook.com ([fe80::9fa:eb3f:cf26:264d]) by DS0PR11MB7901.namprd11.prod.outlook.com ([fe80::9fa:eb3f:cf26:264d%5]) with mapi id 15.20.8251.008; Wed, 11 Dec 2024 17:22:57 +0000 From: sunilkumar.dora@windriver.com To: openembedded-core@lists.openembedded.org Cc: Randy.MacLeod@windriver.com, Naveen.Gowda@windriver.com, Sundeep.Kokkonda@windriver.com Subject: [styhead][PATCH] Backport: Fix c++: tweak for Wrange-loop-construct Date: Wed, 11 Dec 2024 09:22:42 -0800 Message-ID: <20241211172242.4040469-1-sunilkumar.dora@windriver.com> X-Mailer: git-send-email 2.43.0 X-ClientProxiedBy: SJ0PR03CA0128.namprd03.prod.outlook.com (2603:10b6:a03:33c::13) To DS0PR11MB7901.namprd11.prod.outlook.com (2603:10b6:8:f4::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7901:EE_|DM4PR11MB5232:EE_ X-MS-Office365-Filtering-Correlation-Id: 2230fa23-4614-4123-3a0d-08dd1a087441 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: P84qKz6oRIZv2Xuwfhy0VpgCrgKfbT+Ja658nbhC7h1XXDNhLe2F1YV/1cy+3nOzXPK/KJwLpYgigSfi3IRmvYpc/JsazDzmmNyqDp4Fpi8vhwn+GAcYBSnkj/Www8nHtgTz2z9rBLc6FtpVproOrJaK6T4QwO/cXHvO/HZ4Y8QJgUWCxMHiX21FzJ61FdmiAx6BqnrBUKGIIta8AIYeSwWI/XizpuJ6S0nHEFf/+r59fu+cpvcu0QNWLXlYsF2GJW10daN0XypUsZlK3c5ny53gaVobKAwSjIlwTs34779U7ZnsbIN1LEsE6Lj87IU5canGzTm23EghFgb8jmXs7mKKP56fGjh6tIyiw99WaO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V:NSPM;H:DS0PR11MB7901.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M5ZVv3YZSa+FfG3iu7XN3lobLuXZj890DvmaSrGaefymnb04Rrcap+8ipHf7qPnmQXyRAaedM/mJZjaEHfnrPiWBx1cn27XuKbSVP6XJvRs5suQY1t8kb4i4h6MI4ICL4n0MG25O/2pB7cRJl7XJHhSAHZIAlDDNSmG8scCdXYyLugeskuzq0dhaD/RgtD7ZcU3KNzzpgoNm+wtMjglUJHQAn1jjxPlbNSea8ASq2AXgiQO+GQTKufprW30yPlV1mFxKmXTvV7H8CU+hTb6gstpbL3kj3FiypBXdX+samGA97JZjp34BdANGTDQ4Q0vgeVZSWsgbyuoLuWfaf3hkrfURXA0bGFSs244is9dsp3y2LOvJxImlvQRyGeglIiTgIU+o49bqWG1OKe2heMCoUrhx0727fJkptN/witTa+V1WwNKaVDevl4Y3/ChJ6iIkgkgyPsHSHcOqHpBNn3lrZxfiiXvX4ZVWaQhmEaBvog3oqW9I3S9VzyCt0xusEDwdfiddZCjzqAjsvQzMb0nWyxJgftaIKs76VYWQ2S83Kl1HiZdx4fjpfrZVDciVIF6K7JeIG3YIr0kGpGrzHoiBzXlsx111uuu4A909TfQwoqgQ89QCMJiHKpC83cE9TETZrC6pwR9EnvzZ4baYQUKDxjv1BPrdWNTNvlteJXgWEF+8eNJY3TAm3pfPjIFG6kgxEZaisyvR9Yr4DskfBW+7wa4phYPYK+B88INDHhJWonLlepvUMEBzbfRlzy5TlqJaaoHBhtqcyHteQAp6TO/P5dZ5QfiHNHaX73KWIKu2lDlFnvbNdl6MMyAEc4zW78LEydBHXp8wXYCbLLbkiWSgksJGVut0dvOiS22sebW7C8f3RKfDbAAl07g9KoM4xbziCsygVGXtHd3rPOpJhP7U0IGNBsFl4NEQuS3Y9l5XJW1Ouxst40RXE4QaVMdsQvtGTz4HiszvxT9IsKqZD0E10i3ifqnmOJYT4XLMILZQWlvkx8Lo58AZPEW/GrZRYig/kt4XZ5oYcIWXb8v+n79+M/jw2FIoB/VtP+2qtzQVvOXhZgpe53D2d25R0wyMw7Y71NEdKqls6KUe+HErrjvxlJy805amPlwxdy23gvc7SlrYTuCfoesP2D20h6117UGmvSrbX/Tf4V9PaQhU9V69Uvx/+Wg5rtl8182923iqK91EyeUdVOpB5u+55WhauoovqT9kQfIbQwPcsvpvQLKdPS8JAcfTOkB7RTGXsXrSu+wt3JW0qQA2vquDVhYcD5Nog1v6nsPTckfsSLHAtCcpUWNrUUVEGNGXvB74oeD/9r6mpL+cxH3jJsn+1PGid3RVFb22gBK2RKBPQr+CXBJ3IU4/KV0clZZOIeCpM4IPBgAoV4yt6vK46dTDyErzVzDXcLEY8vfby1KBhZDCW6f/v6GKIyVplGKD9vzVtT5p772insk7UcOme1bD8RL4IB79GRqO2h2nYXf53CTjvhHHFkvHt2E/2AsPq03RCrv41W69JaWeWNZSEmc98/OwQWOhS0LoYBLnbTUk0PVzDxJAsb4rOaT7nfqcGS33L3y9poGy21tCRQDk2DaUlshAoSWiE7mKlv8PbUiCy7mwwLDIJQ== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2230fa23-4614-4123-3a0d-08dd1a087441 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7901.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 17:22:57.0334 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4U9TVK9pSlGMCRUB5r61IPRtFg8SJccuGLABPONLIhB/8iwUwyURKSI87DXoTM8dhn8TzrdY9lEWnquDUEbAoHLUb+dxSP0NObmFSQyLf2A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5232 X-Proofpoint-GUID: UfqlZ_3S99unBh7grx9StjQ8U5f6ZH-6 X-Proofpoint-ORIG-GUID: UfqlZ_3S99unBh7grx9StjQ8U5f6ZH-6 X-Authority-Analysis: v=2.4 cv=Y/UCsgeN c=1 sm=1 tr=0 ts=6759ca79 cx=c_pps a=AVVanhwSUc+LQPSikfBlbg==:117 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=RZcAm9yDv7YA:10 a=bRTqI5nwn0kA:10 a=NEAV23lmAAAA:8 a=mDV3o1hIAAAA:8 a=t7CeM3EgAAAA:8 a=20KFwNOVAAAA:8 a=USuHR67c37jO-1kvC0cA:9 a=FdTzh2GWekK77mhwV6Dw:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-11_11,2024-12-10_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.21.0-2411120000 definitions=main-2412110125 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 11 Dec 2024 17:23:15 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/208598 From: Sunil Dora This commit updates the warning to use a check for "trivially constructible" instead of "trivially copyable." The original check was incorrect, as "trivially copyable" only applies to types that can be copied trivially, whereas "trivially constructible" is the correct check for types that can be trivially default-constructed. This change ensures the warning is more accurate and aligns with the proper type traits. LLVM accepted a similar fix: https://github.com/llvm/llvm-project/issues/47355 PR c++/116731 [https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116731] Upstream-Status: Backport [https://gcc.gnu.org/g:6ac4e2f4b2ca9980670e7d3815a9140730df1005] Signed-off-by: Marek Polacek Signed-off-by: Sunil Dora --- meta/recipes-devtools/gcc/gcc-14.2.inc | 1 + ...ix-c-tweak-for-Wrange-loop-construct.patch | 114 ++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 meta/recipes-devtools/gcc/gcc/0026-Backport-Fix-c-tweak-for-Wrange-loop-construct.patch diff --git a/meta/recipes-devtools/gcc/gcc-14.2.inc b/meta/recipes-devtools/gcc/gcc-14.2.inc index e90b5b4c2a..1378cfc1c3 100644 --- a/meta/recipes-devtools/gcc/gcc-14.2.inc +++ b/meta/recipes-devtools/gcc/gcc-14.2.inc @@ -68,6 +68,7 @@ SRC_URI = "${BASEURI} \ file://0023-Fix-install-path-of-linux64.h.patch \ file://0024-Avoid-hardcoded-build-paths-into-ppc-libgcc.patch \ file://0025-gcc-testsuite-tweaks-for-mips-OE.patch \ + file://0026-Backport-Fix-c-tweak-for-Wrange-loop-construct.patch \ file://gcc.git-ab884fffe3fc82a710bea66ad651720d71c938b8.patch \ " diff --git a/meta/recipes-devtools/gcc/gcc/0026-Backport-Fix-c-tweak-for-Wrange-loop-construct.patch b/meta/recipes-devtools/gcc/gcc/0026-Backport-Fix-c-tweak-for-Wrange-loop-construct.patch new file mode 100644 index 0000000000..0a2db4e36a --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc/0026-Backport-Fix-c-tweak-for-Wrange-loop-construct.patch @@ -0,0 +1,114 @@ +From acc5e13c2ea91d2a138c03cd9e5d8826a1a74e4d Mon Sep 17 00:00:00 2001 +From: Sunil Dora +Date: Wed, 11 Dec 2024 00:09:43 -0800 +Subject: [PATCH] Backport: Fix c++: tweak for Wrange-loop-construct + +This commit updates the warning to use a check for "trivially constructible" instead of +"trivially copyable." The original check was incorrect, as "trivially copyable" only applies +to types that can be copied trivially, whereas "trivially constructible" is the correct check +for types that can be trivially default-constructed. + +This change ensures the warning is more accurate and aligns with the proper type traits. + +LLVM accepted a similar fix: +https://github.com/llvm/llvm-project/issues/47355 + +PR c++/116731 [https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116731] + +Upstream-Status: Backport [https://gcc.gnu.org/g:6ac4e2f4b2ca9980670e7d3815a9140730df1005] + +Signed-off-by: Marek Polacek +Signed-off-by: Sunil Dora +--- + gcc/cp/parser.cc | 8 ++- + .../g++.dg/warn/Wrange-loop-construct3.C | 57 +++++++++++++++++++ + 2 files changed, 62 insertions(+), 3 deletions(-) + create mode 100644 gcc/testsuite/g++.dg/warn/Wrange-loop-construct3.C + +diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc +index 7e81c1010..8206489a2 100644 +--- a/gcc/cp/parser.cc ++++ b/gcc/cp/parser.cc +@@ -14301,11 +14301,13 @@ warn_for_range_copy (tree decl, tree expr) + else if (!CP_TYPE_CONST_P (type)) + return; + +- /* Since small trivially copyable types are cheap to copy, we suppress the +- warning for them. 64B is a common size of a cache line. */ ++ /* Since small trivially constructible types are cheap to construct, we ++ suppress the warning for them. 64B is a common size of a cache line. */ ++ tree vec = make_tree_vec (1); ++ TREE_VEC_ELT (vec, 0) = TREE_TYPE (expr); + if (TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST + || (tree_to_uhwi (TYPE_SIZE_UNIT (type)) <= 64 +- && trivially_copyable_p (type))) ++ && is_trivially_xible (INIT_EXPR, type, vec))) + return; + + /* If we can initialize a reference directly, suggest that to avoid the +diff --git a/gcc/testsuite/g++.dg/warn/Wrange-loop-construct3.C b/gcc/testsuite/g++.dg/warn/Wrange-loop-construct3.C +new file mode 100644 +index 000000000..3d9d0c908 +--- /dev/null ++++ b/gcc/testsuite/g++.dg/warn/Wrange-loop-construct3.C +@@ -0,0 +1,57 @@ ++// PR c++/116731 ++// { dg-do compile { target c++11 } } ++// { dg-options "-Wrange-loop-construct" } ++ ++void ++f0 () ++{ ++ struct S { ++ char a[64]; ++ S& operator=(const S&) { return *this; }; ++ }; ++ ++ S arr[8]; ++ for (const auto r : arr) ++ (void) r; ++} ++ ++void ++f1 () ++{ ++ struct S { ++ char a[65]; ++ S& operator=(const S&) { return *this; }; ++ }; ++ ++ S arr[8]; ++ for (const auto r : arr) // { dg-warning "creates a copy" } ++ (void) r; ++} ++ ++void ++f2 () ++{ ++ struct S { ++ char a[64]; ++ S& operator=(const S&) { return *this; }; ++ ~S() { } ++ }; ++ ++ S arr[8]; ++ for (const auto r : arr) // { dg-warning "creates a copy" } ++ (void) r; ++} ++ ++void ++f3 () ++{ ++ struct S { ++ char a[65]; ++ S& operator=(const S&) { return *this; }; ++ ~S() { } ++ }; ++ ++ S arr[8]; ++ for (const auto r : arr) // { dg-warning "creates a copy" } ++ (void) r; ++} +-- +2.43.0 +