Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / gcc.dg / init-bad-3.c
blobc22e8ec669818602f7cd9907c1a9e7650cb0b56e
1 /* Test diagnostics for various bad initializers. Test cases with
2 standard syntax with -pedantic-errors. */
3 /* Origin: Joseph Myers <joseph@codesourcery.com> */
4 /* { dg-do compile } */
5 /* { dg-options "-std=gnu99 -pedantic-errors" } */
7 void f(void);
8 void g(void) = f; /* { dg-error "function 'g' is initialized like a variable" } */
10 void h(a)
11 int a = 1; /* { dg-error "parameter 'a' is initialized" } */
13 struct s x = { 0 }; /* { dg-error "variable 'x' has initializer but incomplete type" } */
14 /* { dg-message "excess elements|near init" "near" { target *-*-* } .-1 } */
15 /* { dg-error "storage size" "size" { target *-*-* } .-2 } */
18 char s[1] = "x";
19 char s1[1] = { "x" };
20 char t[1] = "xy"; /* { dg-error "initializer-string for array of 'char' is too long" } */
21 char t1[1] = { "xy" }; /* { dg-error "initializer-string for array of 'char' is too long" } */
22 char u[1] = { "x", "x" }; /* { dg-error "excess elements in 'char.1.' initializer" } */
23 /* { dg-message "near init" "near" { target *-*-* } .-1 } */
25 int j = { 1 };
27 int k = { 1, 2 }; /* { dg-error "excess elements in scalar initializer" } */
28 /* { dg-message "near init" "near" { target *-*-* } .-1 } */
30 int a1[1] = { [1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */
31 /* { dg-message "near init" "near" { target *-*-* } .-1 } */
32 int a2[1] = { [-1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */
33 /* { dg-message "near init" "near" { target *-*-* } .-1 } */