File: pedwarn-init.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 (20 lines) | stat: -rw-r--r-- 1,337 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wpedantic" } */
/* { dg-prune-output ".*near initialization for.*" } */

typedef unsigned vec __attribute__ ((vector_size (2 * sizeof (int))));
union u { int a; double d; };
struct S { int i; char fam[]; };

int i;
vec v = { 1, 2, 3 }; /* { dg-warning "17:excess elements in vector initializer" } */
int a1 = { 1, 2 }; /* { dg-warning "15:excess elements in scalar initializer" } */
int a2[2] = { 1, 2, 3 }; /* { dg-warning "21:excess elements in array initializer" } */
int a3[] = { [1 ? 1 : i] = 0 }; /* { dg-warning "15:array index in initializer is not an integer constant expression" } */
int a4[] = { [1 ... 1 ? 2 : i] = 0 }; /* { dg-warning "15:array index in initializer is not an integer constant expression" } */
/* { dg-warning "ISO C forbids" "ISO C" { target *-*-* } .-1 } */
char a5[] = ("lol"); /* { dg-warning "13:array initialized from parenthesized string constant" } */
char a6[] = { ("foo") }; /* { dg-warning "13:array initialized from parenthesized string constant" } */
char *a7 = (char []) { ("bar") }; /* { dg-warning "12:array initialized from parenthesized string constant" } */
union u u = { 1, 1.0 }; /* { dg-warning "18:excess elements in union initializer" } */
struct S s = { 1, 2 }; /* { dg-warning "14:initialization of a flexible array member" } */