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 150663861841 for ; Wed, 18 Oct 2023 14:42:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 150663861841 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 150663861841 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697640128; cv=pass; b=r+PLnREK413xS3RAxWixeiGrNkeECMZwihLvTyiTaNPzeUXCLOZvvw7CdQnJfMqEbvQOYzkX1rp6MxhAL2RDKgUFmxkXL1vRkIn+vMCflIEN7shG+gXrTHxsnkdT27qGHZ0GaNiY7HA7upZLzRvYLdYVMx/UzuF/FubqamttXbM= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697640128; c=relaxed/simple; bh=mn6D2iwJbw/TXEx18y7ZZRHrf2otVDD2oO66f1cTAZQ=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=t6bf5BpBlFTmTnKAL55no35ovge8UerblyGnE8J19AxmNItkebWlN9bs0q38R7oPJBk7CH8trsGcOspApdsVkcnRltAGhrlmG6AKyPei2EKP4ZTbEBzyNcP4Q51Zu1YDa9XNzjo8SiMgY5GgjnjNvtYKtoXx6mutsHLoZQ1jK0Y= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39IEJ3w3019185; Wed, 18 Oct 2023 14:42:03 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-2023-03-30; bh=dogegXM7pE+Hi4+HZoz2sukjTn9dtpmnmcbK7weDezg=; b=uKLAXiJrmWRVWUGabKmqq2QDIgHmMFOdHAeNkI5UemBjilh5VeEUFvpoiwil+KS8CJ0N 0FYEkKQUwdos9y2RaU0hwdko9ZODLdrNP5QPtcs2UCAGP8quWqv7BPrrYJ9kX/p0a0qn wQj7tiG0y6+7e4cMYowg7ftyfr90b4PsH5+UxuRsR6F8h3+qpVAri/rRrSXO+q/2NVyI AGFGBCjXJf6jYOoTp6n3Zm38P4RGmz6UI910p4bUEGS60mBxSCCMPTfhZhlCkboi+Sat Du4TSI3uNefL1JrI5eTaYOyXRNBRKPm8UAFqlKHaRI1EV6qCI3TZ8QfTU/NEB8rwW2r1 Jg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tqk28qt0e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Oct 2023 14:42:02 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 39IDaJuA015256; Wed, 18 Oct 2023 14:42:01 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3trg1gk97n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Oct 2023 14:42:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QvtSNmfPd61ZECSQJDObSwXYqKtvuanyK5RnmuqEvKALR2HROwuLEbR5XbRqj6mNrbqKG5Q4OrhHgyerURdTjJChqgdWt7+/mUOyVSLZBpFLUH9m8UR9U2HgpD/HE7Mo9VvyAxRD6ZGkL5qVoVBvJDz22DstY2XQFn1Fu6t/qtt4XSfMndKfwi9LcWQ2gOosSmUH6a+et6TdkZb3WzmV87KYyd0bZsJ5WvsZ1FWX7Ky6Nuv+U7K1ioajdzAbm0TaUiuK8IDe9/Oi7sCzj4KfjruRB9tauQrwF7humKpD/dgHvPh5pVsPQNy4o3PuEpEaSt2ZcNQDk1EJxflm3mITew== 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=dogegXM7pE+Hi4+HZoz2sukjTn9dtpmnmcbK7weDezg=; b=Nk9BafbEKtTdiYIqmsqOmNsSWUxt67YHLcMBkrmE+ItBii9vxV/pcfFx5D3HQ0QZtnBn89J0qDZ9w7VHtwRT31MgGxbmQhRscylBRB6cx4yeawd93UF5KgAzfoNVYE3Aa29ofCuhxCs0WwjwA430ZXCkn4Yj56YS5TgRwODr3IbssFUOLKf0O7DgtVk7oWos/bPyAF2NmpL8pJfh9V6ckLcoG8ApufTZhMiEjcBF7S3GWLl/u1BM5RRF/thUrW2DlbzlSo8RYnX5LR8Sx7v2Kr0DUl3g7X5EQY/7OBKNxCtkumUu4mvqjtwRE64ZxFvUlH84ACbU0jgu0j2i0lSSaQ== 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=dogegXM7pE+Hi4+HZoz2sukjTn9dtpmnmcbK7weDezg=; b=uaJH5Ojc1O8fqzKyxM9Ia9heyZ7+j9TifSj1hhL9XbicFU1Sx1C+vWwByp5dd957XMtVswYkYMn6GIjhZ3GAdc9WonLXKZiv7NnsAnsnfI9Ir5PiOF2QvEA9CAdliAMpPJoMg4ZHfLclCLDyW9Tpx9BCGbxStk/xcFPfDHdH5IQ= Received: from CH3PR10MB7957.namprd10.prod.outlook.com (2603:10b6:610:1bf::19) by BLAPR10MB5187.namprd10.prod.outlook.com (2603:10b6:208:334::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.21; Wed, 18 Oct 2023 14:41:58 +0000 Received: from CH3PR10MB7957.namprd10.prod.outlook.com ([fe80::c950:cd06:efa7:d1d0]) by CH3PR10MB7957.namprd10.prod.outlook.com ([fe80::c950:cd06:efa7:d1d0%3]) with mapi id 15.20.6886.034; Wed, 18 Oct 2023 14:41:58 +0000 From: Qing Zhao To: Siddhesh Poyarekar CC: "joseph@codesourcery.com" , "richard.guenther@gmail.com" , "jakub@redhat.com" , "gcc-patches@gcc.gnu.org" , "keescook@chromium.org" , "uecker@tugraz.at" , "isanbard@gmail.com" Subject: Re: [V3][PATCH 1/3] Provide counted_by attribute to flexible array member field (PR108896) Thread-Topic: [V3][PATCH 1/3] Provide counted_by attribute to flexible array member field (PR108896) Thread-Index: AQHZ12hBjKMnBp+fbEKNJydjoqv0ULA7yzgAgBQodIA= Date: Wed, 18 Oct 2023 14:41:58 +0000 Message-ID: <8F4CA306-E035-4EF5-A1B4-4B82F91BF4AB@oracle.com> References: <20230825152425.2417656-1-qing.zhao@oracle.com> <20230825152425.2417656-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.3) x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CH3PR10MB7957:EE_|BLAPR10MB5187:EE_ x-ms-office365-filtering-correlation-id: 2ac7b47a-6e4e-47b1-eea9-08dbcfe861e6 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8wacmMg7hW8PjewcvbsvqdBRXE4YdaU03qYnAEbN3zIF0DAKcBfKI92LdGsshZEkhjo51K5Tf8D33EUSAKzY311Q8BMsKPN+z8v8DvGgUmyOZGTCTBhOkGQR2XN37I/INGmHf02RMHgcTccLUbKbrceieMfFrKgbXkA5GvIEQ2+vEO+XOEyqz1vlxbSpQVdKy2MzCzlWTxJFtM8tUFBU8bKP1gavg9uzF1T+p1D/f+9iZC7yNvtaIN3sCJhZeLyhC5irkXTcBNE5xhPvaqlgWRkV1MCeThrh5AnukkPH8cdfbw9Y/yBT5/CK7Nljj4068dbRm1EgMqeqp+bUCQsSFB/ld2nriHI5hNlg22/fLizXbFyqRWEsSA3QMB7HOsrjz3IR52rYvM/xdVReEJZGkMwoJEb1y+DX+ydfsTQxcrznjjHEE2InyDztz5SMcE1IToVcgmOlO4AOSTkyXlFnEGUNRQvVhiNLXn5bU5wlzMy4XOa98knwb68zknpt7CuFs6g4yBIwP6ytKhY/+g+afxhJD5JiWC3wCHlIq8wd+dtwKZlU2RdgsRbuaBsbEDLs24N3yo6dkhufk/0d8Ib+wfdJLEWe8oJxW4dpsaUzbuFSsPQQ2cJktP+QMtNcI2Db74zs0c364AApsFr8NHozWA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR10MB7957.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(39860400002)(346002)(136003)(376002)(230922051799003)(186009)(64100799003)(1800799009)(451199024)(33656002)(36756003)(84970400001)(8936002)(66556008)(54906003)(66476007)(91956017)(316002)(64756008)(66946007)(6916009)(38100700002)(86362001)(122000001)(38070700005)(66446008)(53546011)(76116006)(83380400001)(2616005)(6512007)(71200400001)(6506007)(2906002)(30864003)(478600001)(6486002)(44832011)(41300700001)(5660300002)(4326008)(8676002)(45980500001)(579004)(559001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?eWRk8lyy5l7539uNAaVaoXRcTKgauw8R6P7NXfRIRhghAAHoymC+NPx3/CPc?= =?us-ascii?Q?x/RlKw40j1ZSYZNFPUBCjHvGSuLZLbTTstMmLRqZOdp85bIYLcT0DTQUagC5?= =?us-ascii?Q?UGQvDw9tUn6g31jLfzY75jlFnyPv1AQ64THT9cpt3Pp5tu4n5YnNyKdIBRXq?= =?us-ascii?Q?EtgOSpQKosYwgycZuvoaTYvIFVKvy24KPTEzj+a5p8P0z5Cz8kTGYjdOrN1i?= =?us-ascii?Q?qjVg23Wmpya+tkyFhz1jHUzDCM19cziQTIoi40EN61PU8DVr4pJO2PE26AUj?= =?us-ascii?Q?WOqiGzEGG2KbccsiTQOlqK89zKEByE8vwjtWBBDFFZlztut1Zpt2pQQnGMxO?= =?us-ascii?Q?iSkOq+LMDLZ7Xt3Ygr6ejhkNGCmEkcvbxJwLgA7Il2dvaCWnire/ZfLvEBfY?= =?us-ascii?Q?nXxSb1KbPHkbGGFX55zhgLTm+TKgH0x4jhMjO5tin6HjgwXBppT82Bummbmn?= =?us-ascii?Q?opCzqUORAd5FkTY0785yK70wPixl6Wot+Fn8XByrT4XRDvgwKR6TcKDanMs/?= =?us-ascii?Q?d1dM06YMqy4RU4brWVTJFHszGk6qCzObjCLwc9pAk05pw68LX3c74K/rmn0w?= =?us-ascii?Q?jgNagihr3SVQwhtV6lB+6ty17AcTQjb8qKVD/HlPpmtTgQxPXrNkcMrCBxxp?= =?us-ascii?Q?rpJP+89/t6XLBpVRzLPsJdUkvVRICpH4/bGkb1w6reBsXamiqpFre0iUn1Po?= =?us-ascii?Q?xbaFqZGy6hWQDA54/vmqI6l9xKTzyKl9hxtVYEzTcc9wxNP3p7EzJvYlCizo?= =?us-ascii?Q?ScxeeYogomfK/SnYMd5N6zCjnz+qgMLMkJF7EEQZT1Gtdee0ZWLA067YxoHt?= =?us-ascii?Q?f9y8EXMHy95wjhzbEKqff5OsFeKjODsyTw2AS4GXcfbnckFcuLoc0tTMiYt6?= =?us-ascii?Q?sdYq2J2GzivzSXYZaDR2tvjWHIrQLpHITxijHzwgEX4XBoCJVFZKfyZhDb0B?= =?us-ascii?Q?TgmtDBLVGxQEbt0FK6pt+jb03xH/Fey8yoea+N1rp8MVSsigMblzpi3KQRp6?= =?us-ascii?Q?a5myCMMs7VPW8IzwJGe4XsMFQFKeF3pNnL4E9Nyi5HIXEQQTqCdtw3A3VWLR?= =?us-ascii?Q?zc8jtiqcbX6ra+Qapk+rrStxW6bFkZNzySds6GKXZaNyA2LbBBHnocmeXHKy?= =?us-ascii?Q?J5NQyTgPo8H6rpoVcG07CcGyoKGNB21l/1lKfXQdu7Qt6QllhePZ3RauIuB6?= =?us-ascii?Q?JdPeT5GcyUxXAQqaFasERSvZwT9OXdZ1rMR3CmDWgDhGI7ikE613eKooDwUR?= =?us-ascii?Q?siForF+SDltGtXw1wjB2WPwLy2c7tnpLg5E3ZnHWn2sfDWqPT5wAy1cNu8F8?= =?us-ascii?Q?wkiRb8GmFgjKu5d6Flv0HGWIDAS60KGUXQgeJt1jdBYsCr+R8rlJH+mzEHUx?= =?us-ascii?Q?Id+oKUUu+P8E+NfIQ4jbnvHwE8IgF/atdTvGCS54/QbPBBoSyvF3YbYD1XnV?= =?us-ascii?Q?MgKGgCFo4N/IjTRXcqc/PPlLz+PQXRJVAZp/uDm9/SL/OZiGwwwE4MOwiZPO?= =?us-ascii?Q?uUWlbl8BOGWii5kHzkrl76HKxkAbCGRCta7YUosxIyZcobAp2+GrCIW37OBw?= =?us-ascii?Q?Na5UalDWcE3BqYGsgRkcYxCFvOr6N6isegrfe1OOAXabgkdIIiDziWf5KjGN?= =?us-ascii?Q?1iB+sXtXXPS9Bm23YpEn0Ao=3D?= Content-Type: text/plain; charset="us-ascii" Content-ID: <409466B831A858428FFC773058349FEB@namprd10.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: =?us-ascii?Q?jcy2H8cywZZFfXUqqycJmkfzESyRE4gONHCI3QU1TY56tbmYQX5Y5q5wTxS5?= =?us-ascii?Q?HpCpRiwRdO8HKom+kOd4eUsHnnXaOMz36nwOdf/72LCoZd1fgx3EpOqVH0zx?= =?us-ascii?Q?/O66l+BCgRdX8dtQq2Lx39lr4A0Y7DiJ2Bb11BOWYLTZ3PGGsKXU05UI4pil?= =?us-ascii?Q?WaCI8NppKxyrVvBCfOvegAkupqO6HoAdlEzGV7VB6qPi/jQOS7Q25No4PRV5?= =?us-ascii?Q?QJgwbzpH+w07W1N4zrKdTUdYAnmkJw2SiwfxVfpzczS+VKY3y5OI/sQZoUkp?= =?us-ascii?Q?aUSPfIDKxmBmWl1pLjtlP6tgQZjOQtcEQyWF1dDCTHmgAbqMVbJ4+WsI8hwZ?= =?us-ascii?Q?0EkZHEYP4Xluo/H2Fb2ftNvr5wwITzYY8oZpSWxsxmeN167kGC4aFEljk3eg?= =?us-ascii?Q?1+gGsygI/FaxJp/6b5b6b6Mk6StRExbjY+yDm7ka7pOSgjljArucs47Vhk8/?= =?us-ascii?Q?ugXzrXOD8ymU9mZ/RGtxnxwBrfgsfJiIFlhkq9Ws410A4BCj5mIkV+I64q9h?= =?us-ascii?Q?dPKlS0ZBM0bc3L2Qs6W9OHIXdGO1cc6iLGODD3YfuvkOqqq+9PKpsjgC/jEg?= =?us-ascii?Q?weOay2hbCszCRKRrs4CIvoYvk0Mp9J81Hr53uxxL7jixZ6P4KbfLinotjLP6?= =?us-ascii?Q?t9Au6efUsncFcwwRmVSFRbFGfMg5evJJ/vK4OnYQDD1wILTM4tLCeidM8WiC?= =?us-ascii?Q?2KktWg+dU/8WfcQk5HONYJ6LPWl3NUVDpjnt46uUDKnUjAYkdXs/pd/zo8mz?= =?us-ascii?Q?i9zGCKTpV9K2gaVuep+VAfqbpxsh3z+OZ9HN+PIiOlqlieRyGepH6zTh1+/8?= =?us-ascii?Q?ZPXPUODC7NiNefK6P+wU8dZhGieyVW31Z3DzLUUoIt5dFNAf16PKcQjRwte1?= =?us-ascii?Q?2HjLFcZUjdKur1Y1dVjwv1yGl+Z/kKW4fp6950ME4buRAsHTMzpVWC3rDWEG?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7957.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ac7b47a-6e4e-47b1-eea9-08dbcfe861e6 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Oct 2023 14:41:58.4601 (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: Brc0sNbhmOcTLhFb8Jjn42AzI76yZSWml6IrRCHU2edQ1aqvnhQd8p/LEuYbiWdQliCaolC1ELwqVe3lQ133RQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5187 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-18_12,2023-10-18_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310180120 X-Proofpoint-ORIG-GUID: vzt5F6RjVE64SjAqwXcfusZJ0CW9IXln X-Proofpoint-GUID: vzt5F6RjVE64SjAqwXcfusZJ0CW9IXln X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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: Hi, Sid,=20 Thanks a lot for your time and effort to review this patch set! And sorry for my late reply due to a long vacation immediately after Cauldr= on, just came back this Monday.. See my reply embedded below: > On Oct 5, 2023, at 2:51 PM, Siddhesh Poyarekar wrot= e: >=20 > On 2023-08-25 11:24, Qing Zhao wrote: >> Provide a new counted_by attribute to flexible array member field. >=20 > The obligatory "I can't ack the patch but here's a review" disclaimer :) >=20 >> 'counted_by (COUNT)' >> The 'counted_by' attribute may be attached to the flexible array >> member of a structure. It indicates that the number of the >> elements of the array is given by the field named "COUNT" in the >> same structure as the flexible array member. GCC uses this >> information to improve the results of the array bound sanitizer and >> the '__builtin_dynamic_object_size'. >> For instance, the following code: >> struct P { >> size_t count; >> char other; >> char array[] __attribute__ ((counted_by (count))); >> } *p; >> specifies that the 'array' is a flexible array member whose number >> of elements is given by the field 'count' in the same structure. >> The field that represents the number of the elements should have an >> integer type. An explicit 'counted_by' annotation defines a >> relationship between two objects, 'p->array' and 'p->count', that >> 'p->array' has _at least_ 'p->count' number of elements available. >> This relationship must hold even after any of these related objects >> are updated. It's the user's responsibility to make sure this >> relationship to be kept all the time. Otherwise the results of the >> array bound sanitizer and the '__builtin_dynamic_object_size' might >> be incorrect. >> For instance, in the following example, the allocated array has >> less elements than what's specified by the 'sbuf->count', this is >> an user error. As a result, out-of-bounds access to the array >> might not be detected. >> #define SIZE_BUMP 10 >> struct P *sbuf; >> void alloc_buf (size_t nelems) >> { >> sbuf =3D (struct P *) malloc (MAX (sizeof (struct P), >> (offsetof (struct P, array[0]= ) >> + nelems * sizeof (char)))); >> sbuf->count =3D nelems + SIZE_BUMP; >> /* This is invalid when the sbuf->array has less than sbuf->= count >> elements. */ >> } >> In the following example, the 2nd update to the field 'sbuf->count' >> of the above structure will permit out-of-bounds access to the >> array 'sbuf>array' as well. >> #define SIZE_BUMP 10 >> struct P *sbuf; >> void alloc_buf (size_t nelems) >> { >> sbuf =3D (struct P *) malloc (MAX (sizeof (struct P), >> (offsetof (struct P, array[0]= ) >> + (nelems + SIZE_BUMP) * siz= eof (char)))); >> sbuf->count =3D nelems; >> /* This is valid when the sbuf->array has at least sbuf->cou= nt >> elements. */ >> } >> void use_buf (int index) >> { >> sbuf->count =3D sbuf->count + SIZE_BUMP + 1; >> /* Now the value of sbuf->count is larger than the number >> of elements of sbuf->array. */ >> sbuf->array[index] =3D 0; >> /* then the out-of-bound access to this array >> might not be detected. */ >> } >> gcc/c-family/ChangeLog: >> PR C/108896 >> * c-attribs.cc (handle_counted_by_attribute): New function. >> (attribute_takes_identifier_p): Add counted_by attribute to the list. >> * c-common.cc (c_flexible_array_member_type_p): ...To this. >> * c-common.h (c_flexible_array_member_type_p): New prototype. >> gcc/c/ChangeLog: >> PR C/108896 >> * c-decl.cc (flexible_array_member_type_p): Renamed and moved to... >> (add_flexible_array_elts_to_size): Use renamed function. >> (is_flexible_array_member_p): Use renamed function. >> (verify_counted_by_attribute): New function. >> (finish_struct): Use renamed function and verify counted_by >> attribute. >> gcc/ChangeLog: >> PR C/108896 >> * doc/extend.texi: Document attribute counted_by. >> * tree.cc (get_named_field): New function. >> * tree.h (get_named_field): New prototype. >> gcc/testsuite/ChangeLog: >> PR C/108896 >> * gcc.dg/flex-array-counted-by.c: New test. >> --- >> gcc/c-family/c-attribs.cc | 54 ++++++++++++- >> gcc/c-family/c-common.cc | 13 ++++ >> gcc/c-family/c-common.h | 1 + >> gcc/c/c-decl.cc | 79 +++++++++++++++----- >> gcc/doc/extend.texi | 77 +++++++++++++++++++ >> gcc/testsuite/gcc.dg/flex-array-counted-by.c | 40 ++++++++++ >> gcc/tree.cc | 40 ++++++++++ >> gcc/tree.h | 5 ++ >> 8 files changed, 291 insertions(+), 18 deletions(-) >> create mode 100644 gcc/testsuite/gcc.dg/flex-array-counted-by.c >> diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc >> index e2792ca6898b..65e4f6639109 100644 >> --- a/gcc/c-family/c-attribs.cc >> +++ b/gcc/c-family/c-attribs.cc >> @@ -103,6 +103,8 @@ static tree handle_warn_if_not_aligned_attribute (tr= ee *, tree, tree, >> int, bool *); >> static tree handle_strict_flex_array_attribute (tree *, tree, tree, >> int, bool *); >> +static tree handle_counted_by_attribute (tree *, tree, tree, >> + int, bool *); >> static tree handle_weak_attribute (tree *, tree, tree, int, bool *) ; >> static tree handle_noplt_attribute (tree *, tree, tree, int, bool *) ; >> static tree handle_alias_ifunc_attribute (bool, tree *, tree, tree, boo= l *); >> @@ -373,6 +375,8 @@ const struct attribute_spec c_common_attribute_table= [] =3D >> handle_warn_if_not_aligned_attribute, NULL }, >> { "strict_flex_array", 1, 1, true, false, false, false, >> handle_strict_flex_array_attribute, NULL }, >> + { "counted_by", 1, 1, true, false, false, false, >> + handle_counted_by_attribute, NULL }, >> { "weak", 0, 0, true, false, false, false, >> handle_weak_attribute, NULL }, >> { "noplt", 0, 0, true, false, false, false, >> @@ -601,7 +605,8 @@ attribute_takes_identifier_p (const_tree attr_id) >> else if (!strcmp ("mode", spec->name) >> || !strcmp ("format", spec->name) >> || !strcmp ("cleanup", spec->name) >> - || !strcmp ("access", spec->name)) >> + || !strcmp ("access", spec->name) >> + || !strcmp ("counted_by", spec->name)) >> return true; >> else >> return targetm.attribute_takes_identifier_p (attr_id); >> @@ -2555,6 +2560,53 @@ handle_strict_flex_array_attribute (tree *node, t= ree name, >> return NULL_TREE; >> } >> +/* Handle a "counted_by" attribute; arguments as in >> + struct attribute_spec.handler. */ >> + >> +static tree >> +handle_counted_by_attribute (tree *node, tree name, >> + tree args, int ARG_UNUSED (flags), >> + bool *no_add_attrs) >> +{ >> + tree decl =3D *node; >> + tree argval =3D TREE_VALUE (args); >> + >> + /* This attribute only applies to field decls of a structure. */ >> + if (TREE_CODE (decl) !=3D FIELD_DECL) >> + { >> + error_at (DECL_SOURCE_LOCATION (decl), >> + "%qE attribute may not be specified for non-field" >> + " declaration %q+D", name, decl); >> + *no_add_attrs =3D true; >> + } >=20 > Applies only to struct fields. OK. >=20 >> + /* This attribute only applies to field with array type. */ >> + else if (TREE_CODE (TREE_TYPE (decl)) !=3D ARRAY_TYPE) >> + { >> + error_at (DECL_SOURCE_LOCATION (decl), >> + "%qE attribute may not be specified for a non-array field", >> + name); >> + *no_add_attrs =3D true; >> + } >=20 > The struct field should also be an array. OK. >=20 >> + /* This attribute only applies to a C99 flexible array member type. = */ >> + else if (! c_flexible_array_member_type_p (TREE_TYPE (decl))) >> + { >> + error_at (DECL_SOURCE_LOCATION (decl), >> + "%qE attribute may not be specified for a non" >> + " flexible array member field", >> + name); >> + *no_add_attrs =3D true; >> + } >=20 > Additionally, the field should be a *flex* array. OK. Could this be rew= orded to: >=20 > %qE attribute only applies to C99 flexible array members >=20 > That would make it clear that the GNU extension flex arrays (i.e. any las= t array member of a struct) don't support this attribute. Yes, make sense, will update this. >=20 >> + /* The argument should be an identifier. */ >> + else if (TREE_CODE (argval) !=3D IDENTIFIER_NODE) >> + { >> + error_at (DECL_SOURCE_LOCATION (decl), >> + "% argument not an identifier"); >> + *no_add_attrs =3D true; >> + } >=20 > Argument should be an identifier, and the check for validity of the ident= ifier comes later in finish_struct. OK. >=20 >> + >> + return NULL_TREE; >> +} >> + >> /* Handle a "weak" attribute; arguments as in >> struct attribute_spec.handler. */ >> diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc >> index 9fbaeb437a12..a18937245c2a 100644 >> --- a/gcc/c-family/c-common.cc >> +++ b/gcc/c-family/c-common.cc >> @@ -9521,6 +9521,19 @@ c_common_finalize_early_debug (void) >> (*debug_hooks->early_global_decl) (cnode->decl); >> } >> +/* Determine whether TYPE is a ISO C99 flexible array memeber type "[]= ". */ >> +bool >> +c_flexible_array_member_type_p (const_tree type) >> +{ >> + if (TREE_CODE (type) =3D=3D ARRAY_TYPE >> + && TYPE_SIZE (type) =3D=3D NULL_TREE >> + && TYPE_DOMAIN (type) !=3D NULL_TREE >> + && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) =3D=3D NULL_TREE) >> + return true; >> + >> + return false; >> +} >> + >=20 > Hoist flexible_array_member_type_p to use more widely. OK. >=20 >> /* Get the LEVEL of the strict_flex_array for the ARRAY_FIELD based on = the >> values of attribute strict_flex_array and the flag_strict_flex_array= s. */ >> unsigned int >> diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h >> index 78fc5248ba68..c29bb429062b 100644 >> --- a/gcc/c-family/c-common.h >> +++ b/gcc/c-family/c-common.h >> @@ -909,6 +909,7 @@ extern tree fold_for_warn (tree); >> extern tree c_common_get_narrower (tree, int *); >> extern bool get_attribute_operand (tree, unsigned HOST_WIDE_INT *); >> extern void c_common_finalize_early_debug (void); >> +extern bool c_flexible_array_member_type_p (const_tree); >> extern unsigned int c_strict_flex_array_level_of (tree); >> extern bool c_option_is_from_cpp_diagnostics (int); >> diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc >> index 1f9eb44dbaa2..e943b49b5230 100644 >> --- a/gcc/c/c-decl.cc >> +++ b/gcc/c/c-decl.cc >> @@ -5173,19 +5173,6 @@ set_array_declarator_inner (struct c_declarator *= decl, >> return decl; >> } >> -/* Determine whether TYPE is a ISO C99 flexible array memeber type "[]= ". */ >> -static bool >> -flexible_array_member_type_p (const_tree type) >> -{ >> - if (TREE_CODE (type) =3D=3D ARRAY_TYPE >> - && TYPE_SIZE (type) =3D=3D NULL_TREE >> - && TYPE_DOMAIN (type) !=3D NULL_TREE >> - && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) =3D=3D NULL_TREE) >> - return true; >> - >> - return false; >> -} >> - >> /* Determine whether TYPE is a one-element array type "[1]". */ >> static bool >> one_element_array_type_p (const_tree type) >> @@ -5222,7 +5209,7 @@ add_flexible_array_elts_to_size (tree decl, tree i= nit) >> elt =3D CONSTRUCTOR_ELTS (init)->last ().value; >> type =3D TREE_TYPE (elt); >> - if (flexible_array_member_type_p (type)) >> + if (c_flexible_array_member_type_p (type)) >> { >> complete_array_type (&type, elt, false); >> DECL_SIZE (decl) >> @@ -9094,7 +9081,7 @@ is_flexible_array_member_p (bool is_last_field, >> bool is_zero_length_array =3D zero_length_array_type_p (TREE_TYPE (= x)); >> bool is_one_element_array =3D one_element_array_type_p (TREE_TYPE (x)= ); >> - bool is_flexible_array =3D flexible_array_member_type_p (TREE_TYPE (x= )); >> + bool is_flexible_array =3D c_flexible_array_member_type_p (TREE_TYPE = (x)); >> unsigned int strict_flex_array_level =3D c_strict_flex_array_level_= of (x); >> =20 >=20 > Simple refactoring. OK. >=20 >> @@ -9124,6 +9111,61 @@ is_flexible_array_member_p (bool is_last_field, >> return false; >> } >> +/* Verify the argument of the counted_by attribute of the flexible arr= ay >=20 > Verify *that* the argument... Sure, will update this. >=20 >> + member FIELD_DECL is a valid field of the containing structure's fie= ldlist, >> + FIELDLIST, Report error and remove this attribute when it's not. */ >> +static void >> +verify_counted_by_attribute (tree fieldlist, tree field_decl) >> +{ >> + tree attr_counted_by =3D lookup_attribute ("counted_by", >> + DECL_ATTRIBUTES (field_decl)); >> + >> + if (!attr_counted_by) >> + return; >> + >> + /* If there is an counted_by attribute attached to the field, >> + verify it. */ >> + >> + const char *fieldname >> + =3D IDENTIFIER_POINTER (TREE_VALUE (TREE_VALUE (attr_counted_by))); >> + >> + /* Verify the argument of the attrbute is a valid field of the >=20 > s/attrbute/attribute/ Okay. >=20 >> + containing structure. */ >> + >> + tree counted_by_field =3D get_named_field (fieldlist, fieldname); >> + >> + /* Error when the field is not found in the containing structure. */ >> + if (!counted_by_field) >> + { >> + error_at (DECL_SOURCE_LOCATION (field_decl), >> + "%qE attribute argument not a field declaration" >> + " in the same structure, ignore it", >> + (get_attribute_name (attr_counted_by))); >=20 > Probably someone with English as a first language would make a better sug= gestion, but how about: >=20 > Argument specified in %qE attribute is not a field declaration in the > same structure, ignoring it. This is better, will update it. >=20 >> + >> + DECL_ATTRIBUTES (field_decl) >> + =3D remove_attribute ("counted_by", DECL_ATTRIBUTES (field_decl)); >> + } >> + else >> + /* Error when the field is not with an integer type. */ >=20 > Suggest: Flag an error when the field is not of an integer type. Okay.=20 >=20 >> + { >> + while (TREE_CHAIN (counted_by_field)) >> + counted_by_field =3D TREE_CHAIN (counted_by_field); >> + tree real_field =3D TREE_VALUE (counted_by_field); >> + >> + if (TREE_CODE (TREE_TYPE (real_field)) !=3D INTEGER_TYPE) >> + { >> + error_at (DECL_SOURCE_LOCATION (field_decl), >> + "%qE attribute argument not a field declaration" >> + " with integer type, ignore it", >> + (get_attribute_name (attr_counted_by))); >=20 > Suggest: >=20 > Argument specified in %qE attribute is not of an integer type, > ignoring it. Will update this. >=20 >> + >> + DECL_ATTRIBUTES (field_decl) >> + =3D remove_attribute ("counted_by", DECL_ATTRIBUTES (field_decl)); >> + } >> + } >> + >> + return; >> +} >> /* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T. >> LOC is the location of the RECORD_TYPE or UNION_TYPE's definition. >> @@ -9244,7 +9286,7 @@ finish_struct (location_t loc, tree t, tree fieldl= ist, tree attributes, >> DECL_PACKED (x) =3D 1; >> /* Detect flexible array member in an invalid context. */ >> - if (flexible_array_member_type_p (TREE_TYPE (x))) >> + if (c_flexible_array_member_type_p (TREE_TYPE (x))) >> { >> if (TREE_CODE (t) =3D=3D UNION_TYPE) >> { >> @@ -9265,6 +9307,9 @@ finish_struct (location_t loc, tree t, tree fieldl= ist, tree attributes, >> "members"); >> TREE_TYPE (x) =3D error_mark_node; >> } >> + /* if there is a counted_by attribute attached to this field, >> + verify it. */ >> + verify_counted_by_attribute (fieldlist, x); >> } >> if (pedantic && TREE_CODE (t) =3D=3D RECORD_TYPE >> @@ -9279,7 +9324,7 @@ finish_struct (location_t loc, tree t, tree fieldl= ist, tree attributes, >> when x is an array and is the last field. */ >> if (TREE_CODE (TREE_TYPE (x)) =3D=3D ARRAY_TYPE) >> TYPE_INCLUDES_FLEXARRAY (t) >> - =3D is_last_field && flexible_array_member_type_p (TREE_TYPE (x)); >> + =3D is_last_field && c_flexible_array_member_type_p (TREE_TYPE (x)); >> /* Recursively set TYPE_INCLUDES_FLEXARRAY for the context of x, = t >> when x is an union or record and is the last field. */ >> else if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))) >> diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi >> index 97eaacf8a7ec..ea6240646936 100644 >> --- a/gcc/doc/extend.texi >> +++ b/gcc/doc/extend.texi >> @@ -7617,6 +7617,83 @@ When both the attribute and the option present at= the same time, the level of >> the strictness for the specific trailing array field is determined by t= he >> attribute. >> +@cindex @code{counted_by} variable attribute >> +@item counted_by (@var{count}) >> +The @code{counted_by} attribute may be attached to the flexible array >> +member of a structure. It indicates that the number of the elements of= the >> +array is given by the field named "@var{count}" in the same structure a= s the >> +flexible array member. GCC uses this information to improve the result= s of >> +the array bound sanitizer and the @code{__builtin_dynamic_object_size}. >=20 > Maybe specify somehow that this only applies to C99 flexible arrays? Lik= e: >=20 > The @code{counted_by} attribute may be attached to the C99 flexible > array member of a structure... Yes, specify that the attribute will be only applied to C99 FMA is necessar= y, I will update this. >=20 >> + >> +For instance, the following code: >> + >> +@smallexample >> +struct P @{ >> + size_t count; >> + char other; >> + char array[] __attribute__ ((counted_by (count))); >> +@} *p; >> +@end smallexample >> + >> +@noindent >> +specifies that the @code{array} is a flexible array member whose number= of >> +elements is given by the field @code{count} in the same structure. >> + >> +The field that represents the number of the elements should have an int= eger >> +type. An explicit @code{counted_by} annotation defines a relationship = between >> +two objects, @code{p->array} and @code{p->count}, that @code{p->array} = has >> +@emph{at least} @code{p->count} number of elements available. This rel= ationship >> +must hold even after any of these related objects are updated. It's th= e user's >> +responsibility to make sure this relationship to be kept all the time. >> +Otherwise the results of the array bound sanitizer and the >> +@code{__builtin_dynamic_object_size} might be incorrect. >=20 > Suggest: >=20 > The field that represents the number of the elements must have an > integer type. An explicit @code{counted_by} annotation defines a > relationship between two objects, @code{p->array} and @code{p->count}, > that @code{p->array} has @emph{at least} @code{p->count} number of > elements available. The user is responsible to ensure that this > relationship is consistently maintained during the lifetime of the > object. Failure to do so may result in results of the array bound > sanitizer and the @code{__builtin_dynamic_object_size} being > undefined. Thanks for the suggestion, will update accordingly. >=20 >> + >> +For instance, in the following example, the allocated array has less el= ements >> +than what's specified by the @code{sbuf->count}, this is an user error.= As a >> +result, out-of-bounds access to the array might not be detected. >> + >> +@smallexample >> +#define SIZE_BUMP 10 >> +struct P *sbuf; >> +void alloc_buf (size_t nelems) >> +@{ >> + sbuf =3D (struct P *) malloc (MAX (sizeof (struct P), >> + (offsetof (struct P, array[0]) >> + + nelems * sizeof (char)))); >> + sbuf->count =3D nelems + SIZE_BUMP; >> + /* This is invalid when the sbuf->array has less than sbuf->count >> + elements. */ >> +@} >> +@end smallexample >> + >> +In the following example, the 2nd update to the field @code{sbuf->count= } of >> +the above structure will permit out-of-bounds access to the array >> +@code{sbuf>array} as well. >> + >> +@smallexample >> +#define SIZE_BUMP 10 >> +struct P *sbuf; >> +void alloc_buf (size_t nelems) >> +@{ >> + sbuf =3D (struct P *) malloc (MAX (sizeof (struct P), >> + (offsetof (struct P, array[0]) >> + + (nelems + SIZE_BUMP) * sizeof (char)))); >> + sbuf->count =3D nelems; >> + /* This is valid when the sbuf->array has at least sbuf->count >> + elements. */ >> +@} >> +void use_buf (int index) >> +@{ >> + sbuf->count =3D sbuf->count + SIZE_BUMP + 1; >> + /* Now the value of sbuf->count is larger than the number >> + of elements of sbuf->array. */ >> + sbuf->array[index] =3D 0; >> + /* then the out-of-bound access to this array >> + might not be detected. */ >> +@} >> +@end smallexample >> + >> + >=20 > I'm unsure if we should be demonstrating example code with undefined beha= viour. Maybe the documentation is better off without it. Good point, will delete the example with undefined behavior from the doc.=20 >=20 >> @cindex @code{alloc_size} variable attribute >> @item alloc_size (@var{position}) >> @itemx alloc_size (@var{position-1}, @var{position-2}) >> diff --git a/gcc/testsuite/gcc.dg/flex-array-counted-by.c b/gcc/testsuit= e/gcc.dg/flex-array-counted-by.c >> new file mode 100644 >> index 000000000000..f8ce9776bf86 >> --- /dev/null >> +++ b/gcc/testsuite/gcc.dg/flex-array-counted-by.c >> @@ -0,0 +1,40 @@ >> +/* testing the correct usage of attribute counted_by. */ >> +/* { dg-do compile } */ >> +/* { dg-options "-O2" } */ >> + >> +#include >> + >> +int size; >> +int x __attribute ((counted_by (size))); /* { dg-error "attribute may n= ot be specified for non-field declaration" } */ >> + >> +struct trailing { >> + int count; >> + int field __attribute ((counted_by (count))); /* { dg-error "attribut= e may not be specified for a non-array field" } */ >> +}; >> + >> +struct trailing_1 { >> + int count; >> + int array_1[0] __attribute ((counted_by (count))); /* { dg-error "att= ribute may not be specified for a non flexible array member field" } */ >> +}; >> + >> +int count; >> +struct trailing_array_2 { >> + int count; >> + int array_2[] __attribute ((counted_by ("count"))); /* { dg-error "ar= gument not an identifier" } */ >> +}; >> + >> +struct trailing_array_3 { >> + int other; >> + int array_3[] __attribute ((counted_by (L"count"))); /* { dg-error "a= rgument not an identifier" } */ >> +}; >> + >> +struct trailing_array_4 { >> + int other; >> + int array_4[] __attribute ((counted_by (count))); /* { dg-error "attr= ibute argument not a field declaration in the same structure, ignore it" } = */ >> +}; >> + >> +int count; >> +struct trailing_array_5 { >> + float count; >> + int array_5[] __attribute ((counted_by (count))); /* { dg-error "attr= ibute argument not a field declaration with integer type, ignore it" } */ >> +}; >=20 > Tests look OK in principle, but may need updating for the error message. Okay.=20 thanks. Qing >=20 >> diff --git a/gcc/tree.cc b/gcc/tree.cc >> index 420857b110c4..fcd36ae0cd74 100644 >> --- a/gcc/tree.cc >> +++ b/gcc/tree.cc >> @@ -12745,6 +12745,46 @@ array_ref_element_size (tree exp) >> return SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_SIZE_UNIT (elmt_type), = exp); >> } >> +/* Given a field list, FIELDLIST, of a structure/union, return a TREE_= LIST, >> + with each TREE_VALUE a FIELD_DECL stepping down the chain to the FIE= LD >> + whose name is FIELDNAME, which is the last TREE_VALUE of the list. >> + return NULL_TREE if such field is not found. Normally this list is = of >> + length one, but if the field is embedded with (nested) anonymous str= uctures >> + or unions, this list steps down the chain to the field. */ >> +tree >> +get_named_field (tree fieldlist, const char *fieldname) >> +{ >> + tree named_field =3D NULL_TREE; >> + for (tree field =3D fieldlist; field; field =3D DECL_CHAIN (field)) >> + { >> + if (TREE_CODE (field) !=3D FIELD_DECL) >> + continue; >> + if (DECL_NAME (field) !=3D NULL) >> + if (strcmp (IDENTIFIER_POINTER (DECL_NAME (field)), fieldname) =3D=3D = 0) >> + { >> + named_field =3D tree_cons (NULL_TREE, field, named_field); >> + break; >> + } >> + else >> + continue; >> + /* if the field is an anonymous struct/union, we will check the n= ested >> + fields inside it recursively. */ >> + else if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (field))) >> + if ((named_field =3D get_named_field (TYPE_FIELDS (TREE_TYPE (field)= ), >> + fieldname)) !=3D NULL_TREE) >> + { >> + named_field =3D tree_cons (NULL_TREE, field, named_field); >> + break; >> + } >> + else >> + continue; >> + else >> + continue; >> + } >> + return named_field; >> +} >=20 > Descending recursively into the field list of a struct to find an identif= ier with a matching name. OK. >=20 >> + >> + >> /* Return a tree representing the lower bound of the array mentioned in >> EXP, an ARRAY_REF or an ARRAY_RANGE_REF. */ >> diff --git a/gcc/tree.h b/gcc/tree.h >> index 4c04245e2b1b..4859becaa1e7 100644 >> --- a/gcc/tree.h >> +++ b/gcc/tree.h >> @@ -5619,6 +5619,11 @@ extern tree get_base_address (tree t); >> of EXP, an ARRAY_REF or an ARRAY_RANGE_REF. */ >> extern tree array_ref_element_size (tree); >> +/* Given a field list, FIELDLIST, of a structure/union, return the FIE= LD whose >> + name is FIELDNAME, return NULL_TREE if such field is not found. >> + searching nested anonymous structure/union recursively. */ >> +extern tree get_named_field (tree, const char *); >> + >> /* Return a typenode for the "standard" C type with a given name. */ >> extern tree get_typenode_from_name (const char *); >> =20