aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaTemplate.cpp9
-rw-r--r--test/CXX/class.access/p4.cpp14
2 files changed, 21 insertions, 2 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index ba697fb398..378c789273 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -88,8 +88,13 @@ static void FilterAcceptableTemplateNames(ASTContext &C, LookupResult &R) {
filter.erase();
continue;
}
-
- filter.replace(Repl);
+
+ // FIXME: we promote access to public here as a workaround to
+ // the fact that LookupResult doesn't let us remember that we
+ // found this template through a particular injected class name,
+ // which means we end up doing nasty things to the invariants.
+ // Pretending that access is public is *much* safer.
+ filter.replace(Repl, AS_public);
}
}
filter.done();
diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp
index b0c33606f1..fa6e183890 100644
--- a/test/CXX/class.access/p4.cpp
+++ b/test/CXX/class.access/p4.cpp
@@ -436,3 +436,17 @@ namespace test17 {
A::Inner<int> s; // expected-error {{'Inner' is a private member of 'test17::A'}}
}
+
+namespace test18 {
+ template <class T> class A {};
+ class B : A<int> {
+ A<int> member;
+ };
+
+ // FIXME: this access to A should be forbidden (because C++ is dumb),
+ // but LookupResult can't express the necessary information to do
+ // the check, so we aggressively suppress access control.
+ class C : B {
+ A<int> member;
+ };
+}