diff options
author | James Y Knight <jyknight@google.com> | 2017-02-28 18:05:41 +0000 |
---|---|---|
committer | James Y Knight <jyknight@google.com> | 2017-02-28 18:05:41 +0000 |
commit | f563b7840e0cc6ce36d34a846e069e8f0f3a89f4 (patch) | |
tree | 93e80ea2bb9f0b1a6f560c6f7f6923e1a3021ee5 /unittests/Support/TrailingObjectsTest.cpp | |
parent | 9070606d4731daa40d4cbb1a60ddbe1133a10c0c (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296497 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Support/TrailingObjectsTest.cpp')
-rw-r--r-- | unittests/Support/TrailingObjectsTest.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/unittests/Support/TrailingObjectsTest.cpp b/unittests/Support/TrailingObjectsTest.cpp index cb5c47d1b25..23acc54d237 100644 --- a/unittests/Support/TrailingObjectsTest.cpp +++ b/unittests/Support/TrailingObjectsTest.cpp @@ -236,3 +236,24 @@ TEST(TrailingObjects, Realignment) { reinterpret_cast<char *>(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 <typename Derived> +class Class5Tmpl : private llvm::TrailingObjects<Derived, float, int> { + using TrailingObjects = typename llvm::TrailingObjects<Derived, float>; + friend TrailingObjects; + + size_t numTrailingObjects( + typename TrailingObjects::template OverloadToken<float>) const { + return 1; + } + + size_t numTrailingObjects( + typename TrailingObjects::template OverloadToken<int>) const { + return 2; + } +}; + +class Class5 : public Class5Tmpl<Class5> {}; |