39 lines · cpp
1// RUN: %clang_cc1 -std=c++20 -ast-dump %s | FileCheck %s2 3namespace PR46029 {4 5template <int N>6void canary1();7template <int N>8void canary2();9 10template <int N>11struct A {12 void f() requires(N == 1) {13 static_assert(N == 1);14 canary1<N>();15 }16 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, thus23// indirectly validating that the correct candidates of `A::f` were really24// instantiated each time.25// The `static_assert`s validate we don't instantiate wrong candidates.26 27// CHECK:{{.*}}FunctionTemplateDecl {{.*}} canary128// CHECK: {{.*}}TemplateArgument integral29// CHECK-SAME: {{'1'$}}30template struct A<1>;31 32// CHECK: {{.*}}FunctionTemplateDecl {{.*}} canary233// CHECK: {{.*}}TemplateArgument integral34// CHECK-SAME: {{'2'$}}35template struct A<2>;36 37template struct A<3>;38}39