1/* 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
11void f00 (int a[const]);
12void f01 (int [const]); /* { dg-bogus "warning" "warning in place of error" } */
13/* { dg-error "abstract" "\[quals\] in abstract declarator" { target *-*-* } 12 } */
14void
15f02 (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}
21void
22f03 (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
30void f10 (int a[const 2]);
31void f11 (int [const 2]); /* { dg-bogus "warning" "warning in place of error" } */
32/* { dg-error "abstract" "\[quals expr\] in abstract declarator" { target *-*-* } 31 } */
33void
34f12 (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}
40void
41f13 (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
49void f20 (int a[static 2]);
50void f21 (int [static 2]); /* { dg-bogus "warning" "warning in place of error" } */
51/* { dg-error "abstract" "\[static expr\] in abstract declarator" { target *-*-* } 50 } */
52void
53f22 (int a[static 2])
54{
55  int **b = &a;
56  int *const *c = &a;
57}
58void
59f23 (a)
60     int a[static 2];
61{
62  int **b = &a;
63  int *const *c = &a;
64}
65
66void f30 (int a[static const 2]);
67void 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 } */
69void
70f32 (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}
76void
77f33 (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
85void f40 (int a[const static 2]);
86void 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 } */
88void
89f42 (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}
95void
96f43 (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.  */
105int x[const 2]; /* { dg-bogus "warning" "warning in place of error" } */
106/* { dg-error "non-parameter" "quals in non-parm array" { target *-*-* } 105 } */
107int y[static 2]; /* { dg-bogus "warning" "warning in place of error" } */
108/* { dg-error "non-parameter" "static in non-parm array" { target *-*-* } 107 } */
109void g (int a[static 2][3]);
110void 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 } */
112