summaryrefslogtreecommitdiff
path: root/clang/test/Sema/address_spaces.c
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
committerCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
commitbe1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch)
tree1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/Sema/address_spaces.c
parentc4626a62754862d20b41e8a46a3574264ea80e6d (diff)
parentf1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff)
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/Sema/address_spaces.c')
-rw-r--r--clang/test/Sema/address_spaces.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/clang/test/Sema/address_spaces.c b/clang/test/Sema/address_spaces.c
new file mode 100644
index 0000000..24799da
--- /dev/null
+++ b/clang/test/Sema/address_spaces.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+#define _AS1 __attribute__((address_space(1)))
+#define _AS2 __attribute__((address_space(2)))
+#define _AS3 __attribute__((address_space(3)))
+
+void bar(_AS2 int a); // expected-error {{parameter may not be qualified with an address space}}
+
+void foo(_AS3 float *a,
+ _AS1 float b) // expected-error {{parameter may not be qualified with an address space}}
+{
+ _AS2 *x;// expected-warning {{type specifier missing, defaults to 'int'}}
+ _AS1 float * _AS2 *B;
+
+ int _AS1 _AS2 *Y; // expected-error {{multiple address spaces specified for type}}
+ int *_AS1 _AS2 *Z; // expected-error {{multiple address spaces specified for type}}
+
+ _AS1 int local; // expected-error {{automatic variable qualified with an address space}}
+ _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}}
+
+ __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}}
+
+ *a = 5.0f + b;
+}
+
+struct _st {
+ int x, y;
+} s __attribute ((address_space(1))) = {1, 1};
+
+
+// rdar://6774906
+__attribute__((address_space(256))) void * * const base = 0;
+void * get_0(void) {
+ return base[0]; // expected-error {{returning '__attribute__((address_space(256))) void *' from a function with result type 'void *' changes address space of pointer}}
+}
+
+__attribute__((address_space(1))) char test3_array[10];
+void test3(void) {
+ extern void test3_helper(char *p); // expected-note {{passing argument to parameter 'p' here}}
+ test3_helper(test3_array); // expected-error {{changes address space of pointer}}
+}
+
+typedef void ft(void);
+_AS1 ft qf; // expected-error {{function type may not be qualified with an address space}}
+typedef _AS1 ft qft; // expected-error {{function type may not be qualified with an address space}}