| 1 |
/* Test qualifier preservation of typeof and discarded for __auto_type. */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-std=c11" } */ |
| 4 |
|
| 5 |
/* Check that the qualifiers are preserved for atomic types. */ |
| 6 |
|
| 7 |
extern int i; |
| 8 |
|
| 9 |
extern int * p; |
| 10 |
|
| 11 |
extern int _Atomic const ci; |
| 12 |
extern __typeof (ci) ci; |
| 13 |
|
| 14 |
extern int _Atomic volatile vi; |
| 15 |
extern __typeof (vi) vi; |
| 16 |
|
| 17 |
extern int * _Atomic restrict ri; |
| 18 |
extern __typeof (ri) ri; |
| 19 |
|
| 20 |
/* Check that the qualifiers are discarded for atomic types. */ |
| 21 |
|
| 22 |
void f(void) |
| 23 |
{ |
| 24 |
__auto_type aci = ci; |
| 25 |
int *paci = &aci; |
| 26 |
|
| 27 |
__auto_type avi = vi; |
| 28 |
int *pavi = &avi; |
| 29 |
|
| 30 |
__auto_type ari = ri; |
| 31 |
int **pari = &ari; |
| 32 |
} |
| 33 |
|
| 34 |
/* Check that the qualifiers are preserved for non-atomic types. */ |
| 35 |
|
| 36 |
extern int const j; |
| 37 |
|
| 38 |
extern int volatile k; |
| 39 |
|
| 40 |
extern int * restrict q; |
| 41 |
|
| 42 |
extern int const nci; |
| 43 |
extern __typeof (nci) j; |
| 44 |
|
| 45 |
extern int volatile nvi; |
| 46 |
extern __typeof (nvi) k; |
| 47 |
|
| 48 |
extern int * restrict nri; |
| 49 |
extern __typeof (nri) q; |
| 50 |
|
| 51 |
/* Check that the qualifiers are discarded for non-atomic types. */ |
| 52 |
|
| 53 |
void g(void) |
| 54 |
{ |
| 55 |
__auto_type aci = nci; |
| 56 |
int *paci = &aci; |
| 57 |
|
| 58 |
__auto_type avi = nvi; |
| 59 |
int *pavi = &avi; |
| 60 |
|
| 61 |
__auto_type ari = nri; |
| 62 |
int **pari = &ari; |
| 63 |
} |