PR tree-optimization/83369 - Missing diagnostics during inlining
[official-gcc.git] / gcc / testsuite / gcc.dg / pr61096-1.c
blob6678d812eb53a018959661cccf35a67572521b95
1 /* PR c/61077 */
2 /* { dg-do compile } */
3 /* { dg-options "-std=gnu99 -fshort-enums -fshort-wchar -Wpedantic" } */
4 /* { dg-prune-output ".*near initialization for.*" } */
6 typedef enum { A } schar;
7 extern int e;
8 struct S
10 int a[3];
12 struct f
14 int w;
15 int x[];
17 struct g
19 struct f f; /* { dg-warning "invalid use of structure with flexible array member" } */
22 char w1[] = L"foo"; /* { dg-error "13:char-array initialized from wide string" } */
23 __WCHAR_TYPE__ w2[] = "foo"; /* { dg-error "23:wide character array initialized from non-wide string" } */
24 __WCHAR_TYPE__ w3[] = U"foo"; /* { dg-error "23:wide character array initialized from incompatible wide string" } */
25 schar a1[] = "foo"; /* { dg-error "14:array of inappropriate type initialized from string constant" } */
26 int a2[] = (int[]) { 1 }; /* { dg-warning "12:initializer element is not constant" } */
28 int a3 = e; /* { dg-error "10:initializer element is not constant" } */
29 int a4 = (e, 1); /* { dg-error "10:initializer element is not constant" } */
30 int a5 = a1[0]; /* { dg-error "10:initializer element is not constant" } */
31 int a6 = &a3 - &a4; /* { dg-error "10:initializer element is not" } */
32 int a7[] = a7; /* { dg-error "12:invalid initializer" } */
34 struct S s = { { 1 }, { 3 } }; /* { dg-error "23:extra brace group at end of initializer" } */
35 /* { dg-warning "23:excess elements in struct initializer" "" { target *-*-* } .-1 } */
36 struct g g1 = { {0, { 1 } } }; /* { dg-error "21:initialization of flexible array member in a nested context" } */
37 struct g g2 = { .f[0] = 1 }; /* { dg-error "20:array index in non-array initializer" } */
39 __extension__ int a8 = { }; /* { dg-error "24:empty scalar initializer" } */
40 int a9[10] = {[1.2] = 2 }; /* { dg-error "16:array index in initializer not of integer type" } */
41 int a10[10] = {[e] = 2 }; /* { dg-error "17:nonconstant array index in initializer" } */
42 __extension__ int a11[10] = {[1 ... e] = 1 }; /* { dg-error "31:nonconstant array index in initializer" } */
43 int a12 = {[1] = 2 }; /* { dg-error "13:array index in non-array initializer" } */
44 int a13[2] = {[-1] = 4 }; /* { dg-error "16:array index in initializer exceeds array bounds" } */
45 int a14[2] = {[64] = 4 }; /* { dg-error "16:array index in initializer exceeds array bounds" } */
46 __extension__ int a15[10] = {[2 ... 1] = 4 }; /* { dg-error "31:empty index range in initializer" } */
47 __extension__ int a16[10] = {[2 ... 100] = 4 }; /* { dg-error "31:array index range in initializer exceeds array bounds" } */
48 int a17[] = { .B = 1 }; /* { dg-error "15:field name not in record or union initializer" } */
49 int a18[] = { e }; /* { dg-error "15:initializer element is not constant" } */
50 char a19[1] = { "x", "x" }; /* { dg-error "22:excess elements in char array initializer" } */
52 void
53 bar (void)
55 struct f f = { 2, "c" }; /* { dg-error "21:non-static initialization of a flexible array member" } */
58 struct
60 char *v;
61 } sx[] = { .v = 0 }; /* { dg-error "12:field name not in record or union initializer" } */