[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / PCH / decl-attrs.cpp
blob2491070018749bfae4d531fd48aedbe67c0f8c86
1 // RUN: %clang_cc1 -std=c++20 -emit-pch -o %t.a %s
2 // RUN: %clang_cc1 -std=c++20 -include-pch %t.a %s -verify
4 #ifndef HEADER
5 #define HEADER
7 namespace preferred_name {
8 template<typename T> struct X;
9 using Y = X<int>;
10 using Z = X<float>;
11 template<typename T> struct [[using clang: preferred_name(Y), preferred_name(Z)]] X {};
12 Y y;
15 namespace aligned {
16 // PR48434: ensure attributes don't introduce deserialization cycles.
17 template<typename T> struct X1;
18 using Y1 = X1<int>;
19 template<typename T> struct alignas(Y1*) X1 {};
20 Y1 y1;
22 template<typename T> struct X2;
23 using Y2 = X2<int>;
24 template<typename T> struct alignas(Y2*) X2 {};
27 #else
29 namespace preferred_name {
30 Z z;
32 template<typename T> T forget(T t) { return t; }
33 void f() {
34 forget(y).foo(); // expected-error {{no member named 'foo' in 'preferred_name::Y'}}
35 forget(z).foo(); // expected-error {{no member named 'foo' in 'preferred_name::Z'}}
39 namespace aligned {
40 extern Y1 y1;
41 extern Y2 y2;
42 static_assert(alignof(Y1) == alignof(Y1*), "");
43 static_assert(alignof(Y2) == alignof(Y2*), "");
46 #endif