From 2fdabb055d4179fc4e71d8708ab0a352b842fbba Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Tue, 28 Feb 2017 18:05:41 +0000 Subject: Workaround MSVC bug when using TrailingObjects from a template. MSVC appears to be getting confused as to whether OverloadToken is supposed to be public or not. This was discovered by code in Swift, and has been reported to microsoft by hughbe: https://connect.microsoft.com/VisualStudio/feedback/details/3116517 Differential Revision: https://reviews.llvm.org/D29880 llvm-svn: 296497 --- llvm/unittests/Support/TrailingObjectsTest.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'llvm/unittests/Support/TrailingObjectsTest.cpp') diff --git a/llvm/unittests/Support/TrailingObjectsTest.cpp b/llvm/unittests/Support/TrailingObjectsTest.cpp index cb5c47d1b25..23acc54d237 100644 --- a/llvm/unittests/Support/TrailingObjectsTest.cpp +++ b/llvm/unittests/Support/TrailingObjectsTest.cpp @@ -236,3 +236,24 @@ TEST(TrailingObjects, Realignment) { 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 Class5Tmpl : private llvm::TrailingObjects { + using TrailingObjects = typename llvm::TrailingObjects; + friend TrailingObjects; + + size_t numTrailingObjects( + typename TrailingObjects::template OverloadToken) const { + return 1; + } + + size_t numTrailingObjects( + typename TrailingObjects::template OverloadToken) const { + return 2; + } +}; + +class Class5 : public Class5Tmpl {}; -- cgit v1.2.3