diff options
author | Marek Polacek <polacek@redhat.com> | 2014-05-02 05:40:38 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2014-05-02 05:40:38 +0000 |
commit | 6a358dcb65c409f966347dc4cfce1f53942f7173 (patch) | |
tree | 3886530e4ee93fe1ce5e786a6e2bbb874f908b75 /gcc | |
parent | cea4a152f6c7824ec28e27580f2086b7c3e8f87c (diff) | |
download | gcc-6a358dcb65c409f966347dc4cfce1f53942f7173.zip gcc-6a358dcb65c409f966347dc4cfce1f53942f7173.tar.gz gcc-6a358dcb65c409f966347dc4cfce1f53942f7173.tar.bz2 |
re PR c/60784 (Spurious -Wmissing-field-initializers warning for anonymous structure)
PR c/60784
* c-typeck.c (push_init_level): Set constructor_designated to
p->designated for structures.
* gcc.dg/pr60784.c: New test.
From-SVN: r209998
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr60784.c | 25 |
4 files changed, 39 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index a5b4f5f..8fc20cf 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2014-05-02 Marek Polacek <polacek@redhat.com> + + PR c/60784 + * c-typeck.c (push_init_level): Set constructor_designated to + p->designated for structures. + 2014-05-01 Marek Polacek <polacek@redhat.com> PR c/60915 diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 21d1006..98567b4 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -7270,6 +7270,9 @@ push_init_level (int implicit, struct obstack * braced_init_obstack) push_member_name (constructor_fields); constructor_depth++; } + /* If upper initializer is designated, then mark this as + designated too to prevent bogus warnings. */ + constructor_designated = p->designated; } else if (TREE_CODE (constructor_type) == ARRAY_TYPE) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f5976b9..1845daf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-05-02 Marek Polacek <polacek@redhat.com> + + PR c/60784 + * gcc.dg/pr60784.c: New test. + 2014-05-01 Marek Polacek <polacek@redhat.com> PR c/60915 diff --git a/gcc/testsuite/gcc.dg/pr60784.c b/gcc/testsuite/gcc.dg/pr60784.c new file mode 100644 index 0000000..82b512f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr60784.c @@ -0,0 +1,25 @@ +/* PR c/60784 */ +/* { dg-do compile } */ +/* { dg-options "-Wextra -std=c99" } */ + +struct A { int i, j; }; +struct B { struct A a; } b1 = { .a.i = 1, .a.j = 1 }; +struct B b2 = { .a.i = 1 }; + +struct C { struct { int a, b; }; } c1 = { .a = 4, .b = 2 }; +struct C c2 = { .a = 4, .b = 2 }; + +struct D { struct A a; }; +struct E { struct D d; }; +struct F { struct E e; } f1 = { .e.d.a.i = 8 }; +struct F f2 = { .e.d.a.i = 8, .e.d.a.j = 3 }; + +struct G { + struct { + struct { + struct { + int a, b, c, d, e, f; + }; + }; + }; +} g = { .b = 2 }; |