blob: 77961069c5a22fad4b72c6a848bd5d8f92f45072 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Anders Carlsson1d79faf2009-06-12 18:53:02 +00002
3typedef double A;
4template<typename T> class B {
5 typedef int A;
6};
7
8template<typename T> struct X : B<T> {
9 static A a;
10};
11
12int a0[sizeof(X<int>::a) == sizeof(double) ? 1 : -1];
13
14// PR4365.
15template<class T> class Q;
16template<class T> class R : Q<T> {T current;};
John McCall26416062009-11-24 20:33:45 +000017
18
19namespace test0 {
20 template <class T> class Base {
John McCall7002f4c2010-04-09 19:03:51 +000021 public:
John McCall26416062009-11-24 20:33:45 +000022 void instance_foo();
23 static void static_foo();
24 class Inner {
John McCall7002f4c2010-04-09 19:03:51 +000025 public:
John McCall26416062009-11-24 20:33:45 +000026 void instance_foo();
27 static void static_foo();
28 };
29 };
30
31 template <class T> class Derived1 : Base<T> {
John McCall7002f4c2010-04-09 19:03:51 +000032 public:
John McCall26416062009-11-24 20:33:45 +000033 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 McCall7002f4c2010-04-09 19:03:51 +000055 public:
John McCall26416062009-11-24 20:33:45 +000056 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 McCall578b69b2009-12-16 08:11:27 +000091
92namespace 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 McCall3b4294e2009-12-16 12:17:52 +000099 foo(v); // expected-error {{use of undeclared identifier}}
John McCall578b69b2009-12-16 08:11:27 +0000100 }
101 };
102
103 template struct Derived<int>; // expected-note {{requested here}}
104}