diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -657,6 +657,8 @@ mangleName(FD); else if (const MSGuidDecl *GuidD = dyn_cast(GD.getDecl())) mangleName(GuidD); + else if (const BindingDecl *BD = dyn_cast(GD.getDecl())) + mangleName(BD); else llvm_unreachable("unexpected kind of global decl"); } diff --git a/clang/test/CodeGenCXX/mangle.cpp b/clang/test/CodeGenCXX/mangle.cpp --- a/clang/test/CodeGenCXX/mangle.cpp +++ b/clang/test/CodeGenCXX/mangle.cpp @@ -1138,3 +1138,20 @@ // CHECK-LABEL: @_ZN6test581AC1INS_5StateEEET_MNS_8identityIS3_E4typeEFbvE void fn1() { A(a, &State::m_fn1); } } + +namespace test59 { + // verify no crash. + template + void f(T g) { + auto [e] = g; + [](decltype(e)) {}; + } +} + +namespace test60 { + struct X { int i, j; }; + auto [a,b] = X{1,2}; + template void f(decltype(a + T())) {} + // CHECK-LABEL: @_ZN6test601fIiEEvDTplL_ZNS_1aEEcvT__EE + template void f(int); +}