From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 6C77B385842B; Wed, 9 Nov 2022 16:51:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C77B385842B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A9GjlQ8023752; Wed, 9 Nov 2022 16:51:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=corp-2022-7-12; bh=FqM3WJOUjEUwnGfOCa2f4zqE9nYVBDoQ5jlD5PYdFck=; b=X30SWQEkNc2pdNC/nux2Jyoim+k7oqdWlHtyaFNUlWBIARQ4KnqD8ZQE77zqVRyA50me XZ2kmieqmu6etavBjAoQASq28FcJ+T/S6sCs9Rr236av6hCqFuUEKCVgVpdi7De3CqSk CR5KipFENcptc+ZV4ZskbXakPy/TWmcMrWbB8ySsJFMHCzHocdCsFZlIf+32LHJsEr3w MFBjk2yJzdo8inHbXN/RLOQLH9MOt1OHKQyPzeWRMOIcQK70zlQhTXOqnp3JAU68BbiY TtHaeCjMrKWHpjs8mKslkRKzRgS4BE3DkW4DaLh7iZIXiwYDmVS1JMiIA887OzMqomfI vg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3krg0fg020-54 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Nov 2022 16:51:19 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2A9FgrsX000381; Wed, 9 Nov 2022 15:50:37 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2176.outbound.protection.outlook.com [104.47.55.176]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kpcsf53e3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Nov 2022 15:50:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FXOru2hljA9hi3Z4qXwhhUr2dzwpv0N4fttKdXHFZgZqVIw/OgrChrjCGph9o8Wkg6Rjnyip2AAhE/QTAuoWnQn06eUm83k8YkPFUTC9L0S1Fk13DRYqaJGBE5DZxZfX/dOuVG1r761mttsJl1yEW2CX+RzReOTN+ulX14vihrTymTTKCOltJKkAkGyCz4ZY14IBbCnxgPRXn2F1moam8vxiszhHc9RP1Cr2Gfwk7ZZINt6RZz/IKAC17M1n/wkBtdgBIyUL3BQ5kD8vgRh101PB5+NqypQ0je33YtwlA71A7U7+Cqhxst8ZElRohkZTMiP48mh4I8wYsG9XCC/XHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=FqM3WJOUjEUwnGfOCa2f4zqE9nYVBDoQ5jlD5PYdFck=; b=GLFoSUEz0U2DNYRxEddI1RVobUXhr5rZ0svzL6o2nXigftY966yCilLpvGT40GVrcmUnW4N2N9ivtlr2Jl9k4kcYPcw5XzAB/pJPohFQ8qwGgy1L7yZHoARW3Bx7geq4R2hC/Zy63lB49isYtm6etsGCPWT+fcopXEUHeeHQtajBSBzogbkMUdKOvfxbr666/34nKapD9RrJ3M5bcu7H7mbDx9RjvwKeWudN1COTU5zeLwGb73bOAgOWfuAETNsvzT8bH4J5JRkqztD2qyHSh6+qnCYeY+WJWa+9Hp9omzreEUb7v5csBaba8cOCKpStekyPEkd+pn0/vhfjgD+nRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FqM3WJOUjEUwnGfOCa2f4zqE9nYVBDoQ5jlD5PYdFck=; b=coYR0LbhpxdK4szhhbyAGJmqcrdKMieJACEI9ivKFoGNrjinyDtFzo5NJIMPuPSEVS201dYwNhsAa71ekRForqYlVwZYDs+Bjp/O4DM1h3TAs4WBkFgHjF2IpVBCqXejw1IEOrkX5cc6253+2Z9oAtdI5ypivlqnaPFKKot1feY= Received: from CH2PR10MB4344.namprd10.prod.outlook.com (2603:10b6:610:af::19) by SJ0PR10MB6328.namprd10.prod.outlook.com (2603:10b6:a03:44e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.26; Wed, 9 Nov 2022 15:50:34 +0000 Received: from CH2PR10MB4344.namprd10.prod.outlook.com ([fe80::9423:79b3:c0dc:1113]) by CH2PR10MB4344.namprd10.prod.outlook.com ([fe80::9423:79b3:c0dc:1113%7]) with mapi id 15.20.5813.012; Wed, 9 Nov 2022 15:50:34 +0000 From: Qing Zhao To: Richard Biener CC: "joseph@codesourcery.com" , gcc Patches , Kees Cook , "siddhesh@gcc.gnu.org" Subject: Re: [PATCH 1/2] Change the name of array_at_struct_end_p to array_ref_flexible_size_p Thread-Topic: [PATCH 1/2] Change the name of array_at_struct_end_p to array_ref_flexible_size_p Thread-Index: AQHY84GPITd1GuKN8keb1zYqAjDdh642OrcAgACERwA= Date: Wed, 9 Nov 2022 15:50:34 +0000 Message-ID: <6D12715C-60C5-42DE-8F0A-4C5BBAAC5D5F@oracle.com> References: <20221108145113.955321-1-qing.zhao@oracle.com> <20221108145113.955321-2-qing.zhao@oracle.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Apple Mail (2.3696.120.41.1.1) x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CH2PR10MB4344:EE_|SJ0PR10MB6328:EE_ x-ms-office365-filtering-correlation-id: 6ba3b4d5-4f64-4c62-1c60-08dac26a239e x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: NdHV+cGmDkOQqAGFZ2WXwTNL89dEi2RDO3bjTO26tn/hMDuWBHsQQN1YJxBDPVscQUPobmSywYAeIkYxCC4w+RIIgko/pitvpWwI9waH0j2lFe02WiO2QMsaUJslLhV9jovGu9CJ0yxsxKNqIhqXSImXOpK6Kc1hOIYGS2rSY9zTHDzexeKCsdjklBjM4a4/Yt/kxyzPvWlivJbpF27/MLAUlHdtHMTxR+e2PgPXUrBCBhPUspD/9TmZ37VJDmkalqh8QrkY3yZTJ72ZyQQfu4YEn8u4rWSKkCsyMCnsMRcQg+gfB32RqeQPup1Yb7oN6TNXiLH3kPPuv49IA2dSB3kPf0ZX2w8lBZ9kGHwu0DxA0zw+YJBr54ystbr5SNeRzQrwg8Wotbt7gUPbUUAgxVbCRu7PRYjnI7+abwpS0BxTZu1J39mgMP3HO9kdJ1aEMGA95cBauO9KMrKWzjCCy3zOAhD368kv2/hPuDXRPEuSK6rzPO+y0kk9RqGZeOh2i1eJnWtengVY+53x3wT4miCEtv454cGOmbIL54WSXLWldxEGqFQ+/ZcY4g/VTxkVnTVSZv/KMqta3BE0mD9Ko8MD2Cx+JZoayYat8b7hGlxEfRe33C+TgFdKJ/C/Blr2bQk4WLhEKECb4SmW9z53twCiICZq47qsV/ANaKf2TBsZgFgucrPbDeo1a0HzRZ5k+76/lnq7Fxeu0YN8LXlSG1DW1JbY3Ic2dr/ph6oiJYDa75pqHGRrtwp3RycrfcXVE9LFVsXHce0rZBOIHwwPwypiM68C/N5CRHUbsbAVFi1g5DqEDzNc+PBdpDpD7lBp x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH2PR10MB4344.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(136003)(376002)(346002)(396003)(366004)(39860400002)(451199015)(2616005)(36756003)(33656002)(6506007)(122000001)(38100700002)(38070700005)(83380400001)(4326008)(2906002)(30864003)(44832011)(86362001)(186003)(8676002)(66556008)(91956017)(66446008)(64756008)(53546011)(54906003)(6916009)(66946007)(76116006)(71200400001)(966005)(6512007)(316002)(41300700001)(8936002)(5660300002)(66476007)(478600001)(6486002)(45980500001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?AlKGHI0JXdbuf97J2j+nkGpyFsJaD5J5Zrqgn1KicdmtqCy/ET+/3lKgU8Q/?= =?us-ascii?Q?hjvGAjUFofASlbSdtHlo7adw7tyd5ugjmHiJJMKSIjtgGJY8KjivkfT2qQto?= =?us-ascii?Q?mM6assYgYbl/ryz2ZJ5tcgTdes+5OwDF8E73WN+wle/DMThsP3HbxRAu3Wep?= =?us-ascii?Q?5GjSeS7xMvmTkuK3mLXsGgTtKO3qhNGDi2JhmjqHaA7VLB3iHcMa/TbyQPZw?= =?us-ascii?Q?kz7oSP6DTK/D6rgNppNc2nPg1wjrBDRAfRa0R+YHhg+nIVeyTckfAwtqUFRO?= =?us-ascii?Q?Eyslp6wAc8wYv7/yOHPM8mi4oXa9jqVmE6ZyJkhnZcHvagpzn8/RnDosUmzO?= =?us-ascii?Q?8rt1fNn/APuFOoNyKGQJ0SkYZrZW6bnoHk7SkiRjLWXajsfpeq8C6//oc/nI?= =?us-ascii?Q?opS3iJGfxDoPr1j3yTaD5nI7mEK1dvpgcoBXfqdn+tuIc1Sn4t/9PRmXLH0J?= =?us-ascii?Q?CQ78cOwaxtSkjXdQoCfNW1fmskbPGRfnE/VrRdqL/vXyNHsNFKMfeJTxwhK4?= =?us-ascii?Q?pwAyFDkNj2Upu1hXn1eKMpYKfZBHh9V9D/9taYOEqVFXqaYuQTpwoy8mLen1?= =?us-ascii?Q?Qq93sR1FMBhJGBI4KPo+zWyEIJMDejANPvODUKVMLGiJr3Yo88z9EJdVzMJD?= =?us-ascii?Q?T6IMavWjm9OkT9mHIq46w0YXhrBS98EtIna1WzlcLrihaWCQJeLAs7UDk/Vb?= =?us-ascii?Q?7VgIHvSszOWOJc41zjZgjfahbtb1HTvJsyqXqIk/7DdIgjyYU4sXuqyjAoTY?= =?us-ascii?Q?8tiBPJ9iUctRyiWHGrFbTP9w3xGSt53O+VVKLCKZPdkXIkLz7BmUb9rs3Xsi?= =?us-ascii?Q?5BCehfEhwrW8j5vUeJov/6GK67nZDdm/cOvuIadGfxv1Qz/+CcJjQlPGfRPV?= =?us-ascii?Q?9e39c1VaCaBnf7aYhYSyVjizVLndUwWTK1kAwVziFOqFPBQ+pMfuYRmdeaiG?= =?us-ascii?Q?Rphvk3RcXU2MBtgJg12NoPoH49lpDc/FK9ZoFvIk9tFzDwQ5fxZ/9s+XGndm?= =?us-ascii?Q?kf4ebtofES7guc/XlyVKcgRvwfi5/bH9Y2kJS/lihsKAVuIpWNgCMrLLJ9K1?= =?us-ascii?Q?gCXaSNQW1ihPfzfvgBACViegC5NFS+PUvfqsowX1clnEWOLoFU1bjfY83Rx1?= =?us-ascii?Q?5HbO1fAKw8WM/FTpxawhtzLvcXfisH0eJl88X0ptFdMn5vPNi7jfshS4IGgF?= =?us-ascii?Q?4JL1AfG2fMEqZ3huiOed7aoLMXfvt5AlkEJ3geT0ySxq1R1Rwr/TciAUK8MS?= =?us-ascii?Q?APih08d5EY+/Z/jUtoQ+5Utlaj4E3CDWmgT9/wycoQ7Yy7rOSr6+7MHdHBoc?= =?us-ascii?Q?ZPbJaqMBk4sW3N8Gx7enDCeHuqhgBfbwFnbBsDuCGnNI8STntSFJXMStnbfk?= =?us-ascii?Q?FIrAmaa6ZpT7aiAYJSjgFZ4GhRty8vkS7PmQnIxrXc/yYQMmihsKuRpn3mVz?= =?us-ascii?Q?HfC7ol0RMtbt902TuRJ2rGZ5lBD+Uo0RJqAJUr6hJNVtycKd1UYDHGwvPP4W?= =?us-ascii?Q?AUIGNEtCmvrk9lvlKYU6cBZBE93gItb1IN2E5uvWubGBNvN4enS7UA9KUzJW?= =?us-ascii?Q?1RmwyewSpx2dQsKStJ2aqchY7xk3KBQkN950T+4VyQVPK8d2FIrDzIXbOGb5?= =?us-ascii?Q?xdE8ElToGmuU21iQ673WdIk=3D?= Content-Type: text/plain; charset="us-ascii" Content-ID: <930E7BB411A6F0459A58EA6A17CF9474@namprd10.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4344.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ba3b4d5-4f64-4c62-1c60-08dac26a239e X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2022 15:50:34.5764 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 00EdfVQ550U4ExQmsxt8TYT7pLVhNa3EyYSqMJwOZixtpAMoKMzrTzzq98QVrHKHvCnxKaE0zX6OWWPYaR9BSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB6328 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-09_06,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211090120 X-Proofpoint-ORIG-GUID: xE_CDxLY2a1VtJpyLHqDhPM9K4bsVGeL X-Proofpoint-GUID: xE_CDxLY2a1VtJpyLHqDhPM9K4bsVGeL X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Thanks. Committed as: https://gcc.gnu.org/pipermail/gcc-cvs/2022-November/373830.h= tml Qing > On Nov 9, 2022, at 2:57 AM, Richard Biener wrote: >=20 > On Tue, 8 Nov 2022, Qing Zhao wrote: >=20 >> The name of the utility routine "array_at_struct_end_p" is misleading >> and should be changed to a new name that more accurately reflects its >> real meaning. >>=20 >> The routine "array_at_struct_end_p" is used to check whether an array >> reference is to an array whose actual size might be larger than its >> upper bound implies, which includes 3 different cases: >>=20 >> A. a ref to a flexible array member at the end of a structure; >> B. a ref to an array with a different type against the original decl; >> C. a ref to an array that was passed as a parameter; >>=20 >> The old name only reflects the above case A, therefore very confusing >> when reading the corresponding gcc source code. >>=20 >> In this patch, A new name "array_ref_flexible_size_p" is used to replace >> the old name. >>=20 >> All the references to the routine "array_at_struct_end_p" was replaced >> with this new name, and the corresponding comments were updated to make >> them clean and consistent. >=20 > Since you seem to feel strongly about this - OK. >=20 > Thanks, > Richard. >=20 >> gcc/ChangeLog: >>=20 >> * gimple-array-bounds.cc (trailing_array): Replace >> array_at_struct_end_p with new name and update comments. >> * gimple-fold.cc (get_range_strlen_tree): Likewise. >> * gimple-ssa-warn-restrict.cc (builtin_memref::builtin_memref): >> Likewise. >> * graphite-sese-to-poly.cc (bounds_are_valid): Likewise. >> * tree-if-conv.cc (idx_within_array_bound): Likewise. >> * tree-object-size.cc (addr_object_size): Likewise. >> * tree-ssa-alias.cc (component_ref_to_zero_sized_trailing_array_p): >> Likewise. >> (stmt_kills_ref_p): Likewise. >> * tree-ssa-loop-niter.cc (idx_infer_loop_bounds): Likewise. >> * tree-ssa-strlen.cc (maybe_set_strlen_range): Likewise. >> * tree.cc (array_at_struct_end_p): Rename to ... >> (array_ref_flexible_size_p): ... this. >> (component_ref_size): Replace array_at_struct_end_p with new name. >> * tree.h (array_at_struct_end_p): Rename to ... >> (array_ref_flexible_size_p): ... this. >> --- >> gcc/gimple-array-bounds.cc | 4 ++-- >> gcc/gimple-fold.cc | 6 ++---- >> gcc/gimple-ssa-warn-restrict.cc | 5 +++-- >> gcc/graphite-sese-to-poly.cc | 4 ++-- >> gcc/tree-if-conv.cc | 7 +++---- >> gcc/tree-object-size.cc | 2 +- >> gcc/tree-ssa-alias.cc | 8 ++++---- >> gcc/tree-ssa-loop-niter.cc | 15 +++++++-------- >> gcc/tree-ssa-strlen.cc | 2 +- >> gcc/tree.cc | 11 ++++++----- >> gcc/tree.h | 8 ++++---- >> 11 files changed, 35 insertions(+), 37 deletions(-) >>=20 >> diff --git a/gcc/gimple-array-bounds.cc b/gcc/gimple-array-bounds.cc >> index e190b93aa85..fbf448e045d 100644 >> --- a/gcc/gimple-array-bounds.cc >> +++ b/gcc/gimple-array-bounds.cc >> @@ -129,7 +129,7 @@ get_ref_size (tree arg, tree *pref) >> } >>=20 >> /* Return true if REF is (likely) an ARRAY_REF to a trailing array membe= r >> - of a struct. It refines array_at_struct_end_p by detecting a pointe= r >> + of a struct. It refines array_ref_flexible_size_p by detecting a po= inter >> to an array and an array parameter declared using the [N] syntax (as >> opposed to a pointer) and returning false. Set *PREF to the decl or >> expression REF refers to. */ >> @@ -167,7 +167,7 @@ trailing_array (tree arg, tree *pref) >> return false; >> } >>=20 >> - return array_at_struct_end_p (arg); >> + return array_ref_flexible_size_p (arg); >> } >>=20 >> /* Checks one ARRAY_REF in REF, located at LOCUS. Ignores flexible >> diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc >> index 9055cd8982d..cafd331ca98 100644 >> --- a/gcc/gimple-fold.cc >> +++ b/gcc/gimple-fold.cc >> @@ -1690,13 +1690,11 @@ get_range_strlen_tree (tree arg, bitmap visited,= strlen_range_kind rkind, >> /* Handle a MEM_REF into a DECL accessing an array of integers, >> being conservative about references to extern structures with >> flexible array members that can be initialized to arbitrary >> - numbers of elements as an extension (static structs are okay). >> - FIXME: Make this less conservative -- see >> - component_ref_size in tree.cc. */ >> + numbers of elements as an extension (static structs are okay). *= / >> tree ref =3D TREE_OPERAND (TREE_OPERAND (arg, 0), 0); >> if ((TREE_CODE (ref) =3D=3D PARM_DECL || VAR_P (ref)) >> && (decl_binds_to_current_def_p (ref) >> - || !array_at_struct_end_p (arg))) >> + || !array_ref_flexible_size_p (arg))) >> { >> /* Fail if the offset is out of bounds. Such accesses >> should be diagnosed at some point. */ >> diff --git a/gcc/gimple-ssa-warn-restrict.cc b/gcc/gimple-ssa-warn-restr= ict.cc >> index b7ed15c8902..832456ba6fc 100644 >> --- a/gcc/gimple-ssa-warn-restrict.cc >> +++ b/gcc/gimple-ssa-warn-restrict.cc >> @@ -296,8 +296,9 @@ builtin_memref::builtin_memref (pointer_query &ptrqr= y, gimple *stmt, tree expr, >> tree basetype =3D TREE_TYPE (base); >> if (TREE_CODE (basetype) =3D=3D ARRAY_TYPE) >> { >> - if (ref && array_at_struct_end_p (ref)) >> - ; /* Use the maximum possible offset for last member arrays. */ >> + if (ref && array_ref_flexible_size_p (ref)) >> + ; /* Use the maximum possible offset for an array that might >> + have flexible size. */ >> else if (tree basesize =3D TYPE_SIZE_UNIT (basetype)) >> if (TREE_CODE (basesize) =3D=3D INTEGER_CST) >> /* Size could be non-constant for a variable-length type such >> diff --git a/gcc/graphite-sese-to-poly.cc b/gcc/graphite-sese-to-poly.cc >> index 51ba3af204f..7eb24c1c991 100644 >> --- a/gcc/graphite-sese-to-poly.cc >> +++ b/gcc/graphite-sese-to-poly.cc >> @@ -536,9 +536,9 @@ bounds_are_valid (tree ref, tree low, tree high) >> || !tree_fits_shwi_p (high)) >> return false; >>=20 >> - /* 1-element arrays at end of structures may extend over >> + /* An array that has flexible size may extend over >> their declared size. */ >> - if (array_at_struct_end_p (ref) >> + if (array_ref_flexible_size_p (ref) >> && operand_equal_p (low, high, 0)) >> return false; >>=20 >> diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc >> index a83b013d2ad..34bb507ff3b 100644 >> --- a/gcc/tree-if-conv.cc >> +++ b/gcc/tree-if-conv.cc >> @@ -763,10 +763,9 @@ idx_within_array_bound (tree ref, tree *idx, void *= dta) >> if (TREE_CODE (ref) !=3D ARRAY_REF) >> return false; >>=20 >> - /* For arrays at the end of the structure, we are not guaranteed that= they >> - do not really extend over their declared size. However, for array= s of >> - size greater than one, this is unlikely to be intended. */ >> - if (array_at_struct_end_p (ref)) >> + /* For arrays that might have flexible sizes, it is not guaranteed th= at they >> + do not extend over their declared size. */ >> + if (array_ref_flexible_size_p (ref)) >> return false; >>=20 >> ev =3D analyze_scalar_evolution (loop, *idx); >> diff --git a/gcc/tree-object-size.cc b/gcc/tree-object-size.cc >> index 1f04cb80fd0..2e5d267d8ce 100644 >> --- a/gcc/tree-object-size.cc >> +++ b/gcc/tree-object-size.cc >> @@ -633,7 +633,7 @@ addr_object_size (struct object_size_info *osi, cons= t_tree ptr, >> v =3D NULL_TREE; >> break; >> } >> - is_flexible_array_mem_ref =3D array_at_struct_end_p (v); >> + is_flexible_array_mem_ref =3D array_ref_flexible_size_p (v); >> while (v !=3D pt_var && TREE_CODE (v) =3D=3D COMPONENT_REF) >> if (TREE_CODE (TREE_TYPE (TREE_OPERAND (v, 0))) >> !=3D UNION_TYPE >> diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc >> index b4c65da5718..d3a91b1f238 100644 >> --- a/gcc/tree-ssa-alias.cc >> +++ b/gcc/tree-ssa-alias.cc >> @@ -1073,7 +1073,7 @@ component_ref_to_zero_sized_trailing_array_p (tree= ref) >> && TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 1))) =3D=3D ARRAY_TYPE >> && (!TYPE_SIZE (TREE_TYPE (TREE_OPERAND (ref, 1))) >> || integer_zerop (TYPE_SIZE (TREE_TYPE (TREE_OPERAND (ref, 1))))) >> - && array_at_struct_end_p (ref)); >> + && array_ref_flexible_size_p (ref)); >> } >>=20 >> /* Worker for aliasing_component_refs_p. Most parameters match parameter= s of >> @@ -3433,10 +3433,10 @@ stmt_kills_ref_p (gimple *stmt, ao_ref *ref) >> } >> /* Finally check if the lhs has the same address and size as the >> base candidate of the access. Watch out if we have dropped >> - an array-ref that was at struct end, this means ref->ref may >> - be outside of the TYPE_SIZE of its base. */ >> + an array-ref that might have flexible size, this means ref->ref >> + may be outside of the TYPE_SIZE of its base. */ >> if ((! innermost_dropped_array_ref >> - || ! array_at_struct_end_p (innermost_dropped_array_ref)) >> + || ! array_ref_flexible_size_p (innermost_dropped_array_ref)) >> && (lhs =3D=3D base >> || (((TYPE_SIZE (TREE_TYPE (lhs)) >> =3D=3D TYPE_SIZE (TREE_TYPE (base))) >> diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc >> index 4ffcef4f4ff..3fbbf4367ed 100644 >> --- a/gcc/tree-ssa-loop-niter.cc >> +++ b/gcc/tree-ssa-loop-niter.cc >> @@ -3716,18 +3716,17 @@ idx_infer_loop_bounds (tree base, tree *idx, voi= d *dta) >> struct ilb_data *data =3D (struct ilb_data *) dta; >> tree ev, init, step; >> tree low, high, type, next; >> - bool sign, upper =3D true, at_end =3D false; >> + bool sign, upper =3D true, has_flexible_size =3D false; >> class loop *loop =3D data->loop; >>=20 >> if (TREE_CODE (base) !=3D ARRAY_REF) >> return true; >>=20 >> - /* For arrays at the end of the structure, we are not guaranteed that= they >> - do not really extend over their declared size. However, for array= s of >> - size greater than one, this is unlikely to be intended. */ >> - if (array_at_struct_end_p (base)) >> + /* For arrays that might have flexible sizes, it is not guaranteed th= at they >> + do not really extend over their declared size. */=20 >> + if (array_ref_flexible_size_p (base)) >> { >> - at_end =3D true; >> + has_flexible_size =3D true; >> upper =3D false; >> } >>=20 >> @@ -3760,9 +3759,9 @@ idx_infer_loop_bounds (tree base, tree *idx, void = *dta) >> sign =3D tree_int_cst_sign_bit (step); >> type =3D TREE_TYPE (step); >>=20 >> - /* The array of length 1 at the end of a structure most likely extend= s >> + /* The array that might have flexible size most likely extends >> beyond its bounds. */ >> - if (at_end >> + if (has_flexible_size >> && operand_equal_p (low, high, 0)) >> return true; >>=20 >> diff --git a/gcc/tree-ssa-strlen.cc b/gcc/tree-ssa-strlen.cc >> index 5afbae1b72e..b87c7c7ce1f 100644 >> --- a/gcc/tree-ssa-strlen.cc >> +++ b/gcc/tree-ssa-strlen.cc >> @@ -1987,7 +1987,7 @@ maybe_set_strlen_range (tree lhs, tree src, tree b= ound) >> suggests if it's treated as a poor-man's flexible array member. */ >> src =3D TREE_OPERAND (src, 0); >> if (TREE_CODE (src) !=3D MEM_REF >> - && !array_at_struct_end_p (src)) >> + && !array_ref_flexible_size_p (src)) >> { >> tree type =3D TREE_TYPE (src); >> tree size =3D TYPE_SIZE_UNIT (type); >> diff --git a/gcc/tree.cc b/gcc/tree.cc >> index 04603c8c902..d2b0b34a725 100644 >> --- a/gcc/tree.cc >> +++ b/gcc/tree.cc >> @@ -12710,8 +12710,8 @@ array_ref_up_bound (tree exp) >> return NULL_TREE; >> } >>=20 >> -/* Returns true if REF is an array reference, component reference, >> - or memory reference to an array whose actual size might be larger >> +/* Returns true if REF is an array reference, a component reference, >> + or a memory reference to an array whose actual size might be larger >> than its upper bound implies, there are multiple cases: >> A. a ref to a flexible array member at the end of a structure; >> B. a ref to an array with a different type against the original decl; >> @@ -12726,10 +12726,10 @@ array_ref_up_bound (tree exp) >> int test (uint8_t *p, uint32_t t[1][1], int n) { >> for (int i =3D 0; i < 4; i++, p++) >> t[i][0] =3D ...; >> +*/ >>=20 >> - FIXME, the name of this routine need to be changed to be more accura= te. */ >> bool >> -array_at_struct_end_p (tree ref) >> +array_ref_flexible_size_p (tree ref) >> { >> /* the TYPE for this array referece. */ >> tree atype =3D NULL_TREE; >> @@ -12862,6 +12862,7 @@ array_at_struct_end_p (tree ref) >> return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true; >> } >>=20 >> + >> /* Return a tree representing the offset, in bytes, of the field referen= ced >> by EXP. This does not include any offset in DECL_FIELD_BIT_OFFSET. = */ >>=20 >> @@ -12957,7 +12958,7 @@ component_ref_size (tree ref, special_array_memb= er *sam /* =3D NULL */) >> return (tree_int_cst_equal (memsize, TYPE_SIZE_UNIT (memtype)) >> ? memsize : NULL_TREE); >>=20 >> - bool trailing =3D array_at_struct_end_p (ref); >> + bool trailing =3D array_ref_flexible_size_p (ref); >> bool zero_length =3D integer_zerop (memsize); >> if (!trailing && !zero_length) >> /* MEMBER is either an interior array or is an array with >> diff --git a/gcc/tree.h b/gcc/tree.h >> index a50f7b2be9d..0fcdd6b06d0 100644 >> --- a/gcc/tree.h >> +++ b/gcc/tree.h >> @@ -5548,10 +5548,10 @@ extern tree array_ref_up_bound (tree); >> EXP, an ARRAY_REF or an ARRAY_RANGE_REF. */ >> extern tree array_ref_low_bound (tree); >>=20 >> -/* Returns true if REF is an array reference or a component reference >> - to an array at the end of a structure. If this is the case, the arr= ay >> - may be allocated larger than its upper bound implies. */ >> -extern bool array_at_struct_end_p (tree); >> +/* Returns true if REF is an array reference, a component reference, >> + or a memory reference to an array whose actual size might be larger >> + than its upper bound implies. */ >> +extern bool array_ref_flexible_size_p (tree); >>=20 >> /* Return a tree representing the offset, in bytes, of the field referen= ced >> by EXP. This does not include any offset in DECL_FIELD_BIT_OFFSET. = */ >>=20 >=20 > --=20 > Richard Biener > SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg= , > Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; > HRB 36809 (AG Nuernberg)