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 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> Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: =?us-ascii?Q?OxCagfaQBChnUOJfiyGT1ZckmfWrhgG/RTahEuugatYJjfPjGs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swZMk6v9ZqN25iv4/3zwD94nG3DhieYAHCAV32Mlh5yaPKwiw8bVXkh?= =?us-ascii?Q?7xgTnLEA8Wf7iChhujUjVHWRsW+SuoTvQOG5yP+0tzKqviTtx+KZEkVj2a4p?= =?us-ascii?Q?cGfRo87Ccj6dkJYT8pyIGjcBSs19jzj3ajXHcBrdtqak7+jqbAoRgYpQezVa?= =?us-ascii?Q?iM21oxyyhD9tQ3fb02s8ELj0xtgEqwK+oeFRBkkeeC1qL7gejcbJsP7uwwax?= =?us-ascii?Q?9+ZOzfoMB+dltZ44Yj5aY9k3c2+3hGj78qi61f9ir5259ov0+MUfILM71VtL?= =?us-ascii?Q?Pzfr3eiueGwlPyfMDW9KrzfKxhXacXHvxQM60HhgBKg+IkJM175GvsxttWq7?= =?us-ascii?Q?JNHGJNf00hTl3Aw4pLB833eHHg75IroMgyIrggF6VxeAsLynwe22mSmyBf5+?= =?us-ascii?Q?kPPnhhdeNDRxfnvTfLyoyCKgn15xut6wokWFu3XPAbmh4Hry/Lo8p2zno+zb?= =?us-ascii?Q?w7Ut2XjYNw/hxOH2SqISXp5Pvr8RShLMhimx/XPUJeMH0wqQONwJh12pimhO?= =?us-ascii?Q?22zSFCa4L+c+G3VCL9la6/GplAxztqFCyE+Hzop+vgUNmwDxPKFfwTkWuaLd?= =?us-ascii?Q?FwP35gN4wzuxeKN5X5uhyNJOqreQa+S/GU57zYO86M1jGr8hFK9KaVKhvEaE?= =?us-ascii?Q?G/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 List-Id: 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; +} + -- 2.31.1