Index: include/llvm/Support/TrailingObjects.h =================================================================== --- include/llvm/Support/TrailingObjects.h +++ include/llvm/Support/TrailingObjects.h @@ -294,7 +294,12 @@ public: // Make this (privately inherited) member public. +#ifndef _MSC_VER using ParentType::OverloadToken; +#else + // MSVC bug prevents the above from working, at least up through CL 19.10.24629. + template using OverloadToken = typename ParentType::template OverloadToken; +#endif /// Returns a pointer to the trailing object array of the given type /// (which must be one of those specified in the class template). The Index: unittests/Support/TrailingObjectsTest.cpp =================================================================== --- unittests/Support/TrailingObjectsTest.cpp +++ unittests/Support/TrailingObjectsTest.cpp @@ -236,3 +236,19 @@ reinterpret_cast(C + 1) + 1, alignof(long)))); } } + +// Test the use of TrailingObjects with a template class. This +// previously failed to compile due to a bug in MSVC's member access +// control/lookup handling for OverloadToken. +template +class Class5 : private llvm::TrailingObjects { + using TrailingObjects = typename llvm::TrailingObjects; + friend TrailingObjects; + + size_t numTrailingObjects( + typename TrailingObjects::template OverloadToken) const { + return 1; + } +}; + +template class Class5; // instantiate to trigger the error