summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c99-arraydecl-1.c
blob: 2036d82fbd9e1e3b2daf75e3025fba7326c42703 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* Test for C99 forms of array declarator.  */
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */

/* Because GCC doesn't yet implement it, we don't yet test for [*] here.  */

/* Test each of: [quals], [quals expr], [static expr], [static quals expr],
   [quals static expr].  Not yet: [quals *].  */

void f00 (int a[const]);
void f01 (int [const]);

void
f02 (int a[const])
{
  int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
  /* { dg-error "discards" "discards quals" { target *-*-* } 17 } */
  int *const *c = &a;
}
void
f03 (a)
     int a[const];
{
  int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
  /* { dg-error "discards" "discards quals" { target *-*-* } 25 } */
  int *const *c = &a;
}

void f10 (int a[const 2]);
void f11 (int [const 2]);

void
f12 (int a[const 2])
{
  int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
  /* { dg-error "discards" "discards quals" { target *-*-* } 36 } */
  int *const *c = &a;
}
void
f13 (a)
     int a[const 2];
{
  int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
  /* { dg-error "discards" "discards quals" { target *-*-* } 44 } */
  int *const *c = &a;
}

void f20 (int a[static 2]);
void f21 (int [static 2]);

void
f22 (int a[static 2])
{
  int **b = &a;
  int *const *c = &a;
}
void
f23 (a)
     int a[static 2];
{
  int **b = &a;
  int *const *c = &a;
}

void f30 (int a[static const 2]);
void f31 (int [static const 2]);

void
f32 (int a[static const 2])
{
  int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
  /* { dg-error "discards" "discards quals" { target *-*-* } 72 } */
  int *const *c = &a;
}
void
f33 (a)
     int a[static const 2];
{
  int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
  /* { dg-error "discards" "discards quals" { target *-*-* } 80 } */
  int *const *c = &a;
}

void f40 (int a[const static 2]);
void f41 (int [const static 2]);

void
f42 (int a[const static 2])
{
  int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
  /* { dg-error "discards" "discards quals" { target *-*-* } 91 } */
  int *const *c = &a;
}
void
f43 (a)
     int a[const static 2];
{
  int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */
  /* { dg-error "discards" "discards quals" { target *-*-* } 99 } */
  int *const *c = &a;
}

/* Test rejection of static and type qualifiers in non-parameter contexts.  */
int x[const 2]; /* { dg-bogus "warning" "warning in place of error" } */
/* { dg-error "non-parameter" "quals in non-parm array" { target *-*-* } 105 } */
int y[static 2]; /* { dg-bogus "warning" "warning in place of error" } */
/* { dg-error "non-parameter" "static in non-parm array" { target *-*-* } 107 } */
void g (int a[static 2][3]);
void h (int a[2][static 3]); /* { dg-bogus "warning" "warning in place of error" } */
/* { dg-error "non-parameter" "static in non-final parm array" { target *-*-* } 110 } */