31 lines · cpp
1// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wmicrosoft -verify -fms-extensions2// RUN: %clang_cc1 -triple x86_64-windows %s -fsyntax-only -Wmicrosoft -verify -fms-extensions3 4// Check that __ptr32/__ptr64 can be compared.5int 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 12template<typename T>13void bad(T __ptr32 a) { // expected-error {{'__ptr32' attribute only applies to pointer arguments}}`14 (*a) += 1;15}16 17template<int size_expected, typename T>18void f(T a) {19 (*a) += sizeof(a);20 static_assert(sizeof(a) == size_expected, "instantiated template argument has unexpected size");21}22void g(int *p) {23 // instantiate for default sized pointer24 f<sizeof(void*)>(p);25}26 27void h(int *__ptr32 p) {28 // instantiate for 32-bit pointer29 f<4>(p);30}31