File: pr61096-1.c

package info (click to toggle)
gcc-riscv64-unknown-elf 8.3.0.2019.08%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 680,956 kB
  • sloc: ansic: 3,237,715; cpp: 896,882; ada: 772,854; f90: 144,254; asm: 68,788; makefile: 67,456; sh: 29,743; exp: 28,045; objc: 15,273; fortran: 11,885; python: 7,369; pascal: 5,375; awk: 3,725; perl: 2,872; yacc: 316; xml: 311; ml: 285; lex: 198; haskell: 122
file content (61 lines) | stat: -rw-r--r-- 3,007 bytes parent folder | download | duplicates (4)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
/* PR c/61077 */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -fshort-enums -fshort-wchar -Wpedantic" } */
/* { dg-prune-output ".*near initialization for.*" } */

typedef enum { A } schar;
extern int e;
struct S
{
  int a[3];
};
struct f
{
  int w;
  int x[];
};
struct g
{
  struct f f; /* { dg-warning "invalid use of structure with flexible array member" } */
};

char w1[] = L"foo"; /* { dg-error "13:char-array initialized from wide string" } */
__WCHAR_TYPE__ w2[] = "foo"; /* { dg-error "23:wide character array initialized from non-wide string" } */
__WCHAR_TYPE__ w3[] = U"foo"; /* { dg-error "23:wide character array initialized from incompatible wide string" } */
schar a1[] = "foo"; /* { dg-error "14:array of inappropriate type initialized from string constant" } */
int a2[] = (int[]) { 1 }; /* { dg-warning "12:initializer element is not constant" } */

int a3 = e; /* { dg-error "10:initializer element is not constant" } */
int a4 = (e, 1); /* { dg-error "10:initializer element is not constant" } */
int a5 = a1[0]; /* { dg-error "10:initializer element is not constant" } */
int a6 = &a3 - &a4; /* { dg-error "10:initializer element is not" } */
int a7[] = a7; /* { dg-error "12:invalid initializer" } */

struct S s = { { 1 }, { 3 } }; /* { dg-error "23:extra brace group at end of initializer" } */
/* { dg-warning "23:excess elements in struct initializer" "" { target *-*-* } .-1 } */
struct g g1 = { {0, { 1 } } }; /* { dg-error "21:initialization of flexible array member in a nested context" } */
struct g g2 = { .f[0] = 1 }; /* { dg-error "20:array index in non-array initializer" } */

__extension__ int a8 = { }; /* { dg-error "24:empty scalar initializer" } */
int a9[10] = {[1.2] = 2 }; /* { dg-error "16:array index in initializer not of integer type" } */
int a10[10] = {[e] = 2 }; /* { dg-error "17:nonconstant array index in initializer" } */
__extension__ int a11[10] = {[1 ... e] = 1 }; /* { dg-error "31:nonconstant array index in initializer" } */
int a12 = {[1] = 2 }; /* { dg-error "13:array index in non-array initializer" } */
int a13[2] = {[-1] = 4 }; /* { dg-error "16:array index in initializer exceeds array bounds" } */
int a14[2] = {[64] = 4 }; /* { dg-error "16:array index in initializer exceeds array bounds" } */
__extension__ int a15[10] = {[2 ... 1] = 4 }; /* { dg-error "31:empty index range in initializer" } */
__extension__ int a16[10] = {[2 ... 100] = 4 }; /* { dg-error "31:array index range in initializer exceeds array bounds" } */
int a17[] = { .B = 1 }; /* { dg-error "15:field name not in record or union initializer" } */
int a18[] = { e }; /* { dg-error "15:initializer element is not constant" } */
char a19[1] = { "x", "x" }; /* { dg-error "22:excess elements in char array initializer" } */

void
bar (void)
{
  struct f f = { 2, "c" }; /* { dg-error "21:non-static initialization of a flexible array member" } */
}

struct
{
  char *v;
} sx[] = { .v = 0 }; /* { dg-error "12:field name not in record or union initializer" } */