blob: 616f3fcda1a28ed1aeafb610036e69cdd35f5693 [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc %s -fsyntax-only -verify
Chris Lattner73804662008-02-21 01:42:41 +00002
3#define _AS1 __attribute__((address_space(1)))
4#define _AS2 __attribute__((address_space(2)))
5#define _AS3 __attribute__((address_space(3)))
6
7void foo(_AS3 float *a) {
Chris Lattner35d276f2009-02-27 18:53:28 +00008 _AS2 *x;// expected-warning {{type specifier missing, defaults to 'int'}}
Chris Lattner73804662008-02-21 01:42:41 +00009 _AS1 float * _AS2 *B;
10
Nate Begemanc8e89a82008-03-14 18:07:10 +000011 int _AS1 _AS2 *Y; // expected-error {{multiple address spaces specified for type}}
Chris Lattner73804662008-02-21 01:42:41 +000012 int *_AS1 _AS2 *Z; // expected-error {{multiple address spaces specified for type}}
13
Nate Begemanc8e89a82008-03-14 18:07:10 +000014 _AS1 int local; // expected-error {{automatic variable qualified with an address space}}
Nate Begeman8e7dafe2008-03-25 18:36:32 +000015 _AS1 int array[5]; // expected-error {{automatic variable qualified with an address space}}
16 _AS1 int arrarr[5][5]; // expected-error {{automatic variable qualified with an address space}}
Nate Begeman5af27e02008-03-14 00:22:18 +000017
John McCallefadb772009-07-28 06:52:18 +000018 __attribute__((address_space(-1))) int *_boundsA; // expected-error {{address space is negative}}
19 __attribute__((address_space(0xFFFFFF))) int *_boundsB;
20 __attribute__((address_space(0x1000000))) int *_boundsC; // expected-error {{address space is larger than the maximum supported}}
21 // chosen specifically to overflow 32 bits and come out reasonable
22 __attribute__((address_space(4294967500))) int *_boundsD; // expected-error {{address space is larger than the maximum supported}}
23
Chris Lattner73804662008-02-21 01:42:41 +000024 *a = 5.0f;
25}
Chris Lattner863ea9a2009-01-12 00:08:58 +000026
27struct _st {
28 int x, y;
29} s __attribute ((address_space(1))) = {1, 1};
30
Chris Lattnerecca7532009-04-13 06:04:39 +000031
32// rdar://6774906
33__attribute__((address_space(256))) void * * const base = 0;
34void * get_0(void) {
35 return base[0]; // expected-error {{illegal implicit cast between two pointers with different address spaces}} \
John McCall0953e762009-09-24 19:53:00 +000036 expected-warning {{returning 'void __attribute__((address_space(256))) *' discards qualifiers, expected 'void *'}}
Chris Lattnerecca7532009-04-13 06:04:39 +000037}
38