1 |
149 |
jeremybenn |
/* Test for C99 forms of array declarator. */
|
2 |
|
|
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
|
3 |
|
|
/* { dg-do compile } */
|
4 |
|
|
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
|
5 |
|
|
|
6 |
|
|
/* Because GCC doesn't yet implement it, we don't yet test for [*] here. */
|
7 |
|
|
|
8 |
|
|
/* Test each of: [quals], [quals expr], [static expr], [static quals expr],
|
9 |
|
|
[quals static expr]. Not yet: [quals *]. */
|
10 |
|
|
|
11 |
|
|
void f00 (int a[const]);
|
12 |
|
|
void f01 (int [const]); /* { dg-bogus "warning" "warning in place of error" } */
|
13 |
|
|
/* { dg-error "abstract" "\[quals\] in abstract declarator" { target *-*-* } 12 } */
|
14 |
|
|
void
|
15 |
|
|
f02 (int a[const])
|
16 |
|
|
{
|
17 |
|
|
int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
|
18 |
|
|
/* { dg-error "discards" "discards quals" { target *-*-* } 17 } */
|
19 |
|
|
int *const *c = &a;
|
20 |
|
|
}
|
21 |
|
|
void
|
22 |
|
|
f03 (a)
|
23 |
|
|
int a[const];
|
24 |
|
|
{
|
25 |
|
|
int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
|
26 |
|
|
/* { dg-error "discards" "discards quals" { target *-*-* } 25 } */
|
27 |
|
|
int *const *c = &a;
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
void f10 (int a[const 2]);
|
31 |
|
|
void f11 (int [const 2]); /* { dg-bogus "warning" "warning in place of error" } */
|
32 |
|
|
/* { dg-error "abstract" "\[quals expr\] in abstract declarator" { target *-*-* } 31 } */
|
33 |
|
|
void
|
34 |
|
|
f12 (int a[const 2])
|
35 |
|
|
{
|
36 |
|
|
int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
|
37 |
|
|
/* { dg-error "discards" "discards quals" { target *-*-* } 36 } */
|
38 |
|
|
int *const *c = &a;
|
39 |
|
|
}
|
40 |
|
|
void
|
41 |
|
|
f13 (a)
|
42 |
|
|
int a[const 2];
|
43 |
|
|
{
|
44 |
|
|
int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
|
45 |
|
|
/* { dg-error "discards" "discards quals" { target *-*-* } 44 } */
|
46 |
|
|
int *const *c = &a;
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
void f20 (int a[static 2]);
|
50 |
|
|
void f21 (int [static 2]); /* { dg-bogus "warning" "warning in place of error" } */
|
51 |
|
|
/* { dg-error "abstract" "\[static expr\] in abstract declarator" { target *-*-* } 50 } */
|
52 |
|
|
void
|
53 |
|
|
f22 (int a[static 2])
|
54 |
|
|
{
|
55 |
|
|
int **b = &a;
|
56 |
|
|
int *const *c = &a;
|
57 |
|
|
}
|
58 |
|
|
void
|
59 |
|
|
f23 (a)
|
60 |
|
|
int a[static 2];
|
61 |
|
|
{
|
62 |
|
|
int **b = &a;
|
63 |
|
|
int *const *c = &a;
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
void f30 (int a[static const 2]);
|
67 |
|
|
void f31 (int [static const 2]); /* { dg-bogus "warning" "warning in place of error" } */
|
68 |
|
|
/* { dg-error "abstract" "\[static quals expr\] in abstract declarator" { target *-*-* } 67 } */
|
69 |
|
|
void
|
70 |
|
|
f32 (int a[static const 2])
|
71 |
|
|
{
|
72 |
|
|
int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
|
73 |
|
|
/* { dg-error "discards" "discards quals" { target *-*-* } 72 } */
|
74 |
|
|
int *const *c = &a;
|
75 |
|
|
}
|
76 |
|
|
void
|
77 |
|
|
f33 (a)
|
78 |
|
|
int a[static const 2];
|
79 |
|
|
{
|
80 |
|
|
int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
|
81 |
|
|
/* { dg-error "discards" "discards quals" { target *-*-* } 80 } */
|
82 |
|
|
int *const *c = &a;
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
void f40 (int a[const static 2]);
|
86 |
|
|
void f41 (int [const static 2]); /* { dg-bogus "warning" "warning in place of error" } */
|
87 |
|
|
/* { dg-error "abstract" "\[quals static expr\] in abstract declarator" { target *-*-* } 86 } */
|
88 |
|
|
void
|
89 |
|
|
f42 (int a[const static 2])
|
90 |
|
|
{
|
91 |
|
|
int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
|
92 |
|
|
/* { dg-error "discards" "discards quals" { target *-*-* } 91 } */
|
93 |
|
|
int *const *c = &a;
|
94 |
|
|
}
|
95 |
|
|
void
|
96 |
|
|
f43 (a)
|
97 |
|
|
int a[const static 2];
|
98 |
|
|
{
|
99 |
|
|
int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
|
100 |
|
|
/* { dg-error "discards" "discards quals" { target *-*-* } 99 } */
|
101 |
|
|
int *const *c = &a;
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
/* Test rejection of static and type qualifiers in non-parameter contexts. */
|
105 |
|
|
int x[const 2]; /* { dg-bogus "warning" "warning in place of error" } */
|
106 |
|
|
/* { dg-error "non-parameter" "quals in non-parm array" { target *-*-* } 105 } */
|
107 |
|
|
int y[static 2]; /* { dg-bogus "warning" "warning in place of error" } */
|
108 |
|
|
/* { dg-error "non-parameter" "static in non-parm array" { target *-*-* } 107 } */
|
109 |
|
|
void g (int a[static 2][3]);
|
110 |
|
|
void h (int a[2][static 3]); /* { dg-bogus "warning" "warning in place of error" } */
|
111 |
|
|
/* { dg-error "non-parameter" "static in non-final parm array" { target *-*-* } 110 } */
|