From patchwork Tue Apr 30 14:58:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qing Zhao X-Patchwork-Id: 1929650 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2023-11-20 header.b=OjTlN+ct; dkim=pass (1024-bit key; unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=qGIOjfap; dkim-atps=neutral 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=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VTNdX0Tjnz20fY for ; Wed, 1 May 2024 00:59:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 20C323858401 for ; Tue, 30 Apr 2024 14:59: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 696553858D35 for ; Tue, 30 Apr 2024 14:58:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 696553858D35 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 696553858D35 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=1714489133; cv=pass; b=EkKRiUaZ21vYDftetJ10gySg8bR9fRi5XaKU18PjbvtQIlS3H6fpa4ovV7zvnlgHYwMsCbqgzert2uw7TtCGlwzyXm1kTjhZxBT2qs3HQK5KmVM8IZZf+n5T4Gcpc3agaj+EJl5ZObWPLoPy/feYHzq8cweVN5sCsp7kwytx32Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1714489133; c=relaxed/simple; bh=3n0wAyTGloE80TgxiCRQuCUuS6BtO+OZ24FVOGjSbDU=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=Ueu4cQW3v6gJ1h84gN6IMxnA1em3JqMvUlihaU9Mi2m2ez1nk+3wAtk6b06ujFrO4S7TAdf48vXVD6rHaw0VA2cZWaYC3E7udF8As4mYAbaCAHt0fAZQq9w0urNIlUggDAUve8ICKWmCmMb8bKfJyFEer2b1V/dRGI7I2jrWO4I= 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 43UCXV0k011899; Tue, 30 Apr 2024 14:58:49 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=WrbDp6hZ5loKo2HutobE8RtDbCKPwtrDDXEQCCnzNx8=; b=OjTlN+ctQDwA98j7gR29UtDFb0sE8q+Zz/Iqdx5Xnijbd58CLErUJz0HTwj6w7rDvfZo jcExknP+Q61cSaVr4mY2ZLCCBBR+SWRxiTLEIqhNSGVsBzpG0KA7P2M+UbuLZgTFQIF/ 6yJnqcaiSox0LD/IggQAy6ZXR9cJnET6ktE9Im9z2LGQVC/1ZEo8lhtk5UY/O6pNNteh gt0oemMEmEegLiN8mawnin41WwgfEjZO9HV2xy0D6KK7/rQ8XwyM53MUnSn7v2mS8Anm IHE5P1lmMS+R1DQ20aItyGIwE0OiX79HynWChZTDI8WWOQxAlgvwTeJ4HKpWTwotC3qW cw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrswvnayc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Apr 2024 14:58:49 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 43UEHR5G008601; Tue, 30 Apr 2024 14:58:48 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xrqt81pwt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Apr 2024 14:58:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nhHgcVTbbIh6fYAf9wYFITIIMO99vS39ILPedKHSfVG+zu5JmuK1s0D4z+6XkdhE1HsmesGg8h3ZNvUNSYmkdR1gru+TUk4T55kw2izL7cGhFm6PO+733IT0mZFy93kg186m1hFmFXjXLaFAG4NQTsVRjR+Ex3dlz1Kp2rIBt92wf6Ib3ErVf9M0hNt/A0nBrM99fKZ1JmMzcwhV5Izywzbsifi+N6LXXOncFSpLEL9aQxNl89NEUYlPW3HLmsEnrtbPFtbiUJEHf+PaGREoinWGqxV/fuGDGDT9v2Twrrm6MB/Ju7diIizpiTOQnEFGWdBwbm9XkWCdtEnxxWcj9Q== 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=WrbDp6hZ5loKo2HutobE8RtDbCKPwtrDDXEQCCnzNx8=; b=mEgF5lMER3/s/N0joCQv1Am0UlEl58F3ImtuSKcr6pacYxy0sADcyBTb2OHhM3+jP7do9RVwZLsOe/Htitm1afL1Dv4oEoJSTiuD6ssUEAmpyZ7jmdmbGMVWjd7bVoQ7vIpuKEmET2uYPO124DyCdNpTn3f7xjoQm0nlq9kuQdaU6DnvF0ltrl6NcY9rY89foz61r6fmmJyr3xbDMnBuAWAW7Rmp9vdced8ijuefbfnsDpYf8iePuDJl3OKY50SUiila86F7luc5V4LJNLR1YPV3YgGOxKItzyh6K6v9qQ1s/tHDGkbnZ+eL3w8tM86gfMAHbfalxCT3rzM58kypmA== 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=WrbDp6hZ5loKo2HutobE8RtDbCKPwtrDDXEQCCnzNx8=; b=qGIOjfap+PNfm1mh+mJk7eyztS7mVn+ZN+YQojfSmPykbn6SxN7FZi7m4CMeZuQFufeOjqB/3L3OsrdPuvKXGR8o/kRiolEa08LShon89KHvnjGcEO5f2oNUEp0KuNZ4fEAqHzdmW0wK1Fj27H0bhAIOQw7s7fQ1MlcC9PcAsdE= Received: from CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) by SA1PR10MB6493.namprd10.prod.outlook.com (2603:10b6:806:29c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.35; Tue, 30 Apr 2024 14:58:46 +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.7519.035; Tue, 30 Apr 2024 14:58:46 +0000 From: Qing Zhao To: jason@redhat.com, josmyers@redhat.com, richard.guenther@gmail.com, siddhesh@gotplt.org Cc: uecker@tugraz.at, keescook@chromium.org, gcc-patches@gcc.gnu.org, Qing Zhao Subject: [PATCH v3 3/4] Add testing cases for flexible array members in unions and alone in structures. Date: Tue, 30 Apr 2024 14:58:32 +0000 Message-Id: <20240430145833.1366425-4-qing.zhao@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240430145833.1366425-1-qing.zhao@oracle.com> References: <20240430145833.1366425-1-qing.zhao@oracle.com> X-ClientProxiedBy: BYAPR07CA0015.namprd07.prod.outlook.com (2603:10b6:a02:bc::28) To CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB6538:EE_|SA1PR10MB6493:EE_ X-MS-Office365-Filtering-Correlation-Id: f7b5fdd6-03d7-4cf9-c88f-08dc69260908 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: YRvSEy7UqAZozoKz9A/MYqYuRdk9xcZhiUiW3UVsSmaIWspq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EjF5fItcfuh0SL3lr+jVD9y2Xs9YB5f1+hX+PsyZ+vI8YGiJOa2oh4kTavmoREgv55hJ/Mcq55YLxUW/eE7ty4TVOijy4yriqvXtvdD4Y0mpD+aciNx+iBycpTT89fd7U4gVRPSjEtxLkx5BnZZssfhBWN6CAri2hmfNozYQ== 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)(1800799015)(376005)(366007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AVK3AvCGtVrFW9Vp1iuSer4pFdXE1p7FEVOU087e7zNjP3vnzqrVS8hwGOO9Kj8RJ6XF/1+CoAQiOLH4qBbUKpAbA6M3IRCYrSEyKpiw44MEeDj5uhYRdlQyB0GRYjkoJw92B87tM6le9xWFQ/lwchHEGLKmNXY4yNvQkC2vkEyzZ3VAHK2zKiu/WwlpWyTTbkIPDmxjPC6hRqeEbHQVVQ5bvCuPL+AqfkHXxMUO4TAijmvOWCzXdamURDqTYhuc77ois7KtaVIpYOWkhL5L+hJD8xqXMXGVm0UNaqbbo/P/S1qnOBzcKG9xOzEJZZBx+lpTx2u5ZU8tVn0TpokMCLsPh6coFApBUBPMCZzvsXuQzoti3VJOYMuxJJrtYXE3Qv0nIh0ECovxbxU7FGc6T9HxMJu4OyvcEh+cYw8rk8WwWg5KhVZxXpMfUKxox3K4yUgW9jw1ULhdqOTEz1AkAqDKtfsXggR3QLBW+FL9sWmG0meYzB5XYoTPIiE+Sy+ILwKxn8cIhpKD2IJZu3XiTp4wocy2qgBtNNdxN6xSYaAIJGyXgf4BOpBQcdqVLJ8T1nbKfZKBC8WUs4AM15OISL2wz6uQhW21rWG+TDaPS+TFkwKgO5nUxKuPQTc+JDs714hqyAKe/1QPtXohGsmqRjSfja1pkSUZm8mfn6srK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MYPWN6ooZZUNqbO5IeSAAwjA3QWmU7/QG4CpR9ftc4l9ExPBNmtl0DyXRvZ/gs0HlyoIzzeEQuzamtgQKRkfniEAQT5eJqjM5AYYSwf7S7jLb9nOeCcBkmv0xJ6P1amSEvNB2QzkSGtmK7QQMIjl+8zQQ0+n4MePdyJziNg6PS05uxc1+slFpkYzIi3TbufDAUCaUQ64DIJT2Ke4CZ1btzM+HKFtHQ/1qvkKSCsg92+yV2LZxUJKSppOwlHimFFJd3xzwn9uz7V287bYVuxqUh6/qgbGKOIR/4dn5mIKHPaRMBnyit/9dJbHsD4MTzYpyJObFbqMFWfgNk29ecA4Di3EmDuYtkvjuVy2JeWtmlBz05BZDMcojIf3oRhG4cFLN6GKTbIuvlGtphaewebSQj4aVGas9X+ZyUIzqc940gKjQSOoxS5fROgkeZ4ZBR5EhcJ8ck2xZvTlv7gPO7MtOv2+qFXsHiONSkEgyY4eT/wYHMLZjzGV5A//Mi6rFFkhu7IAM1YNkZ0Gj7T7k7vVktOGM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7b5fdd6-03d7-4cf9-c88f-08dc69260908 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB6538.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2024 14:58:46.2246 (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: zAbF2UA8BsYFUHRAvFoNcDbbiuazM5raJvhrYBsr0qJoZjvVcBlLoyb6yeoiyAhLjF5JqVvjEfubQ80cefQImg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6493 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-30_08,2024-04-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxlogscore=929 bulkscore=0 suspectscore=0 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404300106 X-Proofpoint-GUID: 84aTGj4auubLStZ0EphhO_V-v5Xz28wm X-Proofpoint-ORIG-GUID: 84aTGj4auubLStZ0EphhO_V-v5Xz28wm 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+incoming=patchwork.ozlabs.org@gcc.gnu.org gcc/testsuite/ChangeLog: * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-3.c: New testcase. --- .../fam-in-union-alone-in-struct-1.c | 52 +++++++++++++++++++ .../fam-in-union-alone-in-struct-2.c | 51 ++++++++++++++++++ .../fam-in-union-alone-in-struct-3.c | 36 +++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c create mode 100644 gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-2.c create mode 100644 gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-3.c diff --git a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c new file mode 100644 index 000000000000..7d4721aa95ac --- /dev/null +++ b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c @@ -0,0 +1,52 @@ +/* testing the correct usage of flexible array members in unions + and alone in structures. */ +/* { dg-do run} */ +/* { dg-options "-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" } */ + /* { dg-warning "in an otherwise empty" "" { target c++ } .-1 } */ + int b[]; /* { dg-warning "flexible array member in union is a GCC extension" } */ +}; + +struct only_fam { + int b[]; + /* { dg-warning "in a struct with no named members" "" { target c } .-1 } */ + /* { dg-warning "in an otherwise empty" "" { target c++ } .-2 } */ + /* { dg-warning "forbids flexible array member" "" { target c++ } .-3 } */ +}; + +struct only_fam_2 { + unsigned int : 2; + unsigned int : 3; + int b[]; + /* { dg-warning "in a struct with no named members" "" { target c } .-1 } */ + /* { dg-warning "in an otherwise empty" "" { target c++ } .-2 } */ + /* { dg-warning "forbids flexible array member" "" { target c++ } .-3 } */ +}; + +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 (); + if (sizeof (struct only_fam_2) != sizeof (int)) + __builtin_abort (); + return 0; +} + diff --git a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-2.c b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-2.c new file mode 100644 index 000000000000..3743f9e7dac5 --- /dev/null +++ b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-2.c @@ -0,0 +1,51 @@ +/* testing the correct usage of flexible array members in unions + and alone in structures: 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}}; + +struct only_fam_2 { + unsigned int : 2; + unsigned int : 3; + int b[]; +} only_fam_2_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 (); + if (only_fam_2_v.b[0] != 7 + || only_fam_2_v.b[1] != 11) + __builtin_abort (); + + return 0; +} + diff --git a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-3.c b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-3.c new file mode 100644 index 000000000000..dd36fa01306d --- /dev/null +++ b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-3.c @@ -0,0 +1,36 @@ +/* testing the correct usage of flexible array members in unions + and alone in structures. */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +union with_fam_1 { + int a; + int b[]; /* { dg-error "flexible array member in union is a GCC extension" } */ +}; + +union with_fam_2 { + char a; + int b[]; /* { dg-error "flexible array member in union is a GCC extension" } */ +}; + +union with_fam_3 { + char a[]; /* { dg-error "flexible array member in union is a GCC extension" } */ + /* { dg-error "in an otherwise empty" "" { target c++ } .-1 } */ + int b[]; /* { dg-error "flexible array member in union is a GCC extension" } */ +}; + +struct only_fam { + int b[]; + /* { dg-error "in a struct with no named members" "" { target c } .-1 } */ + /* { dg-error "in an otherwise empty" "" { target c++ } .-2 } */ + /* { dg-error "forbids flexible array member" "" { target c++ } .-3 } */ +}; + +struct only_fam_2 { + unsigned int : 2; + unsigned int : 3; + int b[]; + /* { dg-error "in a struct with no named members" "" { target c } .-1 } */ + /* { dg-error "in an otherwise empty" "" { target c++ } .-2 } */ + /* { dg-error "forbids flexible array member" "" { target c++ } .-3 } */ +};