testsute: Add expected warning for packed attribute
authorDimitar Dimitrov <dimitar@dinux.eu>
Thu, 9 Jul 2020 19:04:38 +0000 (22:04 +0300)
committerDimitar Dimitrov <dimitar@dinux.eu>
Tue, 21 Jul 2020 15:35:44 +0000 (18:35 +0300)
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 <dimitar@dinux.eu>
gcc/testsuite/c-c++-common/Waddress-of-packed-member-2.c
gcc/testsuite/c-c++-common/Wattributes.c
gcc/testsuite/c-c++-common/attr-copy.c
gcc/testsuite/c-c++-common/builtin-has-attribute-4.c
gcc/testsuite/c-c++-common/pr51628-29.c
gcc/testsuite/c-c++-common/pr51628-30.c
gcc/testsuite/c-c++-common/pr51628-32.c
gcc/testsuite/gcc.dg/Wattributes-6.c
gcc/testsuite/gcc.dg/attr-copy-4.c
gcc/testsuite/gcc.dg/attr-copy-8.c

index 5dbcb89..802dd81 100644 (file)
@@ -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;
 };
 
index 3f176a0..4ad9044 100644 (file)
@@ -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))
index 284088a..f0db0fd 100644 (file)
@@ -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.  */
index ec31277..3a960aa 100644 (file)
@@ -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)
index a3e7745..1ad9a7d 100644 (file)
@@ -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;
 
index b31e73e..387fc71 100644 (file)
@@ -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;
 
index 52f5e54..908c0b8 100644 (file)
@@ -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;
index d3dd22d..4ba59bf 100644 (file)
@@ -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))
index 1350a35..796724b 100644 (file)
@@ -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);
index c75d9e5..7195f6b 100644 (file)
@@ -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;