From patchwork Wed May 1 16:52:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qing Zhao X-Patchwork-Id: 1930303 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=cJdAbpwn; 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=F7fJ1MXL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4VV3795Nffz1ydT for ; Thu, 2 May 2024 02:53:57 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0981F385840D for ; Wed, 1 May 2024 16:53:56 +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 D9E9B384AB70 for ; Wed, 1 May 2024 16:52:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D9E9B384AB70 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 D9E9B384AB70 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=1714582372; cv=pass; b=MxmacSXLYKkQjdtCuUKj+7Hhm3Y+gzVNcK+26xWzS+noIe6d6gV9GqU8cKOWTFqVbMyax40R6kebC+N8qOYHdbj0fCzU+NbjoWZt0YHfk8F32xPG7Nx8BvYZ3iKQhwhVE1S9YBIBR40vPlWEMzEp7le6/LUC449I3NW/K5LqMv8= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1714582372; c=relaxed/simple; bh=3n0wAyTGloE80TgxiCRQuCUuS6BtO+OZ24FVOGjSbDU=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=syglX6/as3U6NNEhbyIbU3SsMNtG9PeevdzT7pAljotyP4H0jiFpW0XoMLsWHm6xlLpam0dLsK2j2fPjzmRibyZbKqNDT+HdqG45QEHMFoDz1UIGyEZvqNITrkc3AluMDdkcxCQaxtJv5TaYPITz2uHaykrJYH6D5cuZMDjUQfQ= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 441AS0WI001725; Wed, 1 May 2024 16:52:47 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=cJdAbpwnVh5D6E/zwwO8+rB66IcIDjcp8pEL+4qfHw+hy2jQc5b560KmY9xtkKstlMih 6cQybPF0Z9THb4MHtoTAcOTajx+l7yn5jX4Gx5nIV2tS3LcAg88rCcJ5PUiSRrrsLXUo fZUjJK0kAqKa3PNpQraE7BAUViy7VodvyhqoixtPJSVbeqcXh3v+cOMujJiLXhNJCnuf L+kCF7AjpyQScUK+Sv3hSlWOz04U6188Y/ly4Uy9m5RTWja7aNMijA5PFBLeAOCVctP3 j1hw3iUQ+i/WNUa/zKN+03alW1i1R+7UiDN1/yPNrO38dy696vV0OBUSclZ+Fvb3RfUG gg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrr9cqptn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 May 2024 16:52:47 +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 441Fle4j011336; Wed, 1 May 2024 16:52:46 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2101.outbound.protection.outlook.com [104.47.55.101]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xrqt9h9qr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 May 2024 16:52:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B2EIDWR0YScvHb2/dqtH43ewW8FbX8yHswo/P6/Ra4YACFmSGaA/ql4yIW1QU1QQUiY/PmHVdJ/X0rKmxM8icLzY2hpM2xmR6HeTNWwX2y1KGiOq5ToLYaAAzvXPn1nEsFqI7P88lwr9JL+KkQu01TWKd8CUey/BfVCzb5UKwVivwgc0yjMORazA3TbvZmo8eMZdDCvdPNubJAPS8HLh4GXmd+V8xzMjhWxEY4mPVmQRDHMzf3N8prRxsg7xcN0CqH051SKCCV/ic5KVoYy7LeCe1/e+6zYwpHmCn6rhNRF/+6/g1sjOweVcY3FR2/zYphU9l6q0q2ozBHlZ1ixRPQ== 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=Pd6XGBr2wSv+k7cywQibTRRHalcHjJ3v606eGpheVyBSJlqelLugQ+iiPIx3GTDOatRcBhSq0LPPw6KbJr6KRxrLa0Ro68Y3SoGs40Eh5V28shwpfmkhJIF1UirXp3t6WHlcONJpS8uGuLSP/zWIpW6akckIT/8itZ0dREZgXoooKPxb9lRBOkoWhmuoMuy79A/Sf3FNr+XjdcOw9W4zgosCRVoMaGIKaWZzvRU2c5Cf1sW6JVmu+eTndR2adsRVDJb1/9UBsCGwWkB7VYH3jtv+ClFnavXjWwJkrFEuC3wp8am78aHHBKx77z6ZGKtCBHXrJgR/qRPO7klW/bfzSA== 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=F7fJ1MXLfLHx6t5yd8lawxFvG+TYHTwf2DJw8nEcUGYGAOKWTpa5V4vUWPPt3ZhpudZKoenIOfZPKVO6I6zIot5mggUoSty0QOPiwYMTuVbY5c40FKLyxyn1x13fgj/cfZ0inkWLmFM62WLJfYatL56AfoOI2b3w/NPeractjkA= Received: from CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) by BLAPR10MB4962.namprd10.prod.outlook.com (2603:10b6:208:327::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.28; Wed, 1 May 2024 16:52:44 +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; Wed, 1 May 2024 16:52:44 +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 v5 3/4] Add testing cases for flexible array members in unions and alone in structures. Date: Wed, 1 May 2024 16:52:25 +0000 Message-Id: <20240501165226.2924144-4-qing.zhao@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240501165226.2924144-1-qing.zhao@oracle.com> References: <20240501165226.2924144-1-qing.zhao@oracle.com> X-ClientProxiedBy: LO4P265CA0222.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:33a::10) To CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB6538:EE_|BLAPR10MB4962:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e9aef75-1715-42e6-c1b3-08dc69ff1f4b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|1800799015; X-Microsoft-Antispam-Message-Info: A1Rwria48bMrX1aeXXp3OHjkBqwCaSMhtivo7krXGdWjRnAwgm6heVFyfYyEUoVcAlMpfLxOzQHyriE/gq/apVNd3hrwnd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66YctjoVK9q/IqOfIk3tIp0lBq64r2AFOD8IMpL4jf5ToY1OXakqyISEa9L8/Ah8ehgTnVY0XlGWfkA1CkPIU2NU0wTa2/MWipC4GeYca4XcTnQv5yWkX3fqcvv/8g== 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)(376005)(1800799015); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4rJON3MHlTjKCXHA4AzgZssPlPx12mYZxliZkEvo+i+QE3wrqsjvxeNS86s+rwhv+TkkjjmgLB8azhh9XXscbOFVbXU4q8931Kf4Xtx++iFPJ03C2J9xNceuz4A1WZjkmSXeh3R1BFDMcrLTdnQMi+DGIJtDYuOEM3M3tTnOra5c0EoL2YTJDO+CroizuI2mf1ylqRzqrsMVUi2fPtSrGtMlN0REuC9bNoCrLXCFETpqq1IksvsEIW8TgeTUkG3biMKPVPxZo6h68WGsh51UsAI5ZE3M0KxDMAsT4HQcRcmDqghUWKhM1DbQM/0sv+qPf8ep4zOqaAhqdKO64OOlTpKVg0eFbTBicNBYuJaovTQr+yyQTl8jKLdi3ayOea17yCsDaSIpcgY7C98KRvVLs+l6NJgRC+G0tp6K3IN6TT++Lu9X22OCooh3WtRkBR+Bny/fkjFYprfQICGxOXWgWYL91BFEvNABc4MAagkuoklxA/fRG1NyZKyiDmba8lm2YKpFIYe44n/GMxDkWHEGvIhcTLz80axlesYm1Io1NGNgOx/LmR17Kfl3VK71h6A5aggSHeXengpS5V2Ujqxf17TMEDztzvRkwQALBgzHD1bNdko+tEwIikVZUSDHNrrs8JFoOlEP817Uq8MhfYc+Nwul2KHFB/132wYEil/rDqle8XwQukrHAFiBq2FVpXl/7E1+CyEcofBLPwMa+/DGP8iZuVkesvrm2Ar27u07ynzJVWbQcnP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b/Iuan1bEQcDhSMCSOnWFjGlK7RbhPlUDrNQU+1raaLoiex1ifWzVKq5Dc5LVVEQoqkmRNfa8PmLXo4H4km6EF3woVKRqaslMEv1m4ehpcMUDrAcxKWSWnP2avVuCL9cpyrYYpwTCJhqa/KRLqbwyjbbdi6f2aHxN//VdRPQetbIPy8SJn1W47F9xjT2OCWNLSVVKU7qApf9p0UcFMuRVCmZKBNgMdKpOwSuleqDBQit9BmuWa6PW0cr9/MZfc27A9Vmm6NgzwkIblcO6W1XhR+wlWJeCicaNHzXcdFRxPh92nnNhsi+6a8vDQ8Qp1o+bAb7SxxUL7zywHjhMXLNkbz/QrD7kyhv6rActE44mW9l7D8myn+x3N84jCyN82GT+eaz9Gs8fYCCwt9/3XTdk1hGmf7LTeU7XL9A+NpdHqND4Fex008iO+oBK/kyNslpjUurLfO2SyvHCXNY0QZ57w= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e9aef75-1715-42e6-c1b3-08dc69ff1f4b X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB6538.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2024 16:52:44.4582 (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: zrS3f4IpSbV1JDI9fMPMcKT5cdJWDCA1xPD8KTWubiZ3aWLu+qzJ8evnwh6NPXwgEDK0PbSBwtMPWOxdbubxtA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4962 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-05-01_16,2024-04-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=929 malwarescore=0 adultscore=0 mlxscore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405010118 X-Proofpoint-GUID: Q6oce3PIqsKiTPPj2WSwJf3UHatg8eZe X-Proofpoint-ORIG-GUID: Q6oce3PIqsKiTPPj2WSwJf3UHatg8eZe X-Spam-Status: No, score=-11.3 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 } */ +};