xref: /llvm-project/clang/test/AST/constraints-explicit-instantiation.cpp (revision 1a2f3309765fdc143fdc3809211fb85d2e2ca341)
1 // RUN: %clang_cc1 -std=c++20 -ast-dump %s | FileCheck %s
2 
3 namespace PR46029 {
4 
5 template <int N>
6 void canary1();
7 template <int N>
8 void canary2();
9 
10 template <int N>
11 struct A {
fPR46029::A12   void f() requires(N == 1) {
13     static_assert(N == 1);
14     canary1<N>();
15   }
fPR46029::A16   void f() requires(N == 2) {
17     static_assert(N == 2);
18     canary2<N>();
19   }
20 };
21 
22 // This checks that `canary1<1>` and `canaray2<2>` are instantiated, thus
23 // indirectly validating that the correct candidates of `A::f` were really
24 // instantiated each time.
25 // The `static_assert`s validate we don't instantiate wrong candidates.
26 
27 // CHECK:{{.*}}FunctionTemplateDecl {{.*}} canary1
28 // CHECK:      {{.*}}TemplateArgument integral
29 // CHECK-SAME: {{'1'$}}
30 template struct A<1>;
31 
32 // CHECK:      {{.*}}FunctionTemplateDecl {{.*}} canary2
33 // CHECK:      {{.*}}TemplateArgument integral
34 // CHECK-SAME: {{'2'$}}
35 template struct A<2>;
36 
37 template struct A<3>;
38 }
39