[MSVC] Implementation of __unaligned as a proper type qualifier
This patch implements __unaligned (MS extension) as a proper type qualifier
(before that, it was implemented as an ignored attribute).
It also fixes PR27367 and PR27666.
Differential Revision: http://reviews.llvm.org/D20103
llvm-svn: 269220
diff --git a/clang/test/Sema/MicrosoftExtensions.c b/clang/test/Sema/MicrosoftExtensions.c
index e703230..713daf5 100644
--- a/clang/test/Sema/MicrosoftExtensions.c
+++ b/clang/test/Sema/MicrosoftExtensions.c
@@ -170,3 +170,11 @@
__va_start(ap, f); // expected-warning {{incompatible pointer types passing 'my_va_list'}}
}
}
+
+// __unaligned handling
+void test_unaligned() {
+ __unaligned int *p1 = 0;
+ int *p2 = p1; // expected-warning {{initializing 'int *' with an expression of type '__unaligned int *' discards qualifiers}}
+ __unaligned int *p3 = p2;
+}
+
diff --git a/clang/test/Sema/address_spaces.c b/clang/test/Sema/address_spaces.c
index 1922c8a..3fe9315 100644
--- a/clang/test/Sema/address_spaces.c
+++ b/clang/test/Sema/address_spaces.c
@@ -20,7 +20,7 @@
_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(0x7FFFFF))) 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}}
@@ -71,4 +71,4 @@
// 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 *')}}
-}
\ No newline at end of file
+}
diff --git a/clang/test/Sema/invalid-assignment-constant-address-space.c b/clang/test/Sema/invalid-assignment-constant-address-space.c
index de2af64..77d6b33 100644
--- a/clang/test/Sema/invalid-assignment-constant-address-space.c
+++ b/clang/test/Sema/invalid-assignment-constant-address-space.c
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
-#define OPENCL_CONSTANT 16776962
+#define OPENCL_CONSTANT 8388354
int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0};
void foo() {