summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-06-16 08:42:20 +0000
committerJohn McCall <rjmccall@apple.com>2010-06-16 08:42:20 +0000
commite9cccd86da2fe29b7488e4888fa09c6834c82f31 (patch)
tree5a7b17c3fc2c082838d3ecae813af472a552eab5 /clang/test
parentf128bdcb557e20b20d02ca0351aa4ff19a1b0c42 (diff)
downloadbcm5719-llvm-e9cccd86da2fe29b7488e4888fa09c6834c82f31.tar.gz
bcm5719-llvm-e9cccd86da2fe29b7488e4888fa09c6834c82f31.zip
Fix a point of semantics with using declaration hiding: method templates
introduced by using decls are hidden even if their template parameter lists or return types differ from the "overriding" declaration. Propagate using shadow declarations around more effectively when looking up template-ids. Reperform lookup for template-ids in member expressions so that access control is properly set up. Fix some number of latent bugs involving template-ids with totally invalid base types. You can only actually get these with a scope specifier, since otherwise the template-id won't parse as a template-id. Fixes PR7384. llvm-svn: 106093
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp35
-rw-r--r--clang/test/SemaCXX/member-expr.cpp18
2 files changed, 45 insertions, 8 deletions
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
index 25371c7029b..cc28bf6c28c 100644
--- a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
@@ -111,34 +111,53 @@ namespace test3 {
struct Derived1 : Base {
using Base::foo;
- template <int n> Opaque<2> foo() { return Opaque<2>(); }
+ template <int n> Opaque<2> foo() { return Opaque<2>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'n'}}
};
struct Derived2 : Base {
- template <int n> Opaque<2> foo() { return Opaque<2>(); }
+ template <int n> Opaque<2> foo() { return Opaque<2>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'n'}}
using Base::foo;
};
struct Derived3 : Base {
using Base::foo;
- template <class T> Opaque<3> foo() { return Opaque<3>(); }
+ template <class T> Opaque<3> foo() { return Opaque<3>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'T'}}
};
struct Derived4 : Base {
- template <class T> Opaque<3> foo() { return Opaque<3>(); }
+ template <class T> Opaque<3> foo() { return Opaque<3>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'T'}}
using Base::foo;
};
void test() {
expect<0>(Base().foo<int>());
expect<1>(Base().foo<0>());
- expect<0>(Derived1().foo<int>());
+ expect<0>(Derived1().foo<int>()); // expected-error {{no matching member function for call to 'foo'}}
expect<2>(Derived1().foo<0>());
- expect<0>(Derived2().foo<int>());
+ expect<0>(Derived2().foo<int>()); // expected-error {{no matching member function for call to 'foo'}}
expect<2>(Derived2().foo<0>());
expect<3>(Derived3().foo<int>());
- expect<1>(Derived3().foo<0>());
+ expect<1>(Derived3().foo<0>()); // expected-error {{no matching member function for call to 'foo'}}
expect<3>(Derived4().foo<int>());
- expect<1>(Derived4().foo<0>());
+ expect<1>(Derived4().foo<0>()); // expected-error {{no matching member function for call to 'foo'}}
+ }
+}
+
+// PR7384: access control for member templates.
+namespace test4 {
+ class Base {
+ protected:
+ template<typename T> void foo(T);
+ template<typename T> void bar(T); // expected-note {{declared protected here}}
+ };
+
+ struct Derived : Base {
+ using Base::foo;
+ };
+
+ void test() {
+ Derived d;
+ d.foo<int>(3);
+ d.bar<int>(3); // expected-error {{'bar' is a protected member}}
}
}
diff --git a/clang/test/SemaCXX/member-expr.cpp b/clang/test/SemaCXX/member-expr.cpp
index 54a95936bed..e83fdbf0870 100644
--- a/clang/test/SemaCXX/member-expr.cpp
+++ b/clang/test/SemaCXX/member-expr.cpp
@@ -72,3 +72,21 @@ namespace test4 {
y.f(17);
}
}
+
+namespace test5 {
+ struct A {
+ template <class T> void foo();
+ };
+
+ void test0(int x) {
+ x.A::foo<int>(); // expected-error {{'int' is not a structure or union}}
+ }
+
+ void test1(A *x) {
+ x.A::foo<int>(); // expected-error {{'test5::A *' is a pointer}}
+ }
+
+ void test2(A &x) {
+ x->A::foo<int>(); // expected-error {{'test5::A' is not a pointer}}
+ }
+}
OpenPOWER on IntegriCloud