From patchwork Fri Apr 19 18:43:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qing Zhao X-Patchwork-Id: 88758 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7BF9738449C8 for ; Fri, 19 Apr 2024 18:44:20 +0000 (GMT) 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 4A79C3846401 for ; Fri, 19 Apr 2024 18:43:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4A79C3846401 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 4A79C3846401 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=1713552214; cv=pass; b=GvaTsNBRNOGYVSLqrNFs4O7ipgwViPqHIESY4L0FSyXahEEiFKXTMROnHk15g9wuUdavNChfvBwrTbnZkvm0N8rJPek3DpsaOIdShBtI8OYTd0uXfE0fuUcVMZFBFXcCvbJBcC+lyMUrLH8uxIFysFFpGQVKEipNTeZMNBQyIv4= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713552214; c=relaxed/simple; bh=WtEN/MUrHBro1GY5O/2ynDYvk9jNqi0t1s+oTrjcjgU=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=xEZiFEjGxhhk6Lcbt8mUl5tlFHlkDUefIrHuNWwubvpvga6Eu5r3YFW+PF9H3vgVeyuNyhSgrYt5y2UMfGo+7kXaZmvWVn0szg5N+KK8Zzm11MSZ79gjGWHnXt2kiPI/13hXXVRxJr+uJ9c1hf23gVOq9C+9bA4hmXKuidGsua0= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43JIOGig020853; Fri, 19 Apr 2024 18:43:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=SJHT7QevpUv0uILYCsx9tQQE2SszbQ86BtwMgNWKnLU=; b=O7dDD6QB8M9mOSIvT1lu/tPpkM9ISxcYEszNsUy+9ndjBSRr885SXxgu1g5zIoDqgckh +HmHrw1VLHNTfspOMbbCOtz4m1YkCcCsqM1V4cD5A95RHrpH9gUkbuZ5ahHGU85oF/bb Ral5BD+0bXesSiQnNc5r4RCyMZxuitwXaOjF7zDkR39fp5MjHjUvHQvE/88t//4Iq46z oL31oor84Fnv+KqGn7/5Ks5G5h4jIkW46qprdDsOxsMA29qQTj42ESVNwt8fXlBQBmvP caNledntkrYQ9lJCeM56uQhXjOnpkOgzdzNwfivut6V2lX7YCqlKbaEm3AUsD+7tNmms bA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xfjkvdf9u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 18:43:30 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 43JHLAk2014319; Fri, 19 Apr 2024 18:43:29 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xkc97xrwk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 18:43:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZKtvE6Md7dCh0XD7RQlILnK9u+MAs/59Zl2VtZhgQ34BEsTrLMafXgKgcPGsypxCRzX5ZFOKTioUq4z5bHZiWQd7j2q9q4epQB1lHbwuswwg88Vpx0w7yow45qMjygUVxhKXIFfqYJsHkcQaAg8jPmCgZ3JbLuLBdPlKMXw7txdC01jcb7YmGqPkyX2ZGvHRhKDauuuUhgWswYbw2TcVodhT5o7t5qDqnoYVSpQX0/hTdfz8pobJ7KAhkbFzWIFukNN4lpswPCTELMBgoJCRzoaF9qq2On5FG6pXbnXqX6tW1KHrksxO7fYnB894lbCa6oB55nE/h5R5SlAIsIvUUg== 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=SJHT7QevpUv0uILYCsx9tQQE2SszbQ86BtwMgNWKnLU=; b=mXQRfMGFP0nxcmSh8sJhs2+9e19QaH9NCiwbj6GjV4q9RFJDLU6qaBktBgKVkXWvAU5TYmPUI+JdDW6ml7OOCfN/uMGjLDqQF8WPUJQhEjNwEPSmF1W/yaShDNf3+se1b22wmtQGOx1m2SFw2OZ9CCGn3uBH7InZekgRt+Aj7TZfF2AShtY+fKrQ+vHNe7eX8xy7Dax4lEzUYoFCHptxefVrY38uWwSr7cRyXTezz1pa2Rt+EG1kdcPrX28J6QlHTXfeLJdUqoaEoxV4obQ0px8DvtRQLvkRk0J+BWjXVosB4r7PR7OBKWMnpWxgxqi+BY9SUA5K3sIOynIRtMQiWA== 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=SJHT7QevpUv0uILYCsx9tQQE2SszbQ86BtwMgNWKnLU=; b=c711rlIM5hOcJUO7XlsDXhAPOdrunyq/jj7Bf/2QvKc6k3AIQ4V8a8yZk//MYE/Rzw2NQd9WLxwz8fDv7ys6ckVYO4lS1E63//kuCFLteN464RwdxwH1YsS8rQ48krUlazdWYFA14lZbhFbiyq0r9kDi8kvepOqsmqOTHYRQUg4= Received: from CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) by DM4PR10MB7425.namprd10.prod.outlook.com (2603:10b6:8:180::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.43; Fri, 19 Apr 2024 18:43:24 +0000 Received: from CY8PR10MB6538.namprd10.prod.outlook.com ([fe80::2dae:7852:9563:b4bc]) by CY8PR10MB6538.namprd10.prod.outlook.com ([fe80::2dae:7852:9563:b4bc%6]) with mapi id 15.20.7472.037; Fri, 19 Apr 2024 18:43:24 +0000 From: Qing Zhao To: josmyers@redhat.com, richard.guenther@gmail.com, uecker@tugraz.at Cc: siddhesh@gotplt.org, keescook@chromium.org, gcc-patches@gcc.gnu.org, Qing Zhao Subject: [RFC][PATCH v1 1/4] Documentation change Date: Fri, 19 Apr 2024 18:43:14 +0000 Message-Id: <20240419184317.2138890-2-qing.zhao@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240419184317.2138890-1-qing.zhao@oracle.com> References: <20240419184317.2138890-1-qing.zhao@oracle.com> X-ClientProxiedBy: BL1PR13CA0130.namprd13.prod.outlook.com (2603:10b6:208:2bb::15) To CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB6538:EE_|DM4PR10MB7425:EE_ X-MS-Office365-Filtering-Correlation-Id: 009fcc19-7641-4b32-6951-08dc60a09844 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ia05A/xE204Z88EfoOydMGEalBlERCBlhBBVYYSxPvCsvXvPT91wdWXOgz9t7DLFlMkSqNMyMq00HMUbq6gZ6W3bd2gUMeIHPfjje+OeLJ7LBpCOyrjhTUCYJEYbYJTm5qLa/DOlZa+6p58vHilFBmaCvRJoawHWCEc7PSWs+HwDRl/NZpaytPLBLDfRqmYmPe6WtfrRf1HLETvJPNIzOjYmjjY9YzMYD+AY7blVOYHI72ILtcubK+hFnbmMNVvLNGjsPVCtmD8ATmRUXlKgT9Oo7nkrgVPikmzw37YAh6ZBouyRQIHKojiIhLXa3SuS1/dm2NJJ0NWsvxvKRELR566WNsuxQO3Fgc4uwqLNtuBUrHFTZ7q94VD8izNhz/dtY8VqTRY7jr8vEuV4Mo/WcYYKT92qGHUJLHFMgb7QvWqnggkujXHP0lemeY6+VKhuOUafuROpY8mUXaQ9vxwYPkKauZ5/BTvbla8bXvOobWYdhJ9sKoT5nEopZOv78mq8Ar9P8kfNMYqFqY7F/RhPJwtK3HJAiub9v5d145k633I7859iz93+DpSuJf8P9IEnFVTeQ4xn+PU33TldLi1RFPyKwly6z6hYlnxx8bq2NCTo+o651IYF+nLRKZ7PRo05S1oAQIxGknl8Ded2CYjDqG+N3ormyl+0v7HGadOO3b8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY8PR10MB6538.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(1800799015)(376005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h/EEdZEAm52jMJGCwNZtHba7XVYUTyP9Uty5u0xliU4Y0ue9oFhhS/12h1IyyCLw5PFAJvcd9Kn2ChVvmtk3a2zFColoj71TMAYeF8BZNFR15XFbUXkatszCONieNWOyC6DMCofTlh9FNh+LUxD2O5RWQXYTbRpFfJkq8jpbCcT1olQWWOthfQP5keds4tIqPOf3IZydJfASTKS7hHAt/VJB1xfQxQ6jJZaZYRXhwCs9HhC7ZGotqsNboD4/IOdyOVvvpvuqQuBeDodqATtX5kIRUEGvfqNbG+0jhHtoiAxDiIGt5eBm9e+PpgJe//Z8AY6wzGGmifa+qtLRsFP1XMyofcFpSOjZBuJwu5PSOhIXtp6h27dieh9CDUNqSU4ORwGM7YAeBxCnKHT7IcHVJgjLE/G51yxQuZL4ZKlcL2S1hSenDy+uMEzi89vp9FzbmnivXKJJ1aGB71TaLSRh8jzKs8a72K4XQxz7Z9nX/qWIK8glMLGTP8gpVp41QpWq5mdXoeBn8DUbwpENLlu/hzBqdSSnJC0iRK2GNrq/P78lyPjglL0XbECEZNxb0YIYCDjaFshZmGqwuMgwRokNmNeqk03oRuWBuzpAB23cf9HmsTzE94RtLTAoPxkJ4oDeG8EVA3UVvKDshiR/tgLtpqKJb8JByYGBcEjFWeDILB+DeKhMJAjbO3U7zIVIodSTjl9YbG+rAM54xaidi52ShhrcwRGI+NiUEspU7iJ30XXSnQnfyqoR0kF4WOdQ/gnPgGb9YVIqFck8XSiQbIHXgIH9ldJ3Q1UnYe2psqMUQZ9c4fmc+s5f/8Fyw1g/RpVVavaAM8hil7dgxf29HrB7HAufl9vvfUE1K32l9dvKkuzpZRPOiJfE08GeQAxntUU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7iBPzk86MliVlt4jCr/ronni/11KXQ2jCCfHbWgAQkqRpQYV0sQBhwhilJB6Mq9WAVAFXmB6/Ly0HDkTi4fsJ949CEiI0fZGyT2k1Q4uMsyBZI81/+UTxfwlkyDKuMizMkpaBjaHni7lbGbW6J4oelDUUdw8fa3ckneb2n7UAcrmGjpf2pK85nx+YcnUwipAm2856HzRX5jVa8vvkYAHWBC/gRy1eniZTG0k6EBlh/69mXiy98i3pnaR8nb4wu+A6cZQhOpCzlcdEKSnuDbe8tjigiJwu8Kz9u9XPn5smJU0ccjV1ILl7RvF3tPbS04fgFw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 009fcc19-7641-4b32-6951-08dc60a09844 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB6538.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 18:43:24.6477 (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: Ua2a1yYasIRWuNm7pThv7pU4gbc46Cj4KzuZJfvhb3L3E7V3Vy8SIThpY/3cud4L4obNL2qCEPGGwHQX2gImYA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB7425 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-19_13,2024-04-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404190144 X-Proofpoint-ORIG-GUID: UGULGOU1anGpsnCYsqS8zez7oJL6rpYU X-Proofpoint-GUID: UGULGOU1anGpsnCYsqS8zez7oJL6rpYU X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H4, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org for allow flexible array members in unions and alone in structures [PR53548] The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53548 However, this PR was closed as WONTFIX around 2015 due to the following reason: "there is an existing extension that makes the requested functionality possible" i.e GCC fully supported that the zero-length array can be in a union or alone in a structure for a long time. (though I didn't see any official documentation on such extension) It's reasonable to close PR53548 at that time since zero-length array extension can be used for such purpose. However, since GCC13, in order to improve the C/C++ security, we introduced -fstrict-flex-arrays=n to gradually eliminate the "fake flexible array" usages from C/C++ source code. As a result, zero-length arrays eventually will be replaced by C99 flexiable array member completely. Therefore, GCC needs to explicitly allow such extensions directly for C99 flexible arrays, since flexable array member in unions or alone in structs are common code patterns in active use by the Linux kernel (and other projects). For example, these do not error by default with GCC: union one { int a; int b[0]; }; union two { int a; struct { struct { } __empty; int b[]; }; }; But these do: union three { int a; int b[]; }; struct four { int b[]; } Clang has supported such extensions since March, 2024 https://github.com/llvm/llvm-project/pull/84428 GCC should also support such extensions. This will allow for a seamless transition for code bases away from zero-length arrays without losing existing code patterns. gcc/ChangeLog: * doc/extend.texi: Add documentation for Flexible Array Members in Unions and Flexible Array Members alone in Structures. --- gcc/doc/extend.texi | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 7b54a241a7bf..b12ce5fb9b87 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -42,6 +42,8 @@ extensions, accepted by GCC in C90 mode and in C++. * Named Address Spaces::Named address spaces. * Zero Length:: Zero-length arrays. * Empty Structures:: Structures with no members. +* Flexible Array Members in Unions:: Unions with Flexible Array Members. +* Flexible Array Members alone in Structures:: Structures with only Flexible Array Members. * Variable Length:: Arrays whose length is computed at run time. * Variadic Macros:: Macros with a variable number of arguments. * Escaped Newlines:: Slightly looser rules for escaped newlines. @@ -1873,6 +1875,41 @@ The structure has size zero. In C++, empty structures are part of the language. G++ treats empty structures as if they had a single member of type @code{char}. +@node Flexible Array Members in Unions +@section Unions with Flexible Array Members +@cindex unions with flexible array members +@cindex unions with FAMs + +GCC permits a C99 flexible array member (FAM) to be in a union: + +@smallexample +union with_fam @{ + int a; + int b[]; +@}; +@end smallexample + +The size of the union is as if the flexiable array member were omitted +except that it may have more trailing padding than the omission would imply. + +If all the members of a union are flexiable array member, the size of +such union is zero. + +@node Flexible Array Members alone in Structures +@section Structures with only Flexible Array Members +@cindex structures with only flexible array members +@cindex structures with only FAMs + +GCC permits a C99 flexible array member (FAM) to be alone in a structure: + +@smallexample +struct only_fam @{ + int b[]; +@}; +@end smallexample + +The size of such structure gives the size zero. + @node Variable Length @section Arrays of Variable Length @cindex variable-length arrays From patchwork Fri Apr 19 18:43:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qing Zhao X-Patchwork-Id: 88757 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A7D438460BD for ; Fri, 19 Apr 2024 18:44:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 584F33849ADC for ; Fri, 19 Apr 2024 18:43:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 584F33849ADC Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 584F33849ADC Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713552214; cv=pass; b=o401QdC2j6AcAOyh0AneVulgoocXdOzwClJrh2Oz1doxIEjcpdooFKMX2/Kqc/pf1TOwgVMIVBLSPEA3vT/l9+kpBwITBXfKsdyRK8n5nvMG4jIaV66JRP91c7yQnW31cQgCBNFxauVcmrTKvM1vROYDctVmuzQR42kis2S0NKs= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713552214; c=relaxed/simple; bh=2rSlzJHcPUvVIsyq6lIpjDtHKdF5dJzw4vw1xIrGE9s=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=dgPhwCHwFW+BY/DeOGlcb26ZtV9EfTGAHSfxt33qNkmXZxIn5hEIgmveNqWdPTl+3EsrGR2KC5evnVWxxEGDyBwgw3QJ5tuVynyBkNa2H6KCI/2jKUecNrMkGBmetqhhmsCfcbTbrSQm5AAFgCE9Ei6lan1oTpPVr3jDFgCV69k= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43JIO5IE001391; Fri, 19 Apr 2024 18:43:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=tKwo2NgN5wPJhvESoualwC1cxr84ZSdWkl4T9dFnwhY=; b=dDqELpKlazrMTf1HOp0qWG1yFwdKzfpI5Zm/G9YbaQsebpkqa3FmFq9dUJlmSzsAzeJ6 R2710xfHXrsg/a/gZNrRed++0tE7PMdNauRhEmy8dues62QrVAEi9+Cl49PukW9N1ADd 8+XXQ77lHD7IPY5ZV+lnO58j/oBaSbX4xo8vQc/VZTfWr+gzbSlzuJSvqesmYFKotmab idOR9W69xcCrRUqTDihbUvk+hRIsC/Pl53vC2LBhYuj4YxU6no5Bn5Od7i53MCDDX+4K zo+QO3yp0yjr1/vsTKaTuxuU68GU/JDn0RSEcR92KxFB9/H5ZzyX0wcd3rQx+ZcXiNVL AQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xfgujwng4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 18:43:31 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 43JHLAk3014319; Fri, 19 Apr 2024 18:43:30 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xkc97xrwk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 18:43:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xc+bP071gdg7olxEE2awJXMZ+Pg5KNPQtrFzCw1SQe7+bNPPmccMmr7emAaU1kcRE/utKaASIyTE1zXl8ZgV21J1wf4BFoPy6W2epLNU2OEZu/hCzcTbJq35A57E8Kg6vG3J8iiNdyYvxpUOeg+SWmM1bnIxwLYPdAXrOUd47HndUtlsAPYtvCUeSw+/Sx73IHxhHEWV0BiJN+VG3fzzxaNOtiQYl0qSX1M+Mhex6B+o/VUC1TfsAnFi2rKPl/M7xJ0/sPqAlGPWjrJNgG3EsS9KXGXtbQBg9WtcQ4R+bI+gh25EQsQetLKAisfjjn/g1FvzQreZLoACb/hSXBvq3A== 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=tKwo2NgN5wPJhvESoualwC1cxr84ZSdWkl4T9dFnwhY=; b=bJnSah8fi7U7w10i/zau/Oer5t0QPRjWFcbIIogWT+kJ+XIHc/C+8Rxh2/X71v5MG5cnmgKD76xHzzfT1GBJ8XtH7DFTDyXNKevB4a2/xPWZsmFvxJL8KH7iR2QC+RtSEV+ftF7azBrKniL8jgb6mkJZY+hWOpWSBwZ6eVAy7ZOvSy7hJpPORa93ag1KrBNxwzEZToYSxeDQKxrFiagmk46kyHe5p7BnVJ2iPtkqSDIS54Tj8T43s5zqLzf1T1x7K0c7NtxsMyyGFzyJur9wUtnQ1Kk3o6Exq0wDnzKuhh5tBPtW0ztEAUNfQ2VFUWfuTkZ/YBnM7j9Q22zZVGRcsQ== 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=tKwo2NgN5wPJhvESoualwC1cxr84ZSdWkl4T9dFnwhY=; b=YF3xb4N+Z1W8bX3572ebPMSEBeKS2en7+c/IVMhQEvZ5EiAYIXWVRQm2nDV1/okjGua+SM+kc4/ej34hz+c4irrcktCnqsGV8OufsNBQ6EwVtiCPud+2n7tVmQ/6NocEIgiU9MqPsqA3zs2xD4LZN6uGZBwkbJQM0Y4+FdojABE= Received: from CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) by DM4PR10MB7425.namprd10.prod.outlook.com (2603:10b6:8:180::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.43; Fri, 19 Apr 2024 18:43:28 +0000 Received: from CY8PR10MB6538.namprd10.prod.outlook.com ([fe80::2dae:7852:9563:b4bc]) by CY8PR10MB6538.namprd10.prod.outlook.com ([fe80::2dae:7852:9563:b4bc%6]) with mapi id 15.20.7472.037; Fri, 19 Apr 2024 18:43:28 +0000 From: Qing Zhao To: josmyers@redhat.com, richard.guenther@gmail.com, uecker@tugraz.at Cc: siddhesh@gotplt.org, keescook@chromium.org, gcc-patches@gcc.gnu.org, Qing Zhao Subject: [RFC][PATCH v1 2/4] C and C++ FE changes to support flexible array members in unions and alone in structures. Date: Fri, 19 Apr 2024 18:43:15 +0000 Message-Id: <20240419184317.2138890-3-qing.zhao@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240419184317.2138890-1-qing.zhao@oracle.com> References: <20240419184317.2138890-1-qing.zhao@oracle.com> X-ClientProxiedBy: BL1PR13CA0283.namprd13.prod.outlook.com (2603:10b6:208:2bc::18) To CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB6538:EE_|DM4PR10MB7425:EE_ X-MS-Office365-Filtering-Correlation-Id: 69cd157e-95d5-419c-ee97-08dc60a09aa1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8VL/cmjSHoJs1LNT6b3X3bz3RmBTH1lJNMHA1oyQmYq/2LJJz2lTY+bUwORB4rGFhfrq3hSXjeMqxDA5bp4o/dPXtuuU2kRGHmyWmm/aft4JfqMHVpKRQsfhCl3FEWHs5sM4bnXmH0ozr9FXBO1Yw8St1Qfaje6Hgypt6o7XgwmlP9p/jEHV3+SyLJwxuK0mOaSylQTemhrBxrMHujsjRlH2HwJXFcpIUO6Jk8vy18Ge/1a3B21VSumwvGfeYVPVX7JwhCY7Grg2TT1/7IW4CDVADqaKMokhxnjnEuD0uBtx8Yy4gSJiOk46Kj4PtApCHONsgLF7/dzU2wsv+rMNXTiuhp+5SW2Ld85KyOUyBOJODwZTJPTheoVXxVh2OWCs8HtpKJbLzguhsnDcWYbzgG2FEBuReSLkaB6ANzZg6x/+zIO1IRbb6ATbfjo2EoHTns/y2J6zlsYeXoBN6jShJoTJKgx+RmCxSDNEh7W4lqBp3r9WNrryJ0YE/+X6NxDq5rVUK7x9seOdYEi62UFODBOleEZ020sdI9NGBPlnYwJ+Dzt6YsKB00ykZfxIwJ6lrLMgF2oGGe6cqR0ScYr5Y3/pAdTIUuDZi3XM30XdQZcsLJ4v96K2gZqaUXDs6iS3w8X2h7R4Pq08mIp3e6nlvtS5/8V36kPa1N8IeguQI7A= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY8PR10MB6538.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(1800799015)(376005); DIR:OUT; SFP:1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eLFwlVkb+JY9Xn64UpnBvzVHpRutizmn6/JUx7IYnF1/cqIw8CuRhjZqrdu8fqfl0NjfyLI7gMr+mFimsRfdvL00Pa7nnYdWPRbLOBYWD19e739zw1DXEsHByHgyLtceilFWUua+iSj/uaSn81X9zuZ2XQ35DA+Na8Z+C/fczI7oQAX7W2QGoams36VbZHaIiasH+0nZUVkQ8HTu0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69cd157e-95d5-419c-ee97-08dc60a09aa1 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB6538.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 18:43:28.6134 (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: 4UEBTX3duav1o7ux2MDEGPS0oCmVkgMjVjkKiifZmjMSp3yQJdG2gpNyYMOTVpbhfL1mC8J72NRxYhdpD18N+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB7425 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-19_13,2024-04-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404190144 X-Proofpoint-ORIG-GUID: juh-hyPNkXh9n3ELD4QIeHeT4bfkawSR X-Proofpoint-GUID: juh-hyPNkXh9n3ELD4QIeHeT4bfkawSR X-Spam-Status: No, score=-11.6 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_H4, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or alone in structures. gcc/cp/ChangeLog: * class.cc (diagnose_flexarrays): Change error to pdewarn for the case flexible array members alone in structures. * decl.cc (grokdeclarator): Change error to pdewarn for the case flexible array members in unions. gcc/ChangeLog: * stor-layout.cc (place_union_field): Use zero sizes for flexible array member fields. --- gcc/c/c-decl.cc | 16 +++++----------- gcc/cp/class.cc | 11 ++++++++--- gcc/cp/decl.cc | 7 +++---- gcc/stor-layout.cc | 9 +++++++-- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 345090dae38b..947f3cd589eb 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -9471,11 +9471,8 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, if (flexible_array_member_type_p (TREE_TYPE (x))) { if (TREE_CODE (t) == UNION_TYPE) - { - error_at (DECL_SOURCE_LOCATION (x), - "flexible array member in union"); - TREE_TYPE (x) = error_mark_node; - } + pedwarn (DECL_SOURCE_LOCATION (x), OPT_Wpedantic, + "flexible array member in union is a GCC extension"); else if (!is_last_field) { error_at (DECL_SOURCE_LOCATION (x), @@ -9483,12 +9480,9 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, TREE_TYPE (x) = error_mark_node; } else if (!saw_named_field) - { - error_at (DECL_SOURCE_LOCATION (x), - "flexible array member in a struct with no named " - "members"); - TREE_TYPE (x) = error_mark_node; - } + pedwarn (DECL_SOURCE_LOCATION (x), OPT_Wpedantic, + "flexible array member in a struct with no named " + "members is a GCC extension"); } if (pedantic && TREE_CODE (t) == RECORD_TYPE diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc index 5f258729940b..0c8afb72550f 100644 --- a/gcc/cp/class.cc +++ b/gcc/cp/class.cc @@ -7624,6 +7624,7 @@ diagnose_flexarrays (tree t, const flexmems_t *fmem) bool diagd = false; const char *msg = 0; + const char *msg_fam = 0; if (TYPE_DOMAIN (TREE_TYPE (fmem->array))) { @@ -7649,15 +7650,19 @@ diagnose_flexarrays (tree t, const flexmems_t *fmem) if (fmem->after[0]) msg = G_("flexible array member %qD not at end of %q#T"); else if (!fmem->first) - msg = G_("flexible array member %qD in an otherwise empty %q#T"); + msg_fam = G_("flexible array member %qD in an otherwise" + " empty %q#T is a GCC extension"); - if (msg) + if (msg || msg_fam) { location_t loc = DECL_SOURCE_LOCATION (fmem->array); diagd = true; auto_diagnostic_group d; - error_at (loc, msg, fmem->array, t); + if (msg) + error_at (loc, msg, fmem->array, t); + else + pedwarn (loc, OPT_Wpedantic, msg_fam, fmem->array, t); /* In the unlikely event that the member following the flexible array member is declared in a different class, or the member diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 65ab64885ff8..9a91c6f80da1 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -14566,10 +14566,9 @@ grokdeclarator (const cp_declarator *declarator, if (ctype && (TREE_CODE (ctype) == UNION_TYPE || TREE_CODE (ctype) == QUAL_UNION_TYPE)) - { - error_at (id_loc, "flexible array member in union"); - type = error_mark_node; - } + pedwarn (id_loc, OPT_Wpedantic, + "flexible array member in union is a GCC extension"); + else { /* Array is a flexible member. */ diff --git a/gcc/stor-layout.cc b/gcc/stor-layout.cc index e34be19689c0..10c0809914cd 100644 --- a/gcc/stor-layout.cc +++ b/gcc/stor-layout.cc @@ -1245,13 +1245,18 @@ place_union_field (record_layout_info rli, tree field) && TYPE_TYPELESS_STORAGE (TREE_TYPE (field))) TYPE_TYPELESS_STORAGE (rli->t) = 1; + /* We might see a flexible array member field (with no DECL_SIZE_UNIT), use + zero size for such field. */ + tree field_size_unit = DECL_SIZE_UNIT (field) + ? DECL_SIZE_UNIT (field) + : build_int_cst (sizetype, 0); /* We assume the union's size will be a multiple of a byte so we don't bother with BITPOS. */ if (TREE_CODE (rli->t) == UNION_TYPE) - rli->offset = size_binop (MAX_EXPR, rli->offset, DECL_SIZE_UNIT (field)); + rli->offset = size_binop (MAX_EXPR, rli->offset, field_size_unit); else if (TREE_CODE (rli->t) == QUAL_UNION_TYPE) rli->offset = fold_build3 (COND_EXPR, sizetype, DECL_QUALIFIER (field), - DECL_SIZE_UNIT (field), rli->offset); + field_size_unit, rli->offset); } /* A bitfield of SIZE with a required access alignment of ALIGN is allocated From patchwork Fri Apr 19 18:43:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qing Zhao X-Patchwork-Id: 88759 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D66E3384514B for ; Fri, 19 Apr 2024 18:45:26 +0000 (GMT) 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 6BEE83849AE6 for ; Fri, 19 Apr 2024 18:43:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6BEE83849AE6 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 6BEE83849AE6 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=1713552218; cv=pass; b=gYcBmcqQuCoY5seRDbeRLgqdFhkcbA94ZFFNrIg8DFGQo7yMp8lve9atgxskXljzcU47llh+TdSsxoRx6aCDlxEXZjwF2NPHK5vPiomdTm1G5vm+LumfIlasQQa/qpyfKP4+ww380lEgvBRPH1LcfscRyJwGtURHYFFKFPYRf9g= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713552218; c=relaxed/simple; bh=sB6JzymRWOi1TFEXUOpTSBxWj5JKdZZg/TsdZl0hxCI=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=sNv0Wy6bS9/nsbYpjrqrUTdPAtgM4Ido1ShoY/q2X7U6CgCtfP9oOQoKdB1iXZXY0K8fgL4dSP1+Tz+/DrO7zdH0RvRcvV8Wgk4lCrieejzr0A31HHo1DpfSHbXXwwGgQUDm+9BqY7pKlrnL1t1iSp7df6IZnuIESs8gklGlvwc= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43JIOGOr020839; Fri, 19 Apr 2024 18:43:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=1nuANQJK5bxbFvcvIyWXaPisIFeWdntWnInJb1SVwLw=; b=Dz5seUozDRFZ9LOn0fVxmLgA7DDTNLqskm5IfQpuVd0qH/LgIJ9RdBHbWyoOAX/3TDAa y7GuLpsrhLZQGRhwxeDS4wNiHVOD+IyzpKiFNlW92KwE+KBPJwytqbDKnLQleJRdk6MK t7Kgc0F/N0O1v7/CW05wcnzdj5a0U8bLLXzUZNLjEPu7aEu9QSPMkYW81oJB1ehHfdjZ tUCMXLoS8KF20844ynkofUyeu1RggtG6oApHqRh2xB2B1J4vDA4XJYjnPf7/qJDaMA/n WyeetrXEEEYY3b4TdOhLRNRYzFjIVpJw8szcZlDSR5PJDSabZZX9Cq3kvLNvPXY9FVq1 Mw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xfjkvdfak-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 18:43:34 +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 43JIWLAO014746; Fri, 19 Apr 2024 18:43:33 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xkburg6ce-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 18:43:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QHjvehynD3gW5j/9mESYgkJeHuz60gdY9LQ4OS4ZM/dwC9ABdXR13K1SyPqLNC8/9eH6/RM4yp0f5pPCh7D2sxUXpnaqpt+EF8JRP1+0N2jwXA+QiA1JXtw3h5O5U/oRlrLUQWvSBXaadd+J+Czix4eYg+dnZerwMdsvMg+FYfD8hotwh1nDKd0V1zqpcld0GPGFF41I4xL1Dk7wYmGXDTZE7j2zNccSXb2lYPtQkpZus+4NfQrGsrHpAWybxgSkZ+Y8YiIchqGZ8xOeY+axV/5RQdKqzG0EDnmx7n9IVYLvNtMQLx997rubPPKdfZVY5I3UWUx+83YNio/MfresBA== 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=1nuANQJK5bxbFvcvIyWXaPisIFeWdntWnInJb1SVwLw=; b=Aa05LxfLYNZ5CPbHgMLbF3VsNI/lI+oGmiMXsPZtgzdLNLPTsifbd7C0o9Qb81UKA4ve5tej3MUMP6DgvodhE2zT6vffHGMif+Byq6gZEb9RJrpA+wybWR3NJArTXaOgYwcxj0ru7JLHW1RGSAmc5wFvOxjW9ReGF8GD2rn3VleX9+ZGOJhdN21AIWU1cCQXOA2Ich9C5n12ZihnRgEvXFzfu+lkOBXDRRPTXlqZLRnv9WUZ6ul2xc+qcPaXcTr+RJjuFHsjLV71OrnS7zqO8uKs07HidwJspZytipri6eNWx0L2ygyB+icNc6cc5xhAApVwQ1Q0RKveHy8hmHgwdQ== 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=1nuANQJK5bxbFvcvIyWXaPisIFeWdntWnInJb1SVwLw=; b=j+oxUGF7XUommsRQ5UtjJyCXCSmgkRJNIfvEAmaZpDWw7OD1hLuRXVy11ipy7yXjn1C4zcqorjEBzjUL8y5DlEThnIWlTAltsI6nPiNcPUNae4UjDY5pQ92loPv7uWUI71/mk+RozBog6LtqKUobIwGoms8CQ75dnfSgtrYbpcE= Received: from CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) by DM4PR10MB7425.namprd10.prod.outlook.com (2603:10b6:8:180::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.43; Fri, 19 Apr 2024 18:43:31 +0000 Received: from CY8PR10MB6538.namprd10.prod.outlook.com ([fe80::2dae:7852:9563:b4bc]) by CY8PR10MB6538.namprd10.prod.outlook.com ([fe80::2dae:7852:9563:b4bc%6]) with mapi id 15.20.7472.037; Fri, 19 Apr 2024 18:43:31 +0000 From: Qing Zhao To: josmyers@redhat.com, richard.guenther@gmail.com, uecker@tugraz.at Cc: siddhesh@gotplt.org, keescook@chromium.org, gcc-patches@gcc.gnu.org, Qing Zhao Subject: [RFC][PATCH v1 3/4] Add testing cases for flexible array members in unions and alone in structures. Date: Fri, 19 Apr 2024 18:43:16 +0000 Message-Id: <20240419184317.2138890-4-qing.zhao@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240419184317.2138890-1-qing.zhao@oracle.com> References: <20240419184317.2138890-1-qing.zhao@oracle.com> X-ClientProxiedBy: BL1PR13CA0299.namprd13.prod.outlook.com (2603:10b6:208:2bc::34) To CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB6538:EE_|DM4PR10MB7425:EE_ X-MS-Office365-Filtering-Correlation-Id: 23fea546-5fca-40f1-8935-08dc60a09c33 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OZD9tEyWYd2YT/Y51SA+W2GX94iR7KxsqbSooAYNFf3C75s0sBDNoWhlM3U7Xi684znUkdoTWNafOQ2+s7Fox1TAO8NMYjf7Vo2IePBEkfBCpZbPXEmQytwTPr9NapZqDfd/Jn40hvKRysLIQukiyJ+4NjSZGXakTZJ9WwA6Li3bksHMI3lDkvLww3Bc1HnKCL/bhV6bqGNfJheKUtGrZQruBrPGkyEGlHcN7FfKl4dv0FBodGPzyLkgV+5/fw2v9DQV+a8SVsI1Z1NyMG9T0ucflcno6VQ4phqYh9f1Is7UOn7zP97dzB9UKL25W4q4xTFCOebJ7ONT3tWmPXuRYHU3Xue1Gs6h5E2W7WIiKkRNwF03KeQ2O3M8cR7IvAAuhic5fBaJ4zev1kP1fj1yuXL8PcbYhj0Zv4sV7usuZT7f4kYhpeRITCAmmRGZLN/E39+SY9N0FCA0SYJ66APLbXP6x40J4bdcIHjA2H8ga/CSko6a0w1jcJ6b6/cBQGu79nZpAr9oPq8zPw922mL/2puszRyBbXH+tSJ//idhd6UZPB5u5CVB62MclQHk+lPD0cojaGlL0g/P6ZHravZShsE05dqJRZdwEbWYefxSHViHWYw9C61ZD/17WD9JY8ic X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY8PR10MB6538.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(1800799015)(376005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OxCagfaQBChnUOJfiyGT1ZckmfWrhgG/RTahEuugatYJjfPjGs6upoj8BbeEotxkEJeNdjW/bmCD4Roe2w4nLyi+kPl7kgAKinwA16HD2GF2SfM3dCGPmlXw3xI9bduQPGTMzk4UaHDyTDNLMdNx+Sl33PDEpR+OAO8Q5DXaJYbrs0JwFTFaZv+n8eEUzjvuWdYRF8DNV28VtnUiJOnLjhG7zr9XLMfn/ymU9XLxKXSGqqMp2KlVRRmiiT8cjd5aYEVJVFcPhKvZQNpNbe29Fz8RJQgvj0XSceOpf4NkHmnf3/15cAmO0RMEJLveStJ0qwyMyhp4RRUzIAjPJSj/2YzacygSn4nyb9NcJT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12pimhO22zSFCa4L+c+G3VCL9la6/GplAxztqFCyE+Hzop+vgUNmwDxPKFfwTkWuaLdFwP35gN4wzuxeKN5X5uhyNJOqreQa+S/GU57zYO86M1jGr8hFK9KaVKhvEaEG/tMlvAcT/8N3PO779GG4MRivN9MAgY2mx0VppWs X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 1lRlJg1DS+hKBQPs+IS7ZaG8auyr5n+JPk1Mka6jjJcr3SfeslKHOK/XKxlVsmXT9BEDkHhsskoaQ2CRYn66LkmxCSF/LXac+Xg0VRzcnEs9C1DHHPw1NlhlDETDF7xg6p9HXi914oati7jT3kE6xt2OMfidA5Gw2aoy2PmEMik3dbm7jMEg92Y4ljD5V9Dexelu38ooxW1wbMYEhYh3MHgc4nbdpfvayKkcJZRzgv0+BEA9Y8Ff1LUZIt10USL5gyqaCCW5zt3L7eEggPpq5e+vZLax0h/gVPIwCGhSOdwbITXQQR4H+T5ASAgaERhiE/TcPyvUxktleUv0C1hWs2wOB2GH4DsSzTzWO4Etvz/gsVmluVP4F9ed0G1Bbu6Ox1whlzw+8Ysd1Skv0NRjJrvn6ElU6A7aKc61+G30cWhn/mzzj9oMMBS5qxglME53f6LeGguKNAhB2CqWEqriS6q58wZY1WnGg8R4x3jPJKTusnIGa0Z/5quUwNCM7qV76EUAjPKj/BrPDgv2vMnAApxS7L7Ii0fJZzf0jLSydlntbb1S0bsOTPU96N18T+x3RVMq2SeKNrCY8gwVibwNsFb/VINt04wBg5dHwH58UQw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23fea546-5fca-40f1-8935-08dc60a09c33 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB6538.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 18:43:31.2590 (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: nPRdVaLvt+V31xb7bxe8/lRr6f33aLxxfZkWTMf8ryItHonyB7l93lCBkMRgxPGbgctclHD+3Up45U4B3EY+fQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB7425 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-19_13,2024-04-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=905 malwarescore=0 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404190144 X-Proofpoint-ORIG-GUID: 6_Y5eE4tFeXgZdD5eoML5xk23qgQZkGH X-Proofpoint-GUID: 6_Y5eE4tFeXgZdD5eoML5xk23qgQZkGH X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org gcc/testsuite/ChangeLog: * gcc.dg/flex-array-in-union-1.c: New test. * gcc.dg/flex-array-in-union-2.c: New test. --- gcc/testsuite/gcc.dg/flex-array-in-union-1.c | 37 +++++++++++++++++ gcc/testsuite/gcc.dg/flex-array-in-union-2.c | 42 ++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/flex-array-in-union-1.c create mode 100644 gcc/testsuite/gcc.dg/flex-array-in-union-2.c diff --git a/gcc/testsuite/gcc.dg/flex-array-in-union-1.c b/gcc/testsuite/gcc.dg/flex-array-in-union-1.c new file mode 100644 index 000000000000..2a532d77c1dd --- /dev/null +++ b/gcc/testsuite/gcc.dg/flex-array-in-union-1.c @@ -0,0 +1,37 @@ +/* testing the correct usage of flexible array members in unions + and alone in structure. */ +/* { dg-do run} */ +/* { dg-options "-O2 -Wpedantic" } */ + +union with_fam_1 { + int a; + int b[]; /* { dg-warning "flexible array member in union is a GCC extension" } */ +}; + +union with_fam_2 { + char a; + int b[]; /* { dg-warning "flexible array member in union is a GCC extension" } */ +}; + +union with_fam_3 { + char a[]; /* { dg-warning " flexible array member in union is a GCC extension" } */ + int b[]; /* { dg-warning "flexible array member in union is a GCC extension" } */ +}; + +struct only_fam { + int b[]; /* { dg-warning "flexible array member in a struct with no named members is a GCC extension" } */ +}; + +int main () +{ + if (sizeof (union with_fam_1) != sizeof (int)) + __builtin_abort (); + if (sizeof (union with_fam_2) != __alignof__ (int)) + __builtin_abort (); + if (sizeof (union with_fam_3) != 0) + __builtin_abort (); + if (sizeof (struct only_fam) != 0) + __builtin_abort (); + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/flex-array-in-union-2.c b/gcc/testsuite/gcc.dg/flex-array-in-union-2.c new file mode 100644 index 000000000000..130124bbe653 --- /dev/null +++ b/gcc/testsuite/gcc.dg/flex-array-in-union-2.c @@ -0,0 +1,42 @@ +/* testing the correct usage of flexible array members in unions + and alone in structure: initialization */ +/* { dg-do run} */ +/* { dg-options "-O2" } */ + +union with_fam_1 { + int a; + int b[]; +} with_fam_1_v = {.b = {1, 2, 3, 4}}; + +union with_fam_2 { + int a; + char b[]; +} with_fam_2_v = {.a = 0x1f2f3f4f}; + +union with_fam_3 { + char a[]; + int b[]; +} with_fam_3_v = {.b = {0x1f2f3f4f, 0x5f6f7f7f}}; + +struct only_fam { + int b[]; +} only_fam_v = {{7, 11}}; + +int main () +{ + if (with_fam_1_v.b[3] != 4 + || with_fam_1_v.b[0] != 1) + __builtin_abort (); + if (with_fam_2_v.b[3] != 0x1f + || with_fam_2_v.b[0] != 0x4f) + __builtin_abort (); + if (with_fam_3_v.a[0] != 0x4f + || with_fam_3_v.a[7] != 0x5f) + __builtin_abort (); + if (only_fam_v.b[0] != 7 + || only_fam_v.b[1] != 11) + __builtin_abort (); + + return 0; +} + From patchwork Fri Apr 19 18:43:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qing Zhao X-Patchwork-Id: 88760 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D3A6338460BD for ; Fri, 19 Apr 2024 18:45:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id B8F44384645B for ; Fri, 19 Apr 2024 18:43:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B8F44384645B Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 B8F44384645B Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713552222; cv=pass; b=Wk+xu8Kt+xJrcjPSaCDEG8+nfPbsQa6DnPMfIYjAJd2zCZ8AvWlCVGdQ8L5ObOzHh+9hyC0URleIGHJT+GGHjBH8bhjCIYmuJBSTNIdj3c/hVyDPT8DhrWtoA5x/1kYKvvOxNXcQmtvAfG8Wr6SS+jfSf6jMYkJwGu1+RMmNgA4= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713552222; c=relaxed/simple; bh=BIwh20M9N0PmjwEZe+JhtGdl3Qr31OT9zTidbhHWKbM=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=i6tZQ311Ieb5bT3g4n3PF8mVZcAww5z0qfsNkowYOAK2HtVxKPcn3dITa4CN2g0IKNB4K1LgYiLtrsu7yWamoQ4rdSTmgyD0orxEYXUIl+HP2CcPT6/HPTz7TPfbGdQ7EOxADhduyNq6+artjNyY8IEvxhA1SPwTDElyXRqU7cI= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43JINttB021516; Fri, 19 Apr 2024 18:43:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=GAItpMYjlWt8eFBuTrg22cbArmRBq0Wp4lt4SrOnCQ0=; b=ZtUFZage+Wa7OL5THYMBWwOxeBWsUYTK/1dL9DmrJQZI4IqIwGWZpqqjx3YMOfZ2Ubhe egl9wiuytPaaRA/O3FaDhF2od0ABMolgGQ3jP+8Y4pHRIpqgD2m3TF1OGeA7dhsXoq50 McThDRPFlwwC0FIghfRU/U6PbDfBsBEluyShTu0LVyn61+AMTgc2z1yS9WT5pNzlDZnh 9yIAjFtP+kNE6kj7wntqWq/JjKxNgrAmL+87fhCk00zZVUKn/u7cxm5F7iWfBIPkaLq1 TcQboqB5OE1BwbiscbDttO+iO9uEOuSqoNkOGD/6MuGFNmusaSjiA3GzBdWnZamNlN3X bg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xfhnunjsr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 18:43:37 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 43JIPvHx014370; Fri, 19 Apr 2024 18:43:36 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xkc97xs1h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 18:43:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dUhBooYtNvjfm/nvIaEmaNEsdYZQUHUjg6JiUYVfbhzusnMWcIQvWSas5KHLcfHA1+5yaVz94sqd27sZZHeEwJHM4fxpPYBVXyE+Sn/hVtlVgYRHtFh8VldyZhdIOuPAgUD67WpxeVOTmNxBozggfJ51K0k3ZJV/9Stzs6YcVegLo2dEqSaKVB12zTV7nkI4FIed0+qvGtD7Bc4MhVooO4gdsgBSwcOAXAv4PGRjW9jSBEIcQZieAOYxpkYYKagEjtZa8ZAS9Zee8cJyQlN/poXlChA6di81zFGetTfZjrftWMnK8dPNFv22II4i5BsexdmrnIs7BU711KLC7MYqFw== 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=GAItpMYjlWt8eFBuTrg22cbArmRBq0Wp4lt4SrOnCQ0=; b=R0aclLaRN87cnB4ojpgHsdX/T5VwsZeNVUzIl5FRXOhX5leu4RUF4FSAScrjAOozI08Y1l/8WendvehTvrQspdwQxifdzP+CqkkM1/o1PFxJsLz8qqWTwhYVdnrP+Qx2GoQbk5vhjRsgMF6y2YjyuP93OQoPCUFa/CfMDhaV5IZz2ATSZCfnnX2uPl8qp9Y/Q8R6aXZQaTSxD14AZx+BczAKAF5iVQ+TBG4AApVN5rRmWtwSdn9hw1/PgEL1CH5JS1bH77PmWrxoMybSueGrgiaD9ZOyC5kTtMEx0plCMkA6qCOdmW2UJizaiNghYqcguXL53slZaIJTRrAofn/k+g== 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=GAItpMYjlWt8eFBuTrg22cbArmRBq0Wp4lt4SrOnCQ0=; b=ZfwkaYEE2QV/nxF6AQFpAzl7FF/83QOtOKacmXWhSxYxT+8mARdn3c6riSnORrYQrFsspZhnT1jPOuOsUh/TxK8E8HIcIpLd1/jFuY7oC0zIo+ehcSwFF4fUfMWpuVe95U89CjzVjwQRnDN2I3XgSRKFlhw0AMtQluDm6QHSsEM= Received: from CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) by DM4PR10MB7425.namprd10.prod.outlook.com (2603:10b6:8:180::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.43; Fri, 19 Apr 2024 18:43:34 +0000 Received: from CY8PR10MB6538.namprd10.prod.outlook.com ([fe80::2dae:7852:9563:b4bc]) by CY8PR10MB6538.namprd10.prod.outlook.com ([fe80::2dae:7852:9563:b4bc%6]) with mapi id 15.20.7472.037; Fri, 19 Apr 2024 18:43:34 +0000 From: Qing Zhao To: josmyers@redhat.com, richard.guenther@gmail.com, uecker@tugraz.at Cc: siddhesh@gotplt.org, keescook@chromium.org, gcc-patches@gcc.gnu.org, Qing Zhao Subject: [RFC][PATCH v1 4/4] Adjust testcases for flexible array member in union and alone in structure extension. Date: Fri, 19 Apr 2024 18:43:17 +0000 Message-Id: <20240419184317.2138890-5-qing.zhao@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240419184317.2138890-1-qing.zhao@oracle.com> References: <20240419184317.2138890-1-qing.zhao@oracle.com> X-ClientProxiedBy: MN2PR07CA0025.namprd07.prod.outlook.com (2603:10b6:208:1a0::35) To CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB6538:EE_|DM4PR10MB7425:EE_ X-MS-Office365-Filtering-Correlation-Id: 29945983-9d18-4a4f-8608-08dc60a09ddc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sEMec1KVA+OIIFr3/uECBzeGXfG9vi69gnSXez+KGW+Q0h78T6KH/waWq3cchUHHYjTE2ug5EOzuprh8vwRf5ggA65a6jdi9kIw9TYKiISBxAUTS7RsIk0G/RFoNW8G7cNwsEph6dz9s/jiinmo3ObvcyDy8LGM+ViQrQndEqB2RyDv63ZQZKwnxnvmvRXq+IBBLZucb/k3C6H3KKBZyDnjvmnukunh8083L0wpgsRon4jmzfUpXBEjKpxebdBVMb7mS1o6z4krqdY2gKTYT0rTTbz6xNRyyAgE3QwgjVUIqQwUhn72zZ2q2ffw16RT24ECMPC8DBOROarhJNQck8ohnSgZDbp561aeuM3SkC9qKIfyZD+rc3FRgVn6xXSa7y6KRBPf2Z/H90k1MJq1BfVB5sfMJeAU58QDf1mdVppmyTmIi4R2qVklT8YrKn70Pdvk9GbEatOEmjSwgmWlkSyIqxZKgT029FHXQyR8II6+sHTZZnplA0NlIe4LatqfJc/buDOquOlY3/NQ4QDnKvcYuYUYCyPyab1jtLOZ269TgC9jRRYrjQ7qvB7fgqV3EcvBgGzOquBW136CakVW1jQ7/3dGessmOBGhmcgwWMx/B4xvVv2RrLWOvJqNMwenJ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY8PR10MB6538.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(1800799015)(376005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DasZT7lBOLEMh9Y5Tu6VUDOlCzvKsZJ+MN1u5nCt2QC4JrLYCZ+/x3jV6IZRrbZw/oBW1taJGE4RiDxYJw1IAVOVPHJg/EllD0fYtLwv7yVsjohWGl/xJPGUdtI5a7ASFZeP8ALpCR9d41YbZU/b4fcyECi8szJL3qgI9F4mDf7BQH5vZMlFCxInj0iNWMT/lbBDa2WPyn0WeG9s15CFKFKlfrQYHeG/i/sjWQZ8O0XRYUnOhgIK9kc4wqU3mznjzv3NowV/PbWcGGAFpilRarENN035b8K1p0r39RgRi0fxIufGgopRY6suEv6pmPuOiLnPXR1pE+/90AAnZWuC05JLFuMxBJH3yIp8dbhQSQ3EhDvRDgf2mOTL2IIPcswrsZ66Aa8z+vWUch2m2zHk7G2urL2kw4cKoLvVk/fj4JgW5m6TQbmXIDpJNjfm8+EJWTCKNWXsNJzWRyVEIWo89ayXUIgtmj8tqxb9zzsvlKa5nGPjo3LB3n9LUwADu0SDawFQeE0t5dOHg3K8aKPnsIN9bZuHAF3xyBZy8ywdKslSI7ngToIutKU3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-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 0L6y2gYIjJXnpJuXf28em7AoMEriWm/VHIjnRGUNOLDDaXtSJb3FRCASdZm+i79Tk1X1N+vkvh3vbDY1a0ZW/ZT72EC5CmMtm3qGyWSLomcbquu6yzFWV/48enMkvkvBykSfYDSl2e2oekM6efgX8cOV+UUZZc+YcNLklqHD+cDqMELqGU2ZUE32S5UFw0biszIlr2FUhAUWYpTfCUr0dF3AX9Jv5BLqUbglcbKsfJBLsbNHa9pJ65k5nVMMR1km3ht9mkogdyHGP5E6OVub7lrpJbJqBQjutuUNDrhhY3pDD+2G2fBOW/GIJwybI+DZ21by6gBPXvIiht2ouAnrsKJUN6Q0tWr67YkAepXtc8UcTwFphYQ1hstXC0L2gu76uKnpVOVH9TS+KqJN5+7qRbFd6zH3W132NF9QDg2kXSBfp8K77ZP461aU9wP8blMA7BAqbJkDy2HJzeT1WrlgcZiMunQxLRpQk7T/1pcQupdtiAgDOIe6NOto/EttEPwt4vBi6SvdYoBA0RoHpMhB3VazAYO/iOn4Q43gdYnlYeDYfczsSf+isqDKxa7/VpOuO6l8KLfp9c1POMpz69v+rLyPrIqQANWeA4B9dFceJ3w= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29945983-9d18-4a4f-8608-08dc60a09ddc X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB6538.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 18:43:34.0030 (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: c3764Lp7pps/y3eZODYKFd6/J9uuBdVakWyd1AcE798tWQKwng392LFzlBrkaDlQdCw5WxCRAgfdwqQNDURgpQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB7425 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-19_13,2024-04-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404190144 X-Proofpoint-GUID: 0tatvRs4jZXYYbuyG8czCPZxzTd0_SEx X-Proofpoint-ORIG-GUID: 0tatvRs4jZXYYbuyG8czCPZxzTd0_SEx X-Spam-Status: No, score=-11.6 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_H4, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org gcc/testsuite/ChangeLog: * c-c++-common/builtin-clear-padding-3.c: Adjust testcase. * g++.dg/ext/flexary12.C: Likewise. * g++.dg/ext/flexary19.C: Likewise. * g++.dg/ext/flexary2.C: Likewise. * g++.dg/ext/flexary3.C: Likewise. * g++.dg/ext/flexary36.C: Likewise. * g++.dg/ext/flexary4.C: Likewise. * g++.dg/ext/flexary5.C: Likewise. * g++.dg/ext/flexary8.C: Likewise. * g++.dg/torture/pr64280.C: Likewise. * gcc.dg/20050620-1.c: Likewise. * gcc.dg/940510-1.c: Likewise. --- .../c-c++-common/builtin-clear-padding-3.c | 10 ++-- gcc/testsuite/g++.dg/ext/flexary12.C | 6 +-- gcc/testsuite/g++.dg/ext/flexary19.C | 42 +++++++-------- gcc/testsuite/g++.dg/ext/flexary2.C | 2 +- gcc/testsuite/g++.dg/ext/flexary3.C | 2 +- gcc/testsuite/g++.dg/ext/flexary36.C | 2 +- gcc/testsuite/g++.dg/ext/flexary4.C | 54 +++++++++---------- gcc/testsuite/g++.dg/ext/flexary5.C | 4 +- gcc/testsuite/g++.dg/ext/flexary8.C | 8 +-- gcc/testsuite/g++.dg/torture/pr64280.C | 2 +- gcc/testsuite/gcc.dg/20050620-1.c | 2 +- gcc/testsuite/gcc.dg/940510-1.c | 4 +- 12 files changed, 68 insertions(+), 70 deletions(-) diff --git a/gcc/testsuite/c-c++-common/builtin-clear-padding-3.c b/gcc/testsuite/c-c++-common/builtin-clear-padding-3.c index d16cc6aad05f..a4f49f26db14 100644 --- a/gcc/testsuite/c-c++-common/builtin-clear-padding-3.c +++ b/gcc/testsuite/c-c++-common/builtin-clear-padding-3.c @@ -2,14 +2,12 @@ /* { dg-do compile } */ /* { dg-options "" } */ -union U { int a; char b[] __attribute__((aligned (2 * sizeof (int)))); }; /* { dg-error "flexible array member in union" } */ +union U { int a; char b[] __attribute__((aligned (2 * sizeof (int)))); }; struct V { int a; union U b; }; -struct W { int a; union U b; int c; }; void -foo (union U *u, struct V *v, struct W *w) +foo (union U *u, struct V *v) { - __builtin_clear_padding (u); - __builtin_clear_padding (v); - __builtin_clear_padding (w); + __builtin_clear_padding (u); /* { dg-error "flexible array member" "does not have well defined padding bits" } */ + __builtin_clear_padding (v); /* { dg-error "flexible array member" "does not have well defined padding bits" } */ } diff --git a/gcc/testsuite/g++.dg/ext/flexary12.C b/gcc/testsuite/g++.dg/ext/flexary12.C index b0964948731d..6ba4b6417135 100644 --- a/gcc/testsuite/g++.dg/ext/flexary12.C +++ b/gcc/testsuite/g++.dg/ext/flexary12.C @@ -6,7 +6,7 @@ // { dg-options "-Wno-pedantic" } struct A { - int a []; // { dg-error "flexible array member .A::a. in an otherwise empty .struct A." } + int a []; }; void f1 () @@ -40,7 +40,7 @@ void f2 () } struct D { - int a []; // { dg-error "flexible array member .D::a. in an otherwise empty .struct D." } + int a []; D (); }; @@ -52,7 +52,7 @@ D::D (): // { dg-error "initializer for flexible array member" } template struct C { - T a []; // { dg-error "flexible array member" } + T a []; }; void f3 () diff --git a/gcc/testsuite/g++.dg/ext/flexary19.C b/gcc/testsuite/g++.dg/ext/flexary19.C index abfbc43028af..9a06f9ca758f 100644 --- a/gcc/testsuite/g++.dg/ext/flexary19.C +++ b/gcc/testsuite/g++.dg/ext/flexary19.C @@ -12,7 +12,7 @@ struct S1 // The following declares a named data member of an unnamed struct // (i.e., it is not an anonymous struct). struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } s; }; @@ -21,7 +21,7 @@ struct S2 int i; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } s[1]; }; @@ -30,7 +30,7 @@ struct S3 int i; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } s[]; }; @@ -39,7 +39,7 @@ struct S4 int i; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } s[2]; }; @@ -48,7 +48,7 @@ struct S5 int i; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } s[1][2]; }; @@ -57,7 +57,7 @@ struct S6 int i; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } s[][2]; }; @@ -66,7 +66,7 @@ struct S7 int i; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } *s; }; @@ -75,7 +75,7 @@ struct S8 int i; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } **s; }; @@ -84,7 +84,7 @@ struct S9 int i; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } *s[1]; }; @@ -93,7 +93,7 @@ struct S10 int i; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } *s[]; }; @@ -102,7 +102,7 @@ struct S11 int i; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } **s[1]; }; @@ -111,7 +111,7 @@ struct S12 int i; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } **s[]; }; @@ -120,7 +120,7 @@ struct S13 int i; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } **s[2]; }; @@ -129,7 +129,7 @@ struct S14 int i; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } &s; }; @@ -138,7 +138,7 @@ struct S15 int i; typedef struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } T15; }; @@ -159,8 +159,8 @@ struct S17 { int i; - union { // anonymous union - int a[]; // { dg-error "flexible array member in union" } + union { // { dg-warning "invalid use" } + int a[]; // { dg-warning "flexible array member in union" } }; }; @@ -209,7 +209,7 @@ struct S22 struct S22S { static int i; - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } s; }; @@ -218,7 +218,7 @@ struct S23 struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" } static int i; // { dg-error "static data member" } - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } }; }; @@ -227,7 +227,7 @@ struct S24 static int i; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } s; }; @@ -252,7 +252,7 @@ struct S26 }; struct { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; // { dg-warning "in an otherwise empty" } } s; }; diff --git a/gcc/testsuite/g++.dg/ext/flexary2.C b/gcc/testsuite/g++.dg/ext/flexary2.C index c0253777a1e9..7095a3b0fb2d 100644 --- a/gcc/testsuite/g++.dg/ext/flexary2.C +++ b/gcc/testsuite/g++.dg/ext/flexary2.C @@ -13,7 +13,7 @@ struct A { struct B { B() {} - A a[]; // { dg-error "extension|flexible array .* in an otherwise empty" } + A a[]; }; struct C { diff --git a/gcc/testsuite/g++.dg/ext/flexary3.C b/gcc/testsuite/g++.dg/ext/flexary3.C index 8344b42dd163..7785c9b190a4 100644 --- a/gcc/testsuite/g++.dg/ext/flexary3.C +++ b/gcc/testsuite/g++.dg/ext/flexary3.C @@ -11,7 +11,7 @@ // { dg-options "" } struct s { - char c[]; // { dg-error "flexible array member .* in an otherwise empty" } + char c[]; }; int main() diff --git a/gcc/testsuite/g++.dg/ext/flexary36.C b/gcc/testsuite/g++.dg/ext/flexary36.C index 5bb827cfd0e0..87d6fb092100 100644 --- a/gcc/testsuite/g++.dg/ext/flexary36.C +++ b/gcc/testsuite/g++.dg/ext/flexary36.C @@ -25,7 +25,7 @@ struct { union { - int a[]; // { dg-error "flexible array member in union" } + int a[]; int b; } du = { 1 }; diff --git a/gcc/testsuite/g++.dg/ext/flexary4.C b/gcc/testsuite/g++.dg/ext/flexary4.C index bd28cf55de2b..a87b7e71edb6 100644 --- a/gcc/testsuite/g++.dg/ext/flexary4.C +++ b/gcc/testsuite/g++.dg/ext/flexary4.C @@ -11,79 +11,79 @@ #include "flexary.h" struct Sx { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; }; // Verify that non-data members or static data members either before // or after a flexible array member in an otherwise empty struct don't // suppress the diagnostic. struct Sx2 { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; typedef int I; }; struct Sx3 { typedef int I; - int a[]; // { dg-error "in an otherwise empty" } + int a[]; }; struct Sx4 { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; enum E { e }; }; struct Sx5 { enum E { e }; - int a[]; // { dg-error "in an otherwise empty" } + int a[]; }; struct Sx6 { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; static int i; }; struct Sx7 { static int i; - int a[]; // { dg-error "in an otherwise empty" } + int a[]; }; struct Sx8 { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; Sx8 () { } }; struct Sx9 { Sx9 () { } - int a[]; // { dg-error "in an otherwise empty" } + int a[]; }; struct Sx10 { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; virtual ~Sx10 () { } }; struct Sx11 { virtual ~Sx11 () { } - int a[]; // { dg-error "in an otherwise empty" } + int a[]; }; struct Sx12 { - int a[]; // { dg-error "in an otherwise empty" } + int a[]; virtual void foo () = 0; }; struct Sx13 { virtual void foo () = 0; - int a[]; // { dg-error "in an otherwise empty" } + int a[]; }; struct Sx14 { - int a[][1]; // { dg-error "in an otherwise empty" } + int a[][1]; }; struct Sx15 { typedef int A[]; - A a; // { dg-error "in an otherwise empty" } + A a; }; // Verify also that a zero-size array doesn't suppress the diagnostic. @@ -91,7 +91,7 @@ struct Sx16 { // a_0 below is diagnosed with -Wpedantic only and emits // warning: ISO C++ forbids zero-size arrays int a_0 [0]; - int a_x []; // { dg-error "in an otherwise empty" } + int a_x []; }; struct Sx17 { @@ -123,7 +123,7 @@ struct Sx19 { // so doesn't contribute its member to that of the enclosing struct. struct Sx20 { struct S { int i; }; - int a_x []; // { dg-error "in an otherwise empty" } + int a_x []; }; struct Sx21 { @@ -148,12 +148,12 @@ struct Sx24 { struct Sx25 { struct S { }; - S a_x []; // { dg-error "flexible array member" } + S a_x []; }; struct Sx26 { struct { } - a_x []; // { dg-error "flexible array member" } + a_x []; }; struct Sx27 { @@ -193,13 +193,13 @@ struct Sx32 { ASSERT_AT_END (Sx32, a); struct Sx33 { - int a []; // { dg-error "otherwise empty" } + int a []; friend int foo (); }; struct Sx34 { friend int foo (); - int a []; // { dg-error "otherwise empty" } + int a []; }; // Verify that intervening non-field declarations of members other @@ -277,7 +277,7 @@ ASSERT_AT_END (Sx44, a); struct S_S_S_x { struct A { struct B { - int a[]; // { dg-error "flexible array member" } + int a[]; } b; } a; }; @@ -300,7 +300,7 @@ struct NotAnon1 { // The following is not an anonymous struct -- the type is unnamed // but the object has a name. struct { - int bad[]; // { dg-error "otherwise empty" } + int bad[]; } name; }; @@ -328,7 +328,7 @@ ASSERT_AT_END (Anon3, good); struct Anon4 { struct { - int in_empty_struct[]; // { dg-error "in an otherwise empty" } + int in_empty_struct[]; }; }; @@ -366,7 +366,7 @@ struct Six { ASSERT_AT_END (Six, a); class Cx { - int a[]; // { dg-error "flexible array member" } + int a[]; }; class Cix { @@ -390,7 +390,7 @@ struct S0i { struct S_a0_ax { int a0[0]; - int ax[]; // { dg-error "flexible array member" } + int ax[]; }; struct S_a0_i_ax { @@ -417,7 +417,7 @@ struct Si_ax_a0 { struct S_u0_ax { union { } u[0]; - int ax[]; // { dg-error "flexible array member" } + int ax[]; }; struct S_a1_s2 { diff --git a/gcc/testsuite/g++.dg/ext/flexary5.C b/gcc/testsuite/g++.dg/ext/flexary5.C index d5ec13204966..3fb88c0e8a2c 100644 --- a/gcc/testsuite/g++.dg/ext/flexary5.C +++ b/gcc/testsuite/g++.dg/ext/flexary5.C @@ -13,7 +13,7 @@ struct S_no_diag: T { template struct STx_1: T { - char a[]; // { dg-error "flexible array member" } + char a[]; }; template @@ -37,7 +37,7 @@ struct E1: E<0>, E<1> { }; struct E2: E<2>, E<3> { }; struct D1: E1, E2 { - char a[]; // { dg-error "flexible array member" } + char a[]; }; struct NE { size_t i; }; diff --git a/gcc/testsuite/g++.dg/ext/flexary8.C b/gcc/testsuite/g++.dg/ext/flexary8.C index 7a1811deaff2..a0477f0fa410 100644 --- a/gcc/testsuite/g++.dg/ext/flexary8.C +++ b/gcc/testsuite/g++.dg/ext/flexary8.C @@ -4,26 +4,26 @@ union U_i_ax { int i; - int a[]; // { dg-error "flexible array member in union" } + int a[]; }; struct SU1 { union { - int a[]; // { dg-error "flexible array member in union" } + int a[]; }; }; struct SU2 { int n; union { - int a[]; // { dg-error "flexible array member in union" } + int a[]; }; }; struct SU3 { union { int n; - int a[]; // { dg-error "flexible array member in union" } + int a[]; }; }; diff --git a/gcc/testsuite/g++.dg/torture/pr64280.C b/gcc/testsuite/g++.dg/torture/pr64280.C index 5c569e864b4c..1ea70c4e766e 100644 --- a/gcc/testsuite/g++.dg/torture/pr64280.C +++ b/gcc/testsuite/g++.dg/torture/pr64280.C @@ -15,7 +15,7 @@ public: typedef int jmp_buf[]; struct C { - jmp_buf cond_; // { dg-error "flexible array member" } + jmp_buf cond_; }; class F { diff --git a/gcc/testsuite/gcc.dg/20050620-1.c b/gcc/testsuite/gcc.dg/20050620-1.c index befdd9636500..0a9e1d478454 100644 --- a/gcc/testsuite/gcc.dg/20050620-1.c +++ b/gcc/testsuite/gcc.dg/20050620-1.c @@ -5,7 +5,7 @@ void foo (void) { - struct { int i[]; } u; /* { dg-error "flexible array member" } */ + struct { int i[]; } u; } void diff --git a/gcc/testsuite/gcc.dg/940510-1.c b/gcc/testsuite/gcc.dg/940510-1.c index 46183831d096..9bcd7881f715 100644 --- a/gcc/testsuite/gcc.dg/940510-1.c +++ b/gcc/testsuite/gcc.dg/940510-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ /* { dg-options "-std=c89 -pedantic" } */ struct { int a[]; } x = { 0 }; /* { dg-warning "ISO C90 does not support flexible array members" } */ -/* { dg-error "flexible array member in a struct with no named members" "" { target *-*-* } .-1 } */ - +/* { dg-warning "flexible array member in a struct with no named members is a GCC extension" "" { target *-*-* } .-1 } */ +/* { dg-warning "initialization of a flexible array member" "" { target *-*-* } .-2 } */