3 // RUN: split-file %s %t
5 // RUN: %clang_cc1 -std=c++23 %t/A.cppm -emit-module-interface -o %t/A.pcm
6 // RUN: %clang_cc1 -std=c++23 %t/Use.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
8 // RUN: %clang_cc1 -std=c++23 %t/A.cppm -emit-reduced-module-interface -o %t/A.pcm
9 // RUN: %clang_cc1 -std=c++23 %t/Use.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
17 export
template<int N
> struct A
: B
{
18 friend constexpr const int *f(B
) requires
true {
19 static constexpr int result
= N
;
24 friend constexpr const int *g(B
) requires (M
>= 0) && (N
>= 0) {
25 static constexpr int result
= M
* 10 + N
;
30 export
inline A
<1> a1
;
31 export
inline A
<2> a2
;
32 export
inline A
<3> a3
;
34 static_assert(f(a1
) != f(a2
) && f(a2
) != f(a3
));
35 static_assert(g
<1>(a1
) != g
<1>(a2
) && g
<1>(a2
) != g
<1>(a3
));
37 static_assert(*f(a1
) == 1);
38 static_assert(*f(a2
) == 2);
39 static_assert(*f(a3
) == 3);
41 static_assert(*g
<4>(a1
) == 41);
42 static_assert(*g
<5>(a2
) == 52);
43 static_assert(*g
<6>(a3
) == 63);
46 // expected-no-diagnostics
49 // Try some instantiations we tried before and some we didn't.
50 static_assert(f(a1
) != f(a2
) && f(a2
) != f(a3
));
51 static_assert(g
<1>(a1
) != g
<1>(a2
) && g
<1>(a2
) != g
<1>(a3
));
52 static_assert(g
<2>(a1
) != g
<2>(a2
) && g
<2>(a2
) != g
<2>(a3
));
55 static_assert(f(a1
) != f(a4
) && f(a2
) != f(a4
) && f(a3
) != f(a4
));
56 static_assert(g
<3>(a1
) != g
<3>(a4
));
58 static_assert(*f(a1
) == 1);
59 static_assert(*f(a2
) == 2);
60 static_assert(*f(a3
) == 3);
61 static_assert(*f(a4
) == 4);
63 static_assert(*g
<4>(a1
) == 41);
64 static_assert(*g
<5>(a2
) == 52);
65 static_assert(*g
<6>(a3
) == 63);
67 static_assert(*g
<7>(a1
) == 71);
68 static_assert(*g
<8>(a4
) == 84);