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