summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/init-excess-2.c
blob: 0e91b60950b3daa421a612a57ab5f7247caa79a7 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* Test for diagnostics about excess initializers when using a macro
   defined in a system header:
   c/71115 - Missing warning: excess elements in struct initializer.  */
/* { dg-do compile } */
/* { dg-options "" } */
/* { dg-require-effective-target int32plus } */

#include <stddef.h>

int* a[1] = {
  0,
  NULL              /* { dg-warning "excess elements|near init" } */
};

const char str[1] = {
  0,
  NULL              /* { dg-warning "excess elements|near init" } */
};

struct S {
  int *a;
} s = {
  0,
  NULL              /* { dg-warning "excess elements|near init" } */
};

struct __attribute__ ((designated_init)) S2 {
  int *a;
} s2 = {
  NULL              /* { dg-warning "positional initialization|near init" } */
};

union U {
  int *a;
} u = {
  0,
  NULL              /* { dg-warning "excess elements|near init" } */
};

int __attribute__ ((vector_size (16))) ivec = {
  0, 0, 0, 0,
  NULL              /* { dg-warning "excess elements|near init" } */
};

int* scal = {
  0,
  NULL              /* { dg-warning "excess elements|near init" } */
};