39 lines · cpp
1// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s2 3// expected-no-diagnostics4 5// Check recursive instantiation of lambda does not cause assertion.6// lambda function `f` in `fun1` is instantiated twice: first7// as f(f, Number<1>), then as f(f, Number<0>). The8// LocalInstantiationScopes of these two instantiations both contain9// `f` and `i`. However, since they are not merged, clang should not10// assert for that.11 12template <unsigned v>13struct Number14{15 static constexpr unsigned value = v;16};17 18template <unsigned IBegin = 0,19 unsigned IEnd = 1>20constexpr 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 36void fun2() {37 fun1();38}39