URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Go to most recent revision |
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
689 |
jeremybenn |
/* 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" } */
|
6 |
|
|
|
7 |
|
|
void f(void);
|
8 |
|
|
void g(void) = f; /* { dg-error "function 'g' is initialized like a variable" } */
|
9 |
|
|
|
10 |
|
|
void h(a)
|
11 |
|
|
int a = 1; /* { dg-error "parameter 'a' is initialized" } */
|
12 |
|
|
{
|
13 |
|
|
struct s x = { 0 }; /* { dg-error "variable 'x' has initializer but incomplete type" } */
|
14 |
|
|
/* { dg-error "excess elements|near init" "near" { target *-*-* } 13 } */
|
15 |
|
|
/* { dg-error "storage size" "size" { target *-*-* } 13 } */
|
16 |
|
|
}
|
17 |
|
|
|
18 |
|
|
char s[1] = "x";
|
19 |
|
|
char s1[1] = { "x" };
|
20 |
|
|
char t[1] = "xy"; /* { dg-error "initializer-string for array of chars is too long" } */
|
21 |
|
|
char t1[1] = { "xy" }; /* { dg-error "initializer-string for array of chars is too long" } */
|
22 |
|
|
char u[1] = { "x", "x" }; /* { dg-error "excess elements in char array initializer" } */
|
23 |
|
|
/* { dg-error "near init" "near" { target *-*-* } 22 } */
|
24 |
|
|
|
25 |
|
|
int j = { 1 };
|
26 |
|
|
|
27 |
|
|
int k = { 1, 2 }; /* { dg-error "excess elements in scalar initializer" } */
|
28 |
|
|
/* { dg-error "near init" "near" { target *-*-* } 27 } */
|
29 |
|
|
|
30 |
|
|
int a1[1] = { [1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */
|
31 |
|
|
/* { dg-error "near init" "near" { target *-*-* } 30 } */
|
32 |
|
|
int a2[1] = { [-1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */
|
33 |
|
|
/* { dg-error "near init" "near" { target *-*-* } 32 } */
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.