2009-03-24 10:24:46 +08:00
|
|
|
// RUN: clang-cc %s -fsyntax-only -verify
|
2008-02-21 09:42:41 +08:00
|
|
|
|
|
|
|
#define _AS1 __attribute__((address_space(1)))
|
|
|
|
#define _AS2 __attribute__((address_space(2)))
|
|
|
|
#define _AS3 __attribute__((address_space(3)))
|
|
|
|
|
|
|
|
void foo(_AS3 float *a) {
|
2009-02-28 02:53:28 +08:00
|
|
|
_AS2 *x;// expected-warning {{type specifier missing, defaults to 'int'}}
|
2008-02-21 09:42:41 +08:00
|
|
|
_AS1 float * _AS2 *B;
|
|
|
|
|
2008-03-15 02:07:10 +08:00
|
|
|
int _AS1 _AS2 *Y; // expected-error {{multiple address spaces specified for type}}
|
2008-02-21 09:42:41 +08:00
|
|
|
int *_AS1 _AS2 *Z; // expected-error {{multiple address spaces specified for type}}
|
|
|
|
|
2008-03-15 02:07:10 +08:00
|
|
|
_AS1 int local; // expected-error {{automatic variable qualified with an address space}}
|
2008-03-26 02:36:32 +08:00
|
|
|
_AS1 int array[5]; // expected-error {{automatic variable qualified with an address space}}
|
|
|
|
_AS1 int arrarr[5][5]; // expected-error {{automatic variable qualified with an address space}}
|
2008-03-14 08:22:18 +08:00
|
|
|
|
2009-07-28 14:52:18 +08:00
|
|
|
__attribute__((address_space(-1))) int *_boundsA; // expected-error {{address space is negative}}
|
|
|
|
__attribute__((address_space(0xFFFFFF))) int *_boundsB;
|
|
|
|
__attribute__((address_space(0x1000000))) int *_boundsC; // expected-error {{address space is larger than the maximum supported}}
|
|
|
|
// chosen specifically to overflow 32 bits and come out reasonable
|
|
|
|
__attribute__((address_space(4294967500))) int *_boundsD; // expected-error {{address space is larger than the maximum supported}}
|
|
|
|
|
2008-02-21 09:42:41 +08:00
|
|
|
*a = 5.0f;
|
|
|
|
}
|
2009-01-12 08:08:58 +08:00
|
|
|
|
|
|
|
struct _st {
|
|
|
|
int x, y;
|
|
|
|
} s __attribute ((address_space(1))) = {1, 1};
|
|
|
|
|
2009-04-13 14:04:39 +08:00
|
|
|
|
|
|
|
// rdar://6774906
|
|
|
|
__attribute__((address_space(256))) void * * const base = 0;
|
|
|
|
void * get_0(void) {
|
|
|
|
return base[0]; // expected-error {{illegal implicit cast between two pointers with different address spaces}} \
|
|
|
|
expected-warning {{returning 'void __attribute__((address_space(256)))*' discards qualifiers, expected 'void *'}}
|
|
|
|
}
|
|
|
|
|