Index: clang/lib/AST/DeclBase.cpp =================================================================== --- clang/lib/AST/DeclBase.cpp +++ clang/lib/AST/DeclBase.cpp @@ -339,9 +339,12 @@ return true; if (!isa(LDC)) return false; - if (const auto *CRD = dyn_cast(LDC)) + if (const auto *CRD = dyn_cast(LDC)) { if (CRD->isLambda()) return true; + if (CRD->hasDefaultConstructor() && CRD->hasAttr()) + return true; + } LDC = LDC->getLexicalParent(); } return false; Index: clang/test/SemaCXX/dllexport.cpp =================================================================== --- clang/test/SemaCXX/dllexport.cpp +++ clang/test/SemaCXX/dllexport.cpp @@ -1168,3 +1168,13 @@ // expected-error@+2{{lambda cannot be declared 'dllexport'}} #endif auto Lambda = []() __declspec(dllexport) -> bool { return true; }; + +//===----------------------------------------------------------------------===// +// Constructor Closure with default argument +//===----------------------------------------------------------------------===// +template +class __declspec(dllexport) foo { + foo(int x = 0); +}; +template <> +foo::foo(int);