Index: lib/Sema/SemaDeclCXX.cpp =================================================================== --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -5480,6 +5480,15 @@ for (Decl *Member : Class->decls()) { auto *MD = dyn_cast(Member); + auto *VD = dyn_cast(Member); + if (VD && Member->getAttr() && + VD->getStorageClass() == SC_Static && + VD->isDefinedOutsideFunctionOrMethod() && + VD->getType().isLocalConstQualified() && + TSK == TSK_ImplicitInstantiation) + S.PendingLocalImplicitInstantiations.push_back( + std::make_pair(VD, VD->getLocation())); + if (!MD) continue; Index: test/SemaCXX/export_static_const.cpp =================================================================== --- /dev/null +++ test/SemaCXX/export_static_const.cpp @@ -0,0 +1,18 @@ +template +class Base { + virtual void foo() {;} + static const int smember; +}; + +template const int Base::smember = 77; + +template +class __declspec(dllexport) Derived2 : Base +{ + void foo() {;} +}; + + +class Derived: public Derived2 { + void foo() {;} +};