PR middle-end/77674
[official-gcc.git] / gcc / testsuite / c-c++-common / Wcast-qual-1.c
blob640e4f0b683c21ab53ac1103dfaf42f2248eb0f1
1 /* { dg-do compile } */
2 /* { dg-options "-Wcast-qual" } */
4 void
5 f1 (void *bar)
7 const void *p1 = (const void *) bar;
8 const char *p2 = (const char *) bar;
9 const void **p3 = (const void **) bar;
10 const char **p4 = (const char **) bar;
11 const void * const *p5 = (const void * const *) bar;
12 const char * const *p6 = (const char * const *) bar;
13 void * const *p7 = (void * const *) bar;
14 char * const *p8 = (char * const *) bar;
15 const void ***p9 = (const void ***) bar;
16 const char ***p10 = (const char ***) bar;
17 void * const **p11 = (void * const **) bar;
18 char * const **p12 = (char * const **) bar;
19 void ** const *p13 = (void ** const *) bar;
20 char ** const *p14 = (char ** const *) bar;
21 const void * const **p15 = (const void * const **) bar;
22 const char * const **p16 = (const char * const **) bar;
23 const void ** const *p17 = (const void ** const *) bar;
24 const char ** const *p18 = (const char ** const *) bar;
25 void * const * const * p19 = (void * const * const *) bar;
26 char * const * const * p20 = (char * const * const *) bar;
27 const void * const * const *p21 = (const void * const * const *) bar;
28 const char * const * const *p22 = (const char * const * const *) bar;
31 void
32 f2 (void **bar)
34 const void *p1 = (const void *) bar;
35 const char *p2 = (const char *) bar;
36 const void **p3 = (const void **) bar; /* { dg-warning "cast" } */
37 const char **p4 = (const char **) bar;
38 const void * const *p5 = (const void * const *) bar;
39 const char * const *p6 = (const char * const *) bar;
40 void * const *p7 = (void * const *) bar;
41 char * const *p8 = (char * const *) bar;
42 const void ***p9 = (const void ***) bar;
43 const char ***p10 = (const char ***) bar;
44 void * const **p11 = (void * const **) bar;
45 char * const **p12 = (char * const **) bar;
46 void ** const *p13 = (void ** const *) bar;
47 char ** const *p14 = (char ** const *) bar;
48 const void * const **p15 = (const void * const **) bar;
49 const char * const **p16 = (const char * const **) bar;
50 const void ** const *p17 = (const void ** const *) bar;
51 const char ** const *p18 = (const char ** const *) bar;
52 void * const * const * p19 = (void * const * const *) bar;
53 char * const * const * p20 = (char * const * const *) bar;
54 const void * const * const *p21 = (const void * const * const *) bar;
55 const char * const * const *p22 = (const char * const * const *) bar;
58 void
59 f3 (void ***bar)
61 const void *p1 = (const void *) bar;
62 const char *p2 = (const char *) bar;
63 const void **p3 = (const void **) bar;
64 const char **p4 = (const char **) bar;
65 const void * const *p5 = (const void * const *) bar;
66 const char * const *p6 = (const char * const *) bar;
67 void * const *p7 = (void * const *) bar;
68 char * const *p8 = (char * const *) bar;
69 const void ***p9 = (const void ***) bar; /* { dg-warning "cast" } */
70 const char ***p10 = (const char ***) bar;
71 void * const **p11 = (void * const **) bar; /* { dg-warning "cast" } */
72 char * const **p12 = (char * const **) bar;
73 void ** const *p13 = (void ** const *) bar;
74 char ** const *p14 = (char ** const *) bar;
75 const void * const **p15 = (const void * const **) bar; /* { dg-warning "cast" } */
76 const char * const **p16 = (const char * const **) bar;
77 const void ** const *p17 = (const void ** const *) bar; /* { dg-warning "cast" } */
78 const char ** const *p18 = (const char ** const *) bar;
79 void * const * const * p19 = (void * const * const *) bar;
80 char * const * const * p20 = (char * const * const *) bar;
81 const void * const * const *p21 = (const void * const * const *) bar;
82 const char * const * const *p22 = (const char * const * const *) bar;
85 void
86 f4 (void * const **bar)
88 const void ***p9 = (const void ***) bar; /* { dg-warning "cast" } */
89 void * const **p11 = (void * const **) bar;
90 void ** const *p13 = (void ** const *) bar; /* { dg-warning "cast" } */
91 const void * const **p15 = (const void * const **) bar; /* { dg-warning "cast" } */
92 const void ** const *p17 = (const void ** const *) bar; /* { dg-warning "cast" } */
93 void * const * const * p19 = (void * const * const *) bar;
94 const void * const * const *p21 = (const void * const * const *) bar;
97 void
98 f5 (char ***bar)
100 volatile const char ***p9 = (volatile const char ***) bar; /* { dg-warning "cast" } */
101 volatile char * const **p11 = (volatile char * const **) bar; /* { dg-warning "cast" } */
102 volatile char ** const *p13 = (volatile char ** const *) bar; /* { dg-warning "cast" } */
103 volatile const char * const **p15 = (volatile const char * const **) bar; /* { dg-warning "cast" } */
104 volatile const char ** const *p17 = (volatile const char ** const *) bar; /* { dg-warning "cast" } */
105 volatile char * const * const * p19 = (volatile char * const * const *) bar;
106 volatile const char * const * const *p21 = (volatile const char * const * const *) bar;
109 void
110 f6 (char ***bar)
112 const char * volatile **p9 = (const char * volatile **) bar; /* { dg-warning "cast" } */
113 char * volatile const **p11 = (char * volatile const **) bar; /* { dg-warning "cast" } */
114 char * volatile * const *p13 = (char * volatile * const *) bar;
115 const char * volatile const **p15 = (const char * volatile const **) bar; /* { dg-warning "cast" } */
116 const char * volatile * const *p17 = (const char * volatile * const *) bar; /* { dg-warning "cast" } */
117 char * volatile const * const * p19 = (char * volatile const * const *) bar;
118 const char * volatile const * const *p21 = (const char * volatile const * const *) bar;
121 void
122 f7 (char ***bar)
124 const char ** volatile *p9 = (const char ** volatile *) bar; /* { dg-warning "cast" } */
125 char * const * volatile *p11 = (char * const * volatile *) bar; /* { dg-warning "cast" } */
126 char ** volatile const *p13 = (char ** volatile const *) bar;
127 const char * const * volatile *p15 = (const char * const * volatile *) bar; /* { dg-warning "cast" } */
128 const char ** volatile const *p17 = (const char ** volatile const *) bar; /* { dg-warning "cast" } */
129 char * const * volatile const * p19 = (char * const * volatile const *) bar;
130 const char * const * volatile const *p21 = (const char * const * volatile const *) bar;
133 typedef int (intfn) (int);
134 typedef intfn *pintfn;
135 typedef const intfn *constfn;
137 void
138 f8 (constfn ***bar)
140 const constfn *p1 = (const constfn *) bar;
141 const pintfn *p2 = (const pintfn *) bar;
142 const constfn **p3 = (const constfn **) bar;
143 const pintfn **p4 = (const pintfn **) bar;
144 const constfn * const *p5 = (const constfn * const *) bar;
145 const pintfn * const *p6 = (const pintfn * const *) bar;
146 constfn * const *p7 = (constfn * const *) bar;
147 pintfn * const *p8 = (pintfn * const *) bar;
148 const constfn ***p9 = (const constfn ***) bar; /* { dg-warning "cast" } */
149 const pintfn ***p10 = (const pintfn ***) bar; /* { dg-warning "cast" } */
150 constfn * const **p11 = (constfn * const **) bar; /* { dg-warning "cast" } */
151 pintfn * const **p12 = (pintfn * const **) bar; /* { dg-warning "cast" } */
152 constfn ** const *p13 = (constfn ** const *) bar;
153 pintfn ** const *p14 = (pintfn ** const *) bar;
154 const constfn * const **p15 = (const constfn * const **) bar; /* { dg-warning "cast" } */
155 const pintfn * const **p16 = (const pintfn * const **) bar; /* { dg-warning "cast" } */
156 const constfn ** const *p17 = (const constfn ** const *) bar; /* { dg-warning "cast" } */
157 const pintfn ** const *p18 = (const pintfn ** const *) bar; /* { dg-warning "cast" } */
158 constfn * const * const * p19 = (constfn * const * const *) bar;
159 pintfn * const * const * p20 = (pintfn * const * const *) bar;
160 const constfn * const * const *p21 = (const constfn * const * const *) bar;
161 const pintfn * const * const *p22 = (const pintfn * const * const *) bar;