From patchwork Mon Jul 20 16:31:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitar Dimitrov X-Patchwork-Id: 1332488 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=dinux.eu Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=dinux.eu header.i=@dinux.eu header.a=rsa-sha256 header.s=default header.b=eJjJfJHS; dkim-atps=neutral Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B9S0s1WT1zB3tg for ; Tue, 21 Jul 2020 02:31:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3B5CF3861854; Mon, 20 Jul 2020 16:31:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from server28.superhosting.bg (server28.superhosting.bg [217.174.156.11]) by sourceware.org (Postfix) with ESMTPS id 19CCC3861031 for ; Mon, 20 Jul 2020 16:31:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 19CCC3861031 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dinux.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dimitar@dinux.eu DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dinux.eu; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=+TXsBBskbSm4kCzlLeryCwIq0K1OTSqbZkkxeWOonm4=; b=eJjJfJHS6FMS6HC+7s6dZKnVP3 WZDjAw9DoHqp6JdSnfiEWv0Ut9Ia0I6kNWwJ/XwzD+1gW8xbKQZ68vyII5WOCdk9qvpvtCEFo7XZH geH4NjHcH0XLZx5PhKFgiBfgcuZvz/lhoir3jDhoLfTSyrz33vkBWcOKkavDNBF+lAW1rr7NUXLMQ MI7z8cb7ehTi3vBTUvW4lcJaUdocsvf21v35b9rg3B8ZJ0wG5cojjcBtI//0UvRPUvrkraqkI+U9J 7InZAcIKkMmOOnLG1spfz7wQEv/dsOI8vrzSkTwR5SspS+HEZe/BibmKuiR+BhbEYIpliCyhOQRR2 iDcS2ODg==; Received: from [95.87.234.74] (port=60198 helo=localhost.localdomain) by server28.superhosting.bg with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1jxYhJ-00046m-JI; Mon, 20 Jul 2020 19:31:28 +0300 From: Dimitar Dimitrov To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/4] testsuite: Add expected warning for packed attribute Date: Mon, 20 Jul 2020 19:31:04 +0300 Message-Id: <20200720163106.27849-3-dimitar@dinux.eu> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200720163106.27849-1-dimitar@dinux.eu> References: <20200720163106.27849-1-dimitar@dinux.eu> MIME-Version: 1.0 X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server28.superhosting.bg X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dinux.eu X-Get-Message-Sender-Via: server28.superhosting.bg: authenticated_id: dimitar@dinux.eu X-Authenticated-Sender: server28.superhosting.bg: dimitar@dinux.eu X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Targets which pack structures by default get warnings for packed structure attributes. This is expected, so add markers in the test cases. gcc/testsuite/ChangeLog: * c-c++-common/Waddress-of-packed-member-2.c: Add dg-warning for ignored attribute if target is default_packed. * c-c++-common/Wattributes.c: Ditto. * c-c++-common/attr-copy.c: Ditto. * c-c++-common/builtin-has-attribute-4.c: Ditto. * c-c++-common/pr51628-29.c: Ditto. * c-c++-common/pr51628-30.c: Ditto. * c-c++-common/pr51628-32.c: Ditto. * gcc.dg/Wattributes-6.c: Ditto. * gcc.dg/attr-copy-4.c: Ditto. * gcc.dg/attr-copy-8.c: Ditto. Signed-off-by: Dimitar Dimitrov --- .../Waddress-of-packed-member-2.c | 1 + gcc/testsuite/c-c++-common/Wattributes.c | 2 +- gcc/testsuite/c-c++-common/attr-copy.c | 1 + .../c-c++-common/builtin-has-attribute-4.c | 2 +- gcc/testsuite/c-c++-common/pr51628-29.c | 1 + gcc/testsuite/c-c++-common/pr51628-30.c | 1 + gcc/testsuite/c-c++-common/pr51628-32.c | 1 + gcc/testsuite/gcc.dg/Wattributes-6.c | 2 +- gcc/testsuite/gcc.dg/attr-copy-4.c | 3 ++- gcc/testsuite/gcc.dg/attr-copy-8.c | 25 +++++++++++++++++++ 10 files changed, 35 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/c-c++-common/Waddress-of-packed-member-2.c b/gcc/testsuite/c-c++-common/Waddress-of-packed-member-2.c index 5dbcb89ffbc..802dd8156cb 100644 --- a/gcc/testsuite/c-c++-common/Waddress-of-packed-member-2.c +++ b/gcc/testsuite/c-c++-common/Waddress-of-packed-member-2.c @@ -15,6 +15,7 @@ struct s { struct t { char c; struct r p __attribute__((packed)); + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ struct r u; }; diff --git a/gcc/testsuite/c-c++-common/Wattributes.c b/gcc/testsuite/c-c++-common/Wattributes.c index 3f176a04660..4ad90441b4d 100644 --- a/gcc/testsuite/c-c++-common/Wattributes.c +++ b/gcc/testsuite/c-c++-common/Wattributes.c @@ -21,7 +21,7 @@ PackedAligned { int i; }; struct ATTR ((aligned (2))) AlignedMemberPacked { - int ATTR ((packed)) i; + int ATTR ((packed)) i; // { dg-warning "attribute ignored" "" { target default_packed } } }; struct ATTR ((packed)) diff --git a/gcc/testsuite/c-c++-common/attr-copy.c b/gcc/testsuite/c-c++-common/attr-copy.c index 284088a8b97..f0db0fd1a27 100644 --- a/gcc/testsuite/c-c++-common/attr-copy.c +++ b/gcc/testsuite/c-c++-common/attr-copy.c @@ -21,6 +21,7 @@ struct C { char c; ATTR (copy ((bar (), ((struct A *)(0))[0]))) int i; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ }; /* Verify the attribute has been copied. */ diff --git a/gcc/testsuite/c-c++-common/builtin-has-attribute-4.c b/gcc/testsuite/c-c++-common/builtin-has-attribute-4.c index ec3127794b5..3a960aae2ff 100644 --- a/gcc/testsuite/c-c++-common/builtin-has-attribute-4.c +++ b/gcc/testsuite/c-c++-common/builtin-has-attribute-4.c @@ -130,7 +130,7 @@ struct PackedMember char c; short s; int i; - ATTR (packed) int a[2]; + ATTR (packed) int a[2]; /* { dg-warning "attribute ignored" "" { target default_packed } } */ } gpak[2]; void test_packed (struct PackedMember *p) diff --git a/gcc/testsuite/c-c++-common/pr51628-29.c b/gcc/testsuite/c-c++-common/pr51628-29.c index a3e77455b6b..1ad9a7d2d9f 100644 --- a/gcc/testsuite/c-c++-common/pr51628-29.c +++ b/gcc/testsuite/c-c++-common/pr51628-29.c @@ -5,6 +5,7 @@ struct A { int i; }; struct B { struct A a; }; struct C { struct B b __attribute__ ((packed)); }; +/* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ extern struct C *p; diff --git a/gcc/testsuite/c-c++-common/pr51628-30.c b/gcc/testsuite/c-c++-common/pr51628-30.c index b31e73ec036..387fc71db13 100644 --- a/gcc/testsuite/c-c++-common/pr51628-30.c +++ b/gcc/testsuite/c-c++-common/pr51628-30.c @@ -5,6 +5,7 @@ struct A { __complex int i; }; struct B { struct A a; }; struct C { struct B b __attribute__ ((packed)); }; +/* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ extern struct C *p; diff --git a/gcc/testsuite/c-c++-common/pr51628-32.c b/gcc/testsuite/c-c++-common/pr51628-32.c index 52f5e543ab7..908c0b8cbf4 100644 --- a/gcc/testsuite/c-c++-common/pr51628-32.c +++ b/gcc/testsuite/c-c++-common/pr51628-32.c @@ -11,6 +11,7 @@ struct B { char c; __attribute ((packed)) struct A ar[4]; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ }; struct B b; diff --git a/gcc/testsuite/gcc.dg/Wattributes-6.c b/gcc/testsuite/gcc.dg/Wattributes-6.c index d3dd22d85b9..4ba59bf2806 100644 --- a/gcc/testsuite/gcc.dg/Wattributes-6.c +++ b/gcc/testsuite/gcc.dg/Wattributes-6.c @@ -21,7 +21,7 @@ PackedAligned { int i; }; struct ATTR ((aligned (2))) AlignedMemberPacked { - int ATTR ((packed)) i; + int ATTR ((packed)) i; // { dg-warning "attribute ignored" "" { target default_packed } } }; struct ATTR ((packed)) diff --git a/gcc/testsuite/gcc.dg/attr-copy-4.c b/gcc/testsuite/gcc.dg/attr-copy-4.c index 1350a35ec94..796724bb950 100644 --- a/gcc/testsuite/gcc.dg/attr-copy-4.c +++ b/gcc/testsuite/gcc.dg/attr-copy-4.c @@ -21,7 +21,8 @@ Assert (__alignof (struct PackedA) == __alignof (struct PackedB)); struct PackedMember { char c; - ATTR ((copy ((struct PackedB*)0))) double packed_mem; + ATTR ((copy ((struct PackedB*)0))) double packed_mem; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ }; Assert (__alignof (struct PackedMember) == 1); diff --git a/gcc/testsuite/gcc.dg/attr-copy-8.c b/gcc/testsuite/gcc.dg/attr-copy-8.c index c75d9e5c98c..7195f6b19f8 100644 --- a/gcc/testsuite/gcc.dg/attr-copy-8.c +++ b/gcc/testsuite/gcc.dg/attr-copy-8.c @@ -21,41 +21,66 @@ extern B *pb; typedef struct C { ATTR (copy ((struct A *)0)) short m_pa_0; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy ((struct A *)(1, 0))) int m_pa_1_0; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy ((struct A *)(0, 1))) long m_pa_0_1; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (*(struct A *)0)) short m_xpa_0; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (*(struct A *)(1, 0))) int m_xpa_1_0; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (*(struct A *)(0, 1))) long m_xpa_0_1; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (((struct A *)0)[0])) short m_arpa_0; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (((struct A *)(1, 0))[0])) int m_arpa_1_0; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (((struct A *)(0, 1))[0])) long m_arpa_0_1; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ /* Also exercise COMPONENT_REF, ARRAY_REF, and INDIRECT_REF. */ ATTR (copy (a)) short m_ra; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (b.a)) int m_rb_a; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (b.pa)) long m_rb_pa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (&a)) short m_ara; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (&b.a)) int m_arb_a; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (*b.pa)) long m_xb_pa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (b.pa[0])) long m_arb_pa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (*pa)) short m_xpa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (pa[0])) short m_arpa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (ab[0].a)) int m_arab_a; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (ab[1].pa)) long m_arab_pa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (*ab[2].pa)) int m_xarab_pa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (ab[3].pa->bf)) unsigned int m_arab_pa_bf: 1; ATTR (copy (pb->a)) int m_pb_a; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (pb->pa)) long m_pb_pa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (*pb->pa)) int m_xpb_pa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ ATTR (copy (pb->pa->bf)) unsigned int m_pb_pa_bf: 1; ATTR (aligned (4), copy ((struct A *)(0))) short m_a4_pa_0; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ } C;