| 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 |
| 3 |
|
| 4 |
#ifndef HEADER |
| 5 |
#define HEADER |
| 6 |
|
| 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; |
| 13 |
} |
| 14 |
|
| 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; |
| 21 |
|
| 22 |
template<typename T> struct X2; |
| 23 |
using Y2 = X2<int>; |
| 24 |
template<typename T> struct alignas(Y2*) X2 {}; |
| 25 |
} |
| 26 |
|
| 27 |
#else |
| 28 |
|
| 29 |
namespace preferred_name { |
| 30 |
Z z; |
| 31 |
|
| 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'}} |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 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*), ""); |
| 44 |
} |
| 45 |
|
| 46 |
#endif |