mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 15:26:07 +00:00

Earlier, if the QualType was sugared, then we would error out as it was not a pointer type, for example, typedef int *int_star; int_star __ptr32 p; Now, if ptr32 is given we apply it if the raw Canonical Type (i.e., the desugared type) is a PointerType, instead of only checking whether the sugared type is a pointer type. As before, we still disallow ptr32 usage if the pointer is used as a pointer to a member. Differential Revision: https://reviews.llvm.org/D130123
31 lines
908 B
C++
31 lines
908 B
C++
// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
|
|
// RUN: %clang_cc1 -triple x86_64-windows %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
|
|
|
|
// Check that __ptr32/__ptr64 can be compared.
|
|
int test_ptr_comparison(int *__ptr32 __uptr p32u, int *__ptr32 __sptr p32s,
|
|
int *__ptr64 p64) {
|
|
return (p32u == p32s) +
|
|
(p32u == p64) +
|
|
(p32s == p64);
|
|
}
|
|
|
|
template<typename T>
|
|
void bad(T __ptr32 a) { // expected-error {{'__ptr32' attribute only applies to pointer arguments}}`
|
|
(*a) += 1;
|
|
}
|
|
|
|
template<int size_expected, typename T>
|
|
void f(T a) {
|
|
(*a) += sizeof(a);
|
|
static_assert(sizeof(a) == size_expected, "instantiated template argument has unexpected size");
|
|
}
|
|
void g(int *p) {
|
|
// instantiate for default sized pointer
|
|
f<sizeof(void*)>(p);
|
|
}
|
|
|
|
void h(int *__ptr32 p) {
|
|
// instantiate for 32-bit pointer
|
|
f<4>(p);
|
|
}
|