| 1 |
// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wmicrosoft -verify -fms-extensions |
| 2 |
// RUN: %clang_cc1 -triple x86_64-windows %s -fsyntax-only -Wmicrosoft -verify -fms-extensions |
| 3 |
|
| 4 |
// Check that __ptr32/__ptr64 can be compared. |
| 5 |
int test_ptr_comparison(int *__ptr32 __uptr p32u, int *__ptr32 __sptr p32s, |
| 6 |
int *__ptr64 p64) { |
| 7 |
return (p32u == p32s) + |
| 8 |
(p32u == p64) + |
| 9 |
(p32s == p64); |
| 10 |
} |
| 11 |
|
| 12 |
template<typename T> |
| 13 |
void bad(T __ptr32 a) { // expected-error {{'__ptr32' attribute only applies to pointer arguments}}` |
| 14 |
(*a) += 1; |
| 15 |
} |
| 16 |
|
| 17 |
template<int size_expected, typename T> |
| 18 |
void f(T a) { |
| 19 |
(*a) += sizeof(a); |
| 20 |
static_assert(sizeof(a) == size_expected, "instantiated template argument has unexpected size"); |
| 21 |
} |
| 22 |
void g(int *p) { |
| 23 |
// instantiate for default sized pointer |
| 24 |
f<sizeof(void*)>(p); |
| 25 |
} |
| 26 |
|
| 27 |
void h(int *__ptr32 p) { |
| 28 |
// instantiate for 32-bit pointer |
| 29 |
f<4>(p); |
| 30 |
} |