aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/address_spaces.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Sema/address_spaces.c')
-rw-r--r--test/Sema/address_spaces.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/Sema/address_spaces.c b/test/Sema/address_spaces.c
index 87707d7deb0d..a9046d86f18c 100644
--- a/test/Sema/address_spaces.c
+++ b/test/Sema/address_spaces.c
@@ -71,5 +71,19 @@ __attribute__((address_space("12"))) int *i; // expected-error {{'address_space'
// Clang extension doesn't forbid operations on pointers to different address spaces.
char* cmp(_AS1 char *x, _AS2 char *y) {
- return x < y ? x : y; // expected-warning {{pointer type mismatch ('__attribute__((address_space(1))) char *' and '__attribute__((address_space(2))) char *')}}
+ return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type ('__attribute__((address_space(1))) char *' and '__attribute__((address_space(2))) char *') which are pointers to non-overlapping address spaces}}
+}
+
+struct SomeStruct {
+ int a;
+ long b;
+ int c;
+};
+
+// Compound literals in function scope are lvalues with automatic storage duration,
+// so they cannot realistically be qualified with an address space.
+void as_compound_literal() {
+ (_AS1 struct SomeStruct){1, 2, 3}; // expected-error {{compound literal in function scope may not be qualified with an address space}}
+ (_AS1 char[]){"test"}; // expected-error {{compound literal in function scope may not be qualified with an address space}}
+ (_AS1 char[]){'a', 'b', 'c'}; // expected-error {{compound literal in function scope may not be qualified with an address space}}
}