From patchwork Thu Mar 2 01:25:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 63154 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3974644wrd; Wed, 1 Mar 2023 17:26:40 -0800 (PST) X-Google-Smtp-Source: AK7set8xkUCpPXbHKgqSkZ4Eu2ADQN4jLQ5neUWyE1SybZKaLDFocbnbmlTQeoluuqa76CHyDmid X-Received: by 2002:aa7:d484:0:b0:4ae:eab6:a07b with SMTP id b4-20020aa7d484000000b004aeeab6a07bmr418442edr.16.1677720400809; Wed, 01 Mar 2023 17:26:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677720400; cv=none; d=google.com; s=arc-20160816; b=nUcUrSMVCQRADQjXbx4GBWu6YnB5p3cbUhT1Ql++b53YdSE6/6nLDRoAr3PCT2awT9 CZ5fQs0/4D/a7Pqe78StvCKTEib+fYQAX+jBNwqbtAkbKIhfYQfxaanHisCs9TnOgKDy K+7AKsv1PihkqFhpsZld1VZR6Q2RrLl18NTXR34FJjlg/61iD2GTjN7ZL/4WM3HDNASK JpJXUviU7TPurxSjKPUv871BBuurH43jl8TzaBzUUNPm92oWftF2EbUz6IPhEYBhkPEB q7bsor+dZ1Jzb0azk5M2TnoDn2ooFzqFZnyNbSzMFztdwNXY98XIenVqdLUgQ2Ua2h4d SRZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:date:message-id :content-transfer-encoding:mime-version:subject:to:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=VrUhCxacNMPnjpQVnrU+bmoiZ2qFiDI6MfBkntV/WYA=; b=O5w67f9wWiAt9dzbQw/FEh5WTeJ7vyH/ec0T2kFQLPVIUqMz7hXHVDQmVNsom5bA/M W+EesQTn9FwdXPKkQuieNIJhqSD9V27IGpkj7QrG7xnoFHuFZItansDaSe3ZLoICgMUh CU3uvkv5nhtoV3/zFO7ngEOwLzpoxa/2kHRJWki/JkvzPYL4QL/UuVwW7JiHVQe875AI 21+q4H0N9i6Z5l0SrXH1bjaYNZcrY4iCkJVG13fSPuWNaOIohU7Mx6pskk5X2UK1qZwl Oa6pXCHGh0wENwVf3bePpxpz73h0c02GEAN7bL9YOzbrwLOKi1Od+OUZuHNhqaxwHr7x SSDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gThYvObI; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f7-20020a170906494700b008da1e19114fsi748312ejt.322.2023.03.01.17.26.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 17:26:40 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gThYvObI; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B82B2385841E for ; Thu, 2 Mar 2023 01:26:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B82B2385841E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677720399; bh=VrUhCxacNMPnjpQVnrU+bmoiZ2qFiDI6MfBkntV/WYA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=gThYvObIkvfO0GC0vuNrCpXCT2QEQZN5eTruue4xOJmQ7pLi2qiUVdZsSwrn9WewZ I4rahDxeFTAqC28tgoUZFfvyY89+AokqCCSfchLt/KUqzQlqv43Td3TIWENnHr/elG ILAXfGyhOvTHPLn8r5iDeW6s8jkanVi0dI12EJOw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by sourceware.org (Postfix) with ESMTPS id CE05B3858D33 for ; Thu, 2 Mar 2023 01:25:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE05B3858D33 To: Subject: [COMMITTED] testsuite: Fix g++.dg/ext/attr-copy-2.C for default_packed targets MIME-Version: 1.0 Message-ID: <20230302012552.279FF20433@pchp3.se.axis.com> Date: Thu, 2 Mar 2023 02:25:52 +0100 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Hans-Peter Nilsson via Gcc-patches From: Hans-Peter Nilsson Reply-To: Hans-Peter Nilsson Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759217346571972904?= X-GMAIL-MSGID: =?utf-8?q?1759217346571972904?= Committed as obvious. FWIW, I'm on the side that emitting the warning when the reason is just that it's the default layout, is bad. A discussion took place years ago when the warning was added. -- >8 -- For targets where the byte-wise structure element layout is the same as for attribute-packed, you get a warning when that's specified. Thus, expect a warning for such targets. Note the exclusion of bitfields. * g++.dg/ext/attr-copy-2.C: Fix for default_packed targets. --- gcc/testsuite/g++.dg/ext/attr-copy-2.C | 60 +++++++++++++------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/gcc/testsuite/g++.dg/ext/attr-copy-2.C b/gcc/testsuite/g++.dg/ext/attr-copy-2.C index 7776959d9f6b..ffd6f22ef56d 100644 --- a/gcc/testsuite/g++.dg/ext/attr-copy-2.C +++ b/gcc/testsuite/g++.dg/ext/attr-copy-2.C @@ -27,51 +27,51 @@ extern B &rb; typedef struct C { - ATTR (copy ((struct A *)0)) short m_pa_0; - ATTR (copy ((struct A *)(1, 0))) int m_pa_1_0; - ATTR (copy ((struct A *)(0, 1))) long m_pa_0_1; + ATTR (copy ((struct A *)0)) short m_pa_0; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy ((struct A *)(1, 0))) int m_pa_1_0; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy ((struct A *)(0, 1))) long m_pa_0_1; // { dg-warning "attribute ignored" "" { target default_packed } } - ATTR (copy (*(struct A *)0)) short m_xpa_0; - ATTR (copy (*(struct A *)(1, 0))) int m_xpa_1_0; - ATTR (copy (*(struct A *)(0, 1))) long m_xpa_0_1; + ATTR (copy (*(struct A *)0)) short m_xpa_0; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (*(struct A *)(1, 0))) int m_xpa_1_0; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (*(struct A *)(0, 1))) long m_xpa_0_1; // { dg-warning "attribute ignored" "" { target default_packed } } - ATTR (copy (((struct A *)0)[0])) short m_arpa_0; - ATTR (copy (((struct A *)(1, 0))[0])) int m_arpa_1_0; - ATTR (copy (((struct A *)(0, 1))[0])) long m_arpa_0_1; + ATTR (copy (((struct A *)0)[0])) short m_arpa_0; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (((struct A *)(1, 0))[0])) int m_arpa_1_0; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (((struct A *)(0, 1))[0])) long m_arpa_0_1; // { dg-warning "attribute ignored" "" { target default_packed } } - ATTR (copy (a)) short m_a; - ATTR (copy (b.a)) int m_b_a; - ATTR (copy (b.pa)) long m_b_pa; - ATTR (copy (b.ra)) long m_b_ra; + ATTR (copy (a)) short m_a; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (b.a)) int m_b_a; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (b.pa)) long m_b_pa; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (b.ra)) long m_b_ra; // { dg-warning "attribute ignored" "" { target default_packed } } - ATTR (copy (&a)) short m_ara; - ATTR (copy (&b.a)) int m_arb_a; - ATTR (copy (*b.pa)) long m_xb_pa; - ATTR (copy (b.pa[0])) long m_arb_pa; + ATTR (copy (&a)) short m_ara; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (&b.a)) int m_arb_a; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (*b.pa)) long m_xb_pa; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (b.pa[0])) long m_arb_pa; // { dg-warning "attribute ignored" "" { target default_packed } } - ATTR (copy (*pa)) short m_xpa; - ATTR (copy (pa[0])) short m_arpa; + ATTR (copy (*pa)) short m_xpa; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (pa[0])) short m_arpa; // { dg-warning "attribute ignored" "" { target default_packed } } - ATTR (copy (ra)) short m_ra; + ATTR (copy (ra)) short m_ra; // { dg-warning "attribute ignored" "" { target default_packed } } - ATTR (copy (ab[0].a)) int m_arab_a; - ATTR (copy (ab[1].pa)) long m_arab_pa; - ATTR (copy (*ab[2].pa)) int m_xarab_pa; + ATTR (copy (ab[0].a)) int m_arab_a; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (ab[1].pa)) long m_arab_pa; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (*ab[2].pa)) int m_xarab_pa; // { dg-warning "attribute ignored" "" { target default_packed } } ATTR (copy (ab[3].pa->bf)) unsigned int m_arab_pa_bf: 1; ATTR (copy (ab[4].ra.bf)) unsigned int m_arab_ra_bf: 1; - ATTR (copy (pb->a)) int m_pb_a; - ATTR (copy (pb->pa)) long m_pb_pa; - ATTR (copy (*pb->pa)) int m_xpb_pa; + ATTR (copy (pb->a)) int m_pb_a; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (pb->pa)) long m_pb_pa; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (*pb->pa)) int m_xpb_pa; // { dg-warning "attribute ignored" "" { target default_packed } } ATTR (copy (pb->pa->bf)) unsigned int m_pb_pa_bf: 1; ATTR (copy (pb->ra.bf)) unsigned int m_pb_ra_bf: 1; - ATTR (copy (rb.a)) int m_rb_a; - ATTR (copy (rb.pa)) long m_rb_pa; - ATTR (copy (*rb.pa)) int m_xrb_pa; + ATTR (copy (rb.a)) int m_rb_a; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (rb.pa)) long m_rb_pa; // { dg-warning "attribute ignored" "" { target default_packed } } + ATTR (copy (*rb.pa)) int m_xrb_pa; // { dg-warning "attribute ignored" "" { target default_packed } } ATTR (copy (rb.pa->bf)) unsigned int m_rb_pa_bf: 1; - ATTR (aligned (4), copy ((struct A *)(0))) short m_a4_pa_0; + ATTR (aligned (4), copy ((struct A *)(0))) short m_a4_pa_0; // { dg-warning "attribute ignored" "" { target default_packed } } } C;