[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / PCH / cxx1z-aligned-alloc.cpp
blobc1becbde3bf2ce623aa421e4c39da23440e95880
1 // No PCH:
2 // RUN: %clang_cc1 -pedantic -fsized-deallocation -std=c++1z -include %s -verify %s
3 //
4 // With PCH:
5 // RUN: %clang_cc1 -pedantic -fsized-deallocation -std=c++1z -emit-pch %s -o %t
6 // RUN: %clang_cc1 -pedantic -fsized-deallocation -std=c++1z -include-pch %t -verify %s
8 // RUN: %clang_cc1 -pedantic -fsized-deallocation -std=c++1z -emit-pch -fpch-instantiate-templates %s -o %t
9 // RUN: %clang_cc1 -pedantic -fsized-deallocation -std=c++1z -include-pch %t -verify %s
11 // expected-no-diagnostics
13 #ifndef HEADER
14 #define HEADER
16 using size_t = decltype(sizeof(0));
18 // Call the overaligned form of 'operator new'.
19 struct alignas(256) Q { int n; };
20 void *f() { return new Q; }
22 // Extract the std::align_val_t type from the implicit declaration of operator delete.
23 template<typename AlignValT>
24 AlignValT extract(void (*)(void*, size_t, AlignValT));
25 using T = decltype(extract(&operator delete));
27 #else
29 // ok, calls aligned allocation via placement syntax
30 void *q = new (T{16}) Q;
32 namespace std {
33 enum class align_val_t : size_t {};
36 using T = std::align_val_t; // ok, same type
38 #endif