From patchwork Tue Jun 20 15:22:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qing Zhao X-Patchwork-Id: 1797442 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=rnHqG7kR; dkim-atps=neutral Received: from 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qlr5d0Ymsz20XZ for ; Wed, 21 Jun 2023 01:24:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0E3AE385414F for ; Tue, 20 Jun 2023 15:24:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E3AE385414F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687274659; bh=edCDMBzlBJXkmQotyzwcuT0pHjk4LDlJEk8SkA3CmnQ=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=rnHqG7kRE6uVnwZinuD9U0l61sefzjusWb11lFhdsTDXwQr7SwGpR5S1qj/LI24Vg IwT3vJ/Q6SD7rpYP5WsDDTAHQbC9h6lrpCLsk9ywoc5z6CwtNXS232NuDBYfihvbrE Y42Mg5yr+yZFna9n2jGnizF0rhrs4HVwhu09Z/vk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 30E653856DE6 for ; Tue, 20 Jun 2023 15:23:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 30E653856DE6 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35KBu5AI001342; Tue, 20 Jun 2023 15:23:25 GMT Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3r93e1d2hg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Jun 2023 15:23:24 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35KEV6om038725; Tue, 20 Jun 2023 15:23:22 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r9394rbke-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Jun 2023 15:23:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UqimnS11IgIXv8sWbxxBXDelMz8rKe4MHGvvZVXsHxQDvRLi5JRQ76XzNVQooDfXwr+gwvr75FRjw5qkAPUxkhOgfi1fz/6g8IYn/DbJFXq4MOtkAGBw0RY71NrjJLzeTOMo5zfXhdA5NbaWHDo+nIfUJbLrKk1CslLoE/UTV9f1zEGqq8knpg/Vlbi9eFLDPPEkdwDJGDADNb9a9sttNewz8prCqslHCV5WHaDvT/EqtdOcJ2PeJgPz6vZt5D0Wk6ZCarbisaxMLcOAEMRcLAB+T6UCvfWm92M6F8RfJahrM1caWDSKROA0u99pGfwjWJw1z0UpeMOXdeYwUAe2bg== 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=edCDMBzlBJXkmQotyzwcuT0pHjk4LDlJEk8SkA3CmnQ=; b=LSVXMNezF0CTxnxNV6VW0YtlbZoCTAE8bD54qo7KvelVUMcRDxaIiOzs00OHK5IENaeLCcSjQEZeBNFnRvn+xs5/0MRfMi+SMu8Bp63LZAfZxQriXX847BOaiCnXk7lVe6HPahYnJNTFi+uQsHV38Owqkh5xBBt9SOCEj2iIt2DwtwSQ3Z3U0EYF4jv8GJxJYBDDQFCEvN1l8nEg2bdLDwE0z1HBFziGPgAUm1qNosfWhudRmC9D0+twzzdJdVrj1y5yeBmFsOdAdbJOoq5JJTGzxV5WIjxNMB47/0gviPFTYP6ahknDxujPlxIKg52yyV8vvB8GY97AmQbA2+DCuw== 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 Received: from CH2PR10MB4344.namprd10.prod.outlook.com (2603:10b6:610:af::19) by MW4PR10MB6437.namprd10.prod.outlook.com (2603:10b6:303:218::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37; Tue, 20 Jun 2023 15:22:53 +0000 Received: from CH2PR10MB4344.namprd10.prod.outlook.com ([fe80::8d90:607a:f94c:5323]) by CH2PR10MB4344.namprd10.prod.outlook.com ([fe80::8d90:607a:f94c:5323%3]) with mapi id 15.20.6521.020; Tue, 20 Jun 2023 15:22:53 +0000 To: qing.zhao@oracle.com, joseph@codesourcery.com, richard.guenther@gmail.com, jakub@redhat.com, gcc-patches@gcc.gnu.org Cc: keescook@chromium.org, siddhesh@gotplt.org, uecker@tugraz.at Subject: [V10][PATCH 1/3] Introduce IR bit TYPE_INCLUDES_FLEXARRAY for the GCC extension [PR77650] Date: Tue, 20 Jun 2023 15:22:44 +0000 Message-Id: <20230620152246.311493-2-qing.zhao@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230620152246.311493-1-qing.zhao@oracle.com> References: <20230620152246.311493-1-qing.zhao@oracle.com> X-ClientProxiedBy: SN4PR0501CA0116.namprd05.prod.outlook.com (2603:10b6:803:42::33) To CH2PR10MB4344.namprd10.prod.outlook.com (2603:10b6:610:af::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR10MB4344:EE_|MW4PR10MB6437:EE_ X-MS-Office365-Filtering-Correlation-Id: 304ae08e-204c-496b-4595-08db71a23774 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8dvIth0jj7cFvrV4cy1jeOa3Cwn33JX9QBdojvypBeDyOsHf3DCGsIeh2+hy3gPRfs8ob6s7ba7QU1fyMtV5VwvnZ8i5JgR6uAqMng+RBuXP5ZwD5hOPpofto6nD1bVzPUxu0hb0o99DHI0698mT7AfMsLDHtCcPiR3A8NJBp+PLktzh8aLmTOtmf0hs8l/+zncTLyJHZCjlHw6DvCHU5yYnZd34QZrPMwuOO5Fr8A69aXslyfwqNOx5qbTkjBgPme1m3sqT3pNW9dYBIRhnrgIzw0B71R6QggLkyKFCG5YRUyx6eeyMtvJTUTLlfIxcmZ0ASwV6E3qAZC6Kp58XmXVFHHsol+miE5evfniflH7jGJh/mE4v2zCXqn/Oqt26/yinpx+6eYMJjhN9ml79HUOvRE5aXfmJPafiLsVwmFlF1oIGqiyD/Z8JRFib16xwPNpvGyJxJGi53EhN+KM59S7NpCw7ZTr6ZxBXHgZ8HAq3/yp59xyYzFydQeP1i1NRF0ZaHsyG840ZVmyI9C8UTh7UouySk55+sptyl/PEosC+U14rJtP+lCr7aLyww98l 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:(13230028)(39860400002)(346002)(366004)(376002)(396003)(136003)(451199021)(6512007)(6506007)(1076003)(26005)(2906002)(36756003)(86362001)(8676002)(8936002)(66556008)(66476007)(6486002)(66946007)(41300700001)(316002)(4326008)(2616005)(186003)(38100700002)(478600001)(6666004)(83380400001)(5660300002)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NYTu4lulRyvcUnlhTFEYyguXuwEll8vUVg920f6Hdv/s/lD/aTbM82Kx/nlHaHkVGrB6xx2AYfDzKbhCuM2ASpXrAbmWtJfn4sTSH/AiE/89cjJLldRHNcvJon1AJ1dsi4Uei63SOeDvr21BeUWkwvp0Fi8iHNUoS0FzF9bl83fc2V5OXinNEthHE/WFGt73jntZkmJ/pJaV4Tn7tM5YQsYOdB3BBeQc6xY8MaX1Jxe9BJM68x9z7QOkpqysfIBtHXGprY6k9oeWqm4AaS6L6ZEiXLXSJdJFvkKrJwPMASXNP0oGVgoNV61G9da5G8CxYg97chrsqwn20Xrg8+/9ZyjJ/Eb+Ar/QGmq4wc8kECBPdcGI4MEiRCmR0VKBiGZnaiGcfRDLz7EDB07Y8ZHUGOu4TJWKmcj5iRFgQPhAUvghDU9YMkiAuJVmX6Z3DTooZe/tTvhjypzZDkuyznWee3lzQSEBvlqDRZr+3TVF9ZBJuIapr+YJoTTUoAbGY3maljkjXRSofQwHgboj96iLdXITjrhXGYspuwvuXZ4IZ8SMozMDfxifH8fS/FkSD2ldSadwOtCjtk2RwAUvLFNc3miX6206eaKuLKNRVmZFftTNlcWqPRI/QSwcVJ/m8EpAKSLBZ/eJjnq3XzjnQpZG00FfFBNDTpxV+gdHU5Rbq1h/vnl05IDDdUwRQZ9DmI9WEpVA/hUdmMU0TiAoTuUBic/6COugF2djXoUs9p/2pILJ1ozTgGIJIdycOigB4PCM4iraxlZARDhAFPH7EH64VHpANjScCerX2gBHx5tLBxsh1TTxMEoRUVESsb1N0+Bo4+2VPXboocEOdWnHrrK3U4BjiojshgM5Ee6ZSb2hG6+lxQuJhqwcvEuCyuSs1M1lve0EmFwRcLonzUrVBK8VsWRrjFrY9ZXonYV7cHT4iu6rlY8hfICbxBA6EVQaJmoAoYgBrh05Xw5vU9HRukf1aiL+/LM3/bAkh4IxwF7ylhD6eMOtPP3HJO7ybr7PGW5dLN9upbgt2v42vZFHnURUICVUtNY89kySlD8/ZOF+wInlTKK6rsAzzwRZvhj4hONpz3XBq4XCX+OSBSu6m6gSrB1hXpZW7iRi7WAbswEk/hj+qWjQjxG7FDSHu06QzFSVrI8E64RJ6ykYGPInAjCpQKAGpp9bprg22zMp934fbtFhrjq3c1M+fULTUrs/E7/MtGSz6+j7QTGm6NuOMeIySsDT4aJcI7z3Ufv+q1zbqseCdPTkY3MMPlOMxV68d2eO6R0YR4YgnSQuESbRYpcTpPyrFxdqkNOCFLDcGtx81EF87b50uMg0JUmnzuj9WzYdHWNagVcXOeiBpAzORBSESMgQdytSK9wQLnu/Et+pOuBvl5VepPEnAxEje5ZzTkSi0dto12c31tGpcC7rb63X2W1hl0NCzynD5RuMKS3eabwmfk8zOe+fIQtUZyw4SyKExpWFfdnl3UAep6U3LbhNBeucQjT8BPqK5AHQM3GLliUgJqdTPGQmdlEsOblFKHhSHljnOOwfVtbAkVbzNbAj9whjbkPrUJskrlFaSvdACZWpWo0JOICrcq29mzk71TvJ X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ydjpBAGnJAWtPPGSJzjg9wr4Eh+onbSikQIZs3SSEA2uzlwibi24uSMWJbaQLILG8EnOh+7raPzYJU1dgQAyW/6yRLwVieJ75e8jbAwc0NY7TUQEmvXxk7Xug9neQoF4weLIZhiRlsskJl504hShlg3jVNgy6jPb0UhmexuUHETUDhDEL0Ae6ZRKmoYgKeyAKeAuATIp7X+E485X77LZT9YDkW3iLOFPDekA2xaCsW4LrHBQMiQsLodb0X4yG/4b794rqjDx6163h/Dhuf6tX5CebufU7gMWI6Zw34Z98vWML1PHAtgY5Se1gmXH47gMZjExrMJxwpl9ymgvnjEOvi8on/B/d5rRgB7Z+RJNCmo0EjABH5Rd+x6raCLsRxwqGk4IsEVlu3jIyHGGO+B8FOoXZEHy3MPZvd7iRSg4LB4tXXxqtDUaTxRo12G3I84MPpj93xrbQDy9ae7BqFDBp816/k2E0DxOwKjTFMHBZ1Ids0bj1QbQbteeVs9KigQyICRQHqbSDdcg6c7ouvY0MBEeaczfxmqs1UnPVF/mwB9eddSS6QV9HB7jwwnOSOVknhI2p2t63rE3xCUr/fvsx04KM4IeWMscFPUiBjtAuFrH7de3+6bOiEmtZN/IXJM588JB3goOrqTES5FSM9Pv0YERd2+fRdVP9CnFsbejpI1MqSod3iAEz7pKP3091hb55YwkC0WQNt3ZzbA0tvxiNoIsZb5kLduIQapExxflW1Nix0D7rSlcFaTRJYzkFkLX3O6dAs517eoXvkxH+7QqBFMJ3EDGpL4TtPupdBp+F4bOXMJ8w7iLeJxIaQhTDibva4Q//ZPgd5+Oaebz30O/7hHuMf3X7+V8EoHcZAVEzJV4p/ckbNY8ejogtYFY8LtOYx0W2iV7FobNrEkiZYq2/f4yX2lJY51Hg2bO/FDyFiHEqYLyf8eUICg2yeMS6XeT X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 304ae08e-204c-496b-4595-08db71a23774 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4344.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2023 15:22:53.3417 (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: okW3F3Rug+O+F3CjuVq6qd48pQLOBHu7534gX51dowRH0BSw9+TlufmftzovaZwVfI+oMELYnrRBWjm9YU7ieg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6437 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-20_11,2023-06-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306200139 X-Proofpoint-GUID: 7gMs7HZAmccI5ZCOwwadi8nwIdO8IahX X-Proofpoint-ORIG-GUID: 7gMs7HZAmccI5ZCOwwadi8nwIdO8IahX X-Spam-Status: No, score=-11.4 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, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Qing Zhao via Gcc-patches From: Qing Zhao Reply-To: Qing Zhao Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" on a structure with a C99 flexible array member being nested in another structure GCC extension accepts the case when a struct with a flexible array member is embedded into another struct or union (possibly recursively) as the last field. This patch is to introduce the IR bit TYPE_INCLUDES_FLEXARRAY (reuse the existing IR bit TYPE_NO_NAMED_ARGS_SATDARG_P), set it correctly in C FE, stream it correctly in Middle-end, and print it during IR dumping. PR C/77650 gcc/c/ChangeLog: * c-decl.cc (finish_struct): Set TYPE_INCLUDES_FLEXARRAY for struct/union type. gcc/lto/ChangeLog: * lto-common.cc (compare_tree_sccs_1): Compare bit TYPE_NO_NAMED_ARGS_STDARG_P or TYPE_INCLUDES_FLEXARRAY properly for its corresponding type. gcc/ChangeLog: * print-tree.cc (print_node): Print new bit type_include_flexarray. * tree-core.h (struct tree_type_common): Use bit no_named_args_stdarg_p as type_include_flexarray for RECORD_TYPE or UNION_TYPE. * tree-streamer-in.cc (unpack_ts_type_common_value_fields): Stream in bit no_named_args_stdarg_p properly for its corresponding type. * tree-streamer-out.cc (pack_ts_type_common_value_fields): Stream out bit no_named_args_stdarg_p properly for its corresponding type. * tree.h (TYPE_INCLUDES_FLEXARRAY): New macro TYPE_INCLUDES_FLEXARRAY. --- gcc/c/c-decl.cc | 11 +++++++++++ gcc/lto/lto-common.cc | 5 ++++- gcc/print-tree.cc | 5 +++++ gcc/tree-core.h | 2 ++ gcc/tree-streamer-in.cc | 5 ++++- gcc/tree-streamer-out.cc | 5 ++++- gcc/tree.h | 7 ++++++- 7 files changed, 36 insertions(+), 4 deletions(-) diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 1af51c4acfc..e14f514cb6e 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -9267,6 +9267,17 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, /* Set DECL_NOT_FLEXARRAY flag for FIELD_DECL x. */ DECL_NOT_FLEXARRAY (x) = !is_flexible_array_member_p (is_last_field, x); + /* Set TYPE_INCLUDES_FLEXARRAY for the context of x, t. + when x is an array and is the last field. */ + if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE) + TYPE_INCLUDES_FLEXARRAY (t) + = is_last_field && 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))) + TYPE_INCLUDES_FLEXARRAY (t) + = is_last_field && TYPE_INCLUDES_FLEXARRAY (TREE_TYPE (x)); + if (DECL_NAME (x) || RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))) saw_named_field = true; diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc index 537570204b3..f6b85bbc6f7 100644 --- a/gcc/lto/lto-common.cc +++ b/gcc/lto/lto-common.cc @@ -1275,7 +1275,10 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map) if (AGGREGATE_TYPE_P (t1)) compare_values (TYPE_TYPELESS_STORAGE); compare_values (TYPE_EMPTY_P); - compare_values (TYPE_NO_NAMED_ARGS_STDARG_P); + if (FUNC_OR_METHOD_TYPE_P (t1)) + compare_values (TYPE_NO_NAMED_ARGS_STDARG_P); + if (RECORD_OR_UNION_TYPE_P (t1)) + compare_values (TYPE_INCLUDES_FLEXARRAY); compare_values (TYPE_PACKED); compare_values (TYPE_RESTRICT); compare_values (TYPE_USER_ALIGN); diff --git a/gcc/print-tree.cc b/gcc/print-tree.cc index ccecd3dc6a7..62451b6cf4e 100644 --- a/gcc/print-tree.cc +++ b/gcc/print-tree.cc @@ -632,6 +632,11 @@ print_node (FILE *file, const char *prefix, tree node, int indent, && TYPE_CXX_ODR_P (node)) fputs (" cxx-odr-p", file); + if ((code == RECORD_TYPE + || code == UNION_TYPE) + && TYPE_INCLUDES_FLEXARRAY (node)) + fputs (" includes-flexarray", file); + /* The transparent-union flag is used for different things in different nodes. */ if ((code == UNION_TYPE || code == RECORD_TYPE) diff --git a/gcc/tree-core.h b/gcc/tree-core.h index c48a12b378f..668808a29d0 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -1713,6 +1713,8 @@ struct GTY(()) tree_type_common { unsigned typeless_storage : 1; unsigned empty_flag : 1; unsigned indivisible_p : 1; + /* TYPE_NO_NAMED_ARGS_STDARG_P for a stdarg function. + Or TYPE_INCLUDES_FLEXARRAY for RECORD_TYPE and UNION_TYPE. */ unsigned no_named_args_stdarg_p : 1; unsigned spare : 1; diff --git a/gcc/tree-streamer-in.cc b/gcc/tree-streamer-in.cc index c803800862c..be2bdbb7699 100644 --- a/gcc/tree-streamer-in.cc +++ b/gcc/tree-streamer-in.cc @@ -386,7 +386,10 @@ unpack_ts_type_common_value_fields (struct bitpack_d *bp, tree expr) if (AGGREGATE_TYPE_P (expr)) TYPE_TYPELESS_STORAGE (expr) = (unsigned) bp_unpack_value (bp, 1); TYPE_EMPTY_P (expr) = (unsigned) bp_unpack_value (bp, 1); - TYPE_NO_NAMED_ARGS_STDARG_P (expr) = (unsigned) bp_unpack_value (bp, 1); + if (FUNC_OR_METHOD_TYPE_P (expr)) + TYPE_NO_NAMED_ARGS_STDARG_P (expr) = (unsigned) bp_unpack_value (bp, 1); + if (RECORD_OR_UNION_TYPE_P (expr)) + TYPE_INCLUDES_FLEXARRAY (expr) = (unsigned) bp_unpack_value (bp, 1); TYPE_PRECISION (expr) = bp_unpack_var_len_unsigned (bp); SET_TYPE_ALIGN (expr, bp_unpack_var_len_unsigned (bp)); #ifdef ACCEL_COMPILER diff --git a/gcc/tree-streamer-out.cc b/gcc/tree-streamer-out.cc index 5751f77273b..6d4a9d90da6 100644 --- a/gcc/tree-streamer-out.cc +++ b/gcc/tree-streamer-out.cc @@ -355,7 +355,10 @@ pack_ts_type_common_value_fields (struct bitpack_d *bp, tree expr) if (AGGREGATE_TYPE_P (expr)) bp_pack_value (bp, TYPE_TYPELESS_STORAGE (expr), 1); bp_pack_value (bp, TYPE_EMPTY_P (expr), 1); - bp_pack_value (bp, TYPE_NO_NAMED_ARGS_STDARG_P (expr), 1); + if (FUNC_OR_METHOD_TYPE_P (expr)) + bp_pack_value (bp, TYPE_NO_NAMED_ARGS_STDARG_P (expr), 1); + if (RECORD_OR_UNION_TYPE_P (expr)) + bp_pack_value (bp, TYPE_INCLUDES_FLEXARRAY (expr), 1); bp_pack_var_len_unsigned (bp, TYPE_PRECISION (expr)); bp_pack_var_len_unsigned (bp, TYPE_ALIGN (expr)); } diff --git a/gcc/tree.h b/gcc/tree.h index 1854fe4a7d4..84e23aeba44 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -807,7 +807,12 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int, (...) prototype, where arguments can be accessed with va_start and va_arg), as opposed to an unprototyped function. */ #define TYPE_NO_NAMED_ARGS_STDARG_P(NODE) \ - (TYPE_CHECK (NODE)->type_common.no_named_args_stdarg_p) + (FUNC_OR_METHOD_CHECK (NODE)->type_common.no_named_args_stdarg_p) + +/* True if this RECORD_TYPE or UNION_TYPE includes a flexible array member + as the last field recursively. */ +#define TYPE_INCLUDES_FLEXARRAY(NODE) \ + (RECORD_OR_UNION_CHECK (NODE)->type_common.no_named_args_stdarg_p) /* In an IDENTIFIER_NODE, this means that assemble_name was called with this string as an argument. */