summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/TrailingObjectsTest.cpp
diff options
context:
space:
mode:
authorJames Y Knight <jyknight@google.com>2017-02-28 18:05:41 +0000
committerJames Y Knight <jyknight@google.com>2017-02-28 18:05:41 +0000
commit2fdabb055d4179fc4e71d8708ab0a352b842fbba (patch)
tree4a90cc5650c433ba50bcfd7fbab610cb49c0bc3e /llvm/unittests/Support/TrailingObjectsTest.cpp
parent74ca880749ed560accfb436620dc073a95a0b725 (diff)
downloadbcm5719-llvm-2fdabb055d4179fc4e71d8708ab0a352b842fbba.tar.gz
bcm5719-llvm-2fdabb055d4179fc4e71d8708ab0a352b842fbba.zip
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
Diffstat (limited to 'llvm/unittests/Support/TrailingObjectsTest.cpp')
-rw-r--r--llvm/unittests/Support/TrailingObjectsTest.cpp21
1 files changed, 21 insertions, 0 deletions
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<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> {};
OpenPOWER on IntegriCloud