1 /* Tests usage of const qualifier.
6 const char const_char
= 123; /* constant char */
7 const char * const_char_ptr
; /* pointer to constant char */
8 char * const char_ptr_const
= &k
; /* constant pointer to char */
9 const char * const const_char_ptr_const
= &const_char
;
10 /* constant pointer to constant char */
11 char char_array
[3]; /* array of char */
12 const char const_char_array
[] = {1,2,3}; /* array of constant char */
13 const char ** const_char_ptr_ptr
; /* pointer to pointer to constant char */
24 /* Since const_char_ptr is in itself not constant, we can change it */
25 const_char_ptr
= const_char_array
;
27 ASSERT(*const_char_ptr
== 2);
29 /* Check for bug #621531 */
30 const_char_ptr
= const_char_array
;
31 ASSERT(const_char_ptr
[0] == 1);
34 /* Since char_ptr_const is constant, we cannot change it. However, */
35 /* we can change the object that it points to. */
37 ASSERT(ident(*char_ptr_const
)==5);
39 ASSERT(ident(*char_ptr_const
)==6);
41 /* We can't modify const_char_ptr_const or the object that it points */
42 /* to. Unfortunately, we can't test that compiler enforces these */
43 /* restriction, so just verify its initialization. */
44 ASSERT(*const_char_ptr_const
== const_char
);
46 /* We can change const_char_ptr_ptr or the object that it points to. */
47 const_char_ptr
= const_char_array
;
48 const_char_ptr_ptr
= &const_char_ptr
;
49 ASSERT(ident(**const_char_ptr_ptr
)==1);
50 (*const_char_ptr_ptr
)++;
51 ASSERT(ident(**const_char_ptr_ptr
)==2);