[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / recursive-lambda.cpp
blob58087628db9882dca05ddbb025d1e7f07d62b9de
1 // RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
3 // expected-no-diagnostics
5 // Check recursive instantiation of lambda does not cause assertion.
6 // lambda function `f` in `fun1` is instantiated twice: first
7 // as f(f, Number<1>), then as f(f, Number<0>). The
8 // LocalInstantiationScopes of these two instantiations both contain
9 // `f` and `i`. However, since they are not merged, clang should not
10 // assert for that.
12 template <unsigned v>
13 struct Number
15 static constexpr unsigned value = v;
18 template <unsigned IBegin = 0,
19 unsigned IEnd = 1>
20 constexpr auto fun1(Number<IBegin> = Number<0>{}, Number<IEnd> = Number<1>{})
22 constexpr unsigned a = 0;
23 auto f = [&](auto fs, auto i) {
24 if constexpr(i.value > 0)
26 (void)a;
27 return fs(fs, Number<IBegin>{});
29 (void)a;
32 return f(f, Number<IEnd>{});
36 void fun2() {
37 fun1();