Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Anders Carlsson | 1d79faf | 2009-06-12 18:53:02 +0000 | [diff] [blame] | 2 | |
| 3 | typedef double A; |
| 4 | template<typename T> class B { |
| 5 | typedef int A; |
| 6 | }; |
| 7 | |
| 8 | template<typename T> struct X : B<T> { |
| 9 | static A a; |
| 10 | }; |
| 11 | |
| 12 | int a0[sizeof(X<int>::a) == sizeof(double) ? 1 : -1]; |
| 13 | |
| 14 | // PR4365. |
| 15 | template<class T> class Q; |
| 16 | template<class T> class R : Q<T> {T current;}; |
John McCall | 2641606 | 2009-11-24 20:33:45 +0000 | [diff] [blame] | 17 | |
| 18 | |
| 19 | namespace test0 { |
| 20 | template <class T> class Base { |
John McCall | 7002f4c | 2010-04-09 19:03:51 +0000 | [diff] [blame] | 21 | public: |
John McCall | 2641606 | 2009-11-24 20:33:45 +0000 | [diff] [blame] | 22 | void instance_foo(); |
| 23 | static void static_foo(); |
| 24 | class Inner { |
John McCall | 7002f4c | 2010-04-09 19:03:51 +0000 | [diff] [blame] | 25 | public: |
John McCall | 2641606 | 2009-11-24 20:33:45 +0000 | [diff] [blame] | 26 | void instance_foo(); |
| 27 | static void static_foo(); |
| 28 | }; |
| 29 | }; |
| 30 | |
| 31 | template <class T> class Derived1 : Base<T> { |
John McCall | 7002f4c | 2010-04-09 19:03:51 +0000 | [diff] [blame] | 32 | public: |
John McCall | 2641606 | 2009-11-24 20:33:45 +0000 | [diff] [blame] | 33 | void test0() { |
| 34 | Base<T>::static_foo(); |
| 35 | Base<T>::instance_foo(); |
| 36 | } |
| 37 | |
| 38 | void test1() { |
| 39 | Base<T>::Inner::static_foo(); |
| 40 | Base<T>::Inner::instance_foo(); // expected-error {{call to non-static member function without an object argument}} |
| 41 | } |
| 42 | |
| 43 | static void test2() { |
| 44 | Base<T>::static_foo(); |
| 45 | Base<T>::instance_foo(); // expected-error {{call to non-static member function without an object argument}} |
| 46 | } |
| 47 | |
| 48 | static void test3() { |
| 49 | Base<T>::Inner::static_foo(); |
| 50 | Base<T>::Inner::instance_foo(); // expected-error {{call to non-static member function without an object argument}} |
| 51 | } |
| 52 | }; |
| 53 | |
| 54 | template <class T> class Derived2 : Base<T>::Inner { |
John McCall | 7002f4c | 2010-04-09 19:03:51 +0000 | [diff] [blame] | 55 | public: |
John McCall | 2641606 | 2009-11-24 20:33:45 +0000 | [diff] [blame] | 56 | void test0() { |
| 57 | Base<T>::static_foo(); |
| 58 | Base<T>::instance_foo(); // expected-error {{call to non-static member function without an object argument}} |
| 59 | } |
| 60 | |
| 61 | void test1() { |
| 62 | Base<T>::Inner::static_foo(); |
| 63 | Base<T>::Inner::instance_foo(); |
| 64 | } |
| 65 | |
| 66 | static void test2() { |
| 67 | Base<T>::static_foo(); |
| 68 | Base<T>::instance_foo(); // expected-error {{call to non-static member function without an object argument}} |
| 69 | } |
| 70 | |
| 71 | static void test3() { |
| 72 | Base<T>::Inner::static_foo(); |
| 73 | Base<T>::Inner::instance_foo(); // expected-error {{call to non-static member function without an object argument}} |
| 74 | } |
| 75 | }; |
| 76 | |
| 77 | void test0() { |
| 78 | Derived1<int> d1; |
| 79 | d1.test0(); |
| 80 | d1.test1(); // expected-note {{in instantiation of member function}} |
| 81 | d1.test2(); // expected-note {{in instantiation of member function}} |
| 82 | d1.test3(); // expected-note {{in instantiation of member function}} |
| 83 | |
| 84 | Derived2<int> d2; |
| 85 | d2.test0(); // expected-note {{in instantiation of member function}} |
| 86 | d2.test1(); |
| 87 | d2.test2(); // expected-note {{in instantiation of member function}} |
| 88 | d2.test3(); // expected-note {{in instantiation of member function}} |
| 89 | } |
| 90 | } |
John McCall | 578b69b | 2009-12-16 08:11:27 +0000 | [diff] [blame] | 91 | |
| 92 | namespace test1 { |
| 93 | template <class T> struct Base { |
| 94 | void foo(T); // expected-note {{must qualify identifier to find this declaration in dependent base class}} |
| 95 | }; |
| 96 | |
| 97 | template <class T> struct Derived : Base<T> { |
| 98 | void doFoo(T v) { |
John McCall | 3b4294e | 2009-12-16 12:17:52 +0000 | [diff] [blame] | 99 | foo(v); // expected-error {{use of undeclared identifier}} |
John McCall | 578b69b | 2009-12-16 08:11:27 +0000 | [diff] [blame] | 100 | } |
| 101 | }; |
| 102 | |
| 103 | template struct Derived<int>; // expected-note {{requested here}} |
| 104 | } |