This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Another test for designated_init (PR c/59855)
- From: Marek Polacek <polacek at redhat dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 2 Aug 2014 07:48:56 +0200
- Subject: [committed] Another test for designated_init (PR c/59855)
- Authentication-results: sourceware.org; auth=none
Test also anonymous union in a structure.
Tested on x86_64-linux, applying to trunk.
2014-08-02 Marek Polacek <polacek@redhat.com>
PR c/59855
* gcc.dg/Wdesignated-init-2.c: New test.
diff --git gcc/testsuite/gcc.dg/Wdesignated-init-2.c gcc/testsuite/gcc.dg/Wdesignated-init-2.c
index e69de29..d5edfba 100644
--- gcc/testsuite/gcc.dg/Wdesignated-init-2.c
+++ gcc/testsuite/gcc.dg/Wdesignated-init-2.c
@@ -0,0 +1,15 @@
+/* PR c/59855 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu11" } */
+
+struct S {
+ int a;
+ union {
+ int b;
+ int c;
+ };
+} __attribute__((designated_init));
+
+struct S s1 = { .a = 0, .b = 0 };
+struct S s2 = { 0, 0 }; /* { dg-warning "(positional|near initialization)" } */
+struct S s3 = { .a = 5, 0 }; /* { dg-warning "(positional|near initialization)" } */
Marek