[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / AST / constraints-explicit-instantiation.cpp
blob10b6432f2db8c2ac30535f1117d1c804dd45abf9
1 // RUN: %clang_cc1 -std=c++20 -ast-dump %s | FileCheck %s
3 namespace PR46029 {
5 template <int N>
6 void canary1();
7 template <int N>
8 void canary2();
10 template <int N>
11 struct A {
12 void f() requires(N == 1) {
13 static_assert(N == 1);
14 canary1<N>();
16 void f() requires(N == 2) {
17 static_assert(N == 2);
18 canary2<N>();
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.
27 // CHECK:{{.*}}FunctionTemplateDecl {{.*}} canary1
28 // CHECK: {{.*}}TemplateArgument integral
29 // CHECK-SAME: {{1$}}
30 template struct A<1>;
32 // CHECK: {{.*}}FunctionTemplateDecl {{.*}} canary2
33 // CHECK: {{.*}}TemplateArgument integral
34 // CHECK-SAME: {{2$}}
35 template struct A<2>;
37 template struct A<3>;