This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] Another test for designated_init (PR c/59855)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]