Debian Codegraph @

gcc/testsuite/gcc.dg/init-excess-2.c

raw
1 /* Test for diagnostics about excess initializers when using a macro
2 defined in a system header:
3 c/71115 - Missing warning: excess elements in struct initializer. */
4 /* { dg-do compile } */
5 /* { dg-options "" } */
6 /* { dg-require-effective-target int32plus } */
7
8 #include <stddef.h>
9
10 int* a[1] = {
11 0,
12 NULL /* { dg-warning "excess elements|near init" } */
13 };
14
15 const char str[1] = {
16 0,
17 NULL /* { dg-warning "excess elements|near init" } */
18 };
19
20 struct S {
21 int *a;
22 } s = {
23 0,
24 NULL /* { dg-warning "excess elements|near init" } */
25 };
26
27 struct __attribute__ ((designated_init)) S2 {
28 int *a;
29 } s2 = {
30 NULL /* { dg-warning "positional initialization|near init" } */
31 };
32
33 union U {
34 int *a;
35 } u = {
36 0,
37 NULL /* { dg-warning "excess elements|near init" } */
38 };
39
40 int __attribute__ ((vector_size (16))) ivec = {
41 0, 0, 0, 0,
42 NULL /* { dg-warning "excess elements|near init" } */
43 };
44
45 int* scal = {
46 0,
47 NULL /* { dg-warning "excess elements|near init" } */
48 };