summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Woverride-init-2.c
blob: d0ece89eb6d71f68beb300aa8b246df9571c1855 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* Test for warnings for overriding designated initializers:
   -Wextra.  Bug 24010.  */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-Wextra" } */

struct s { int a; int b; int c; };
union u { char a; long long b; };

struct s s0 = {
  .a = 1,
  .b = 2,
  .a = 3, /* { dg-warning "initialized field overwritten" } */
  4, /* { dg-warning "initialized field overwritten" } */
  5
};

union u u0 = {
  .a = 1,
  .b = 2, /* { dg-warning "initialized field overwritten" } */
  .a = 3 }; /* { dg-warning "initialized field overwritten" } */

int a[5] = {
  [0] = 1,
  [1] = 2,
  [0] = 3, /* { dg-warning "initialized field overwritten" } */
  [2] = 4
};