1 // Testing that the compiler can select the correct template specialization
2 // from different template aliasing.
5 // RUN: split-file %s %t
8 // RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm
9 // RUN: %clang_cc1 -std=c++20 %t/b.cpp -fprebuilt-module-path=%t \
10 // RUN: -fsyntax-only -verify
14 // For template type parameters
16 export template <class C>
18 static constexpr bool selected = false;
25 static constexpr bool selected = true;
30 // For template template parameters
32 export template <template<typename> typename C>
34 static constexpr bool selected = false;
39 static constexpr bool selected = true;
42 // For template non type parameters
43 export template <int X>
45 static constexpr bool selected = false;
46 static constexpr int value = X;
51 static constexpr bool selected = true;
52 static constexpr int value = 43;
55 export template <const int *>
57 static constexpr bool selected = false;
60 export int IntegralValue = 0;
62 struct Pointers<&IntegralValue> {
63 static constexpr bool selected = true;
66 export template <void *>
68 static constexpr bool selected = false;
72 struct NullPointers<nullptr> {
73 static constexpr bool selected = true;
76 export template<int (&)[5]>
78 static constexpr bool selected = false;
84 static constexpr bool selected = true;
88 // expected-no-diagnostics
91 // Testing for different qualifiers
92 static_assert(S<B>::selected);
93 static_assert(S<::B>::selected);
94 static_assert(::S<B>::selected);
95 static_assert(::S<::B>::selected);
97 static_assert(S<C>::selected);
98 static_assert(S<::C>::selected);
99 static_assert(::S<C>::selected);
100 static_assert(::S<::C>::selected);
107 static_assert(S<D::E>::selected);
108 static_assert(S<decltype(D::getAType())>::selected);
110 // Testing we can select the correct specialization for different
111 // template template argument alising.
113 static_assert(V<S>::selected);
114 static_assert(V<::S>::selected);
115 static_assert(::V<S>::selected);
116 static_assert(::V<::S>::selected);
118 // Testing for template non type parameters
119 static_assert(Numbers<43>::selected);
120 static_assert(Numbers<21 * 2 + 1>::selected);
121 static_assert(Numbers<42 + 1>::selected);
122 static_assert(Numbers<44 - 1>::selected);
123 static_assert(Numbers<Numbers<43>::value>::selected);
124 static_assert(!Numbers<44>::selected);
126 static_assert(Pointers<&IntegralValue>::selected);
127 static_assert(!Pointers<nullptr>::selected);
128 static_assert(NullPointers<nullptr>::selected);
129 static_assert(!NullPointers<(void*)&IntegralValue>::selected);
131 static_assert(Array<array>::selected);
132 int another_array[5];
133 static_assert(!Array<another_array>::selected);