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
14 export
template<int N
> struct A
: B
{
15 friend constexpr const int *f(B
) requires
true {
16 static constexpr int result
= N
;
21 friend constexpr const int *g(B
) requires (M
>= 0) && (N
>= 0) {
22 static constexpr int result
= M
* 10 + N
;
27 export
inline A
<1> a1
;
28 export
inline A
<2> a2
;
29 export
inline A
<3> a3
;
31 static_assert(f(a1
) != f(a2
) && f(a2
) != f(a3
));
32 static_assert(g
<1>(a1
) != g
<1>(a2
) && g
<1>(a2
) != g
<1>(a3
));
34 static_assert(*f(a1
) == 1);
35 static_assert(*f(a2
) == 2);
36 static_assert(*f(a3
) == 3);
38 static_assert(*g
<4>(a1
) == 41);
39 static_assert(*g
<5>(a2
) == 52);
40 static_assert(*g
<6>(a3
) == 63);
43 // expected-no-diagnostics
46 // Try some instantiations we tried before and some we didn't.
47 static_assert(f(a1
) != f(a2
) && f(a2
) != f(a3
));
48 static_assert(g
<1>(a1
) != g
<1>(a2
) && g
<1>(a2
) != g
<1>(a3
));
49 static_assert(g
<2>(a1
) != g
<2>(a2
) && g
<2>(a2
) != g
<2>(a3
));
52 static_assert(f(a1
) != f(a4
) && f(a2
) != f(a4
) && f(a3
) != f(a4
));
53 static_assert(g
<3>(a1
) != g
<3>(a4
));
55 static_assert(*f(a1
) == 1);
56 static_assert(*f(a2
) == 2);
57 static_assert(*f(a3
) == 3);
58 static_assert(*f(a4
) == 4);
60 static_assert(*g
<4>(a1
) == 41);
61 static_assert(*g
<5>(a2
) == 52);
62 static_assert(*g
<6>(a3
) == 63);
64 static_assert(*g
<7>(a1
) == 71);
65 static_assert(*g
<8>(a4
) == 84);