1 // RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s 2 3 // expected-no-diagnostics 4 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. 11 12 template <unsigned v> 13 struct Number 14 { 15 static constexpr unsigned value = v; 16 }; 17 18 template <unsigned IBegin = 0, 19 unsigned IEnd = 1> 20 constexpr auto fun1(Number<IBegin> = Number<0>{}, Number<IEnd> = Number<1>{}) 21 { 22 constexpr unsigned a = 0; 23 auto f = [&](auto fs, auto i) { 24 if constexpr(i.value > 0) 25 { 26 (void)a; 27 return fs(fs, Number<IBegin>{}); 28 } 29 (void)a; 30 }; 31 32 return f(f, Number<IEnd>{}); 33 } 34 35 36 void fun2() { 37 fun1(); 38 } 39