blob: 0a6a6bc0990e5f9233b860b2777b393542b6792f [file] [log] [blame]
Douglas Gregor2700dcd2009-09-02 23:58:38 +00001// RUN: clang-cc -fsyntax-only -verify %s
Douglas Gregor2700dcd2009-09-02 23:58:38 +00002template<typename T>
3void call_f0(T x) {
4 x.Base::f0();
5}
6
7struct Base {
8 void f0();
9};
10
11struct X0 : Base {
12 typedef Base CrazyBase;
13};
14
15void test_f0(X0 x0) {
16 call_f0(x0);
17}
18
19template<typename TheBase, typename T>
20void call_f0_through_typedef(T x) {
21 typedef TheBase Base2;
22 x.Base2::f0();
23}
24
25void test_f0_through_typedef(X0 x0) {
26 call_f0_through_typedef<Base>(x0);
27}
28
29template<typename TheBase, typename T>
30void call_f0_through_typedef2(T x) {
31 typedef TheBase CrazyBase; // expected-note{{current scope}}
Douglas Gregorc68afe22009-09-03 21:38:09 +000032 x.CrazyBase::f0(); // expected-error{{ambiguous}} \
33 // expected-error 2{{no member named}}
Douglas Gregor2700dcd2009-09-02 23:58:38 +000034}
35
36struct OtherBase { };
37
38struct X1 : Base, OtherBase {
39 typedef OtherBase CrazyBase; // expected-note{{object type}}
40};
41
42void test_f0_through_typedef2(X0 x0, X1 x1) {
43 call_f0_through_typedef2<Base>(x0);
Douglas Gregorc68afe22009-09-03 21:38:09 +000044 call_f0_through_typedef2<OtherBase>(x1); // expected-note{{instantiation}}
45 call_f0_through_typedef2<Base>(x1); // expected-note{{instantiation}}
Douglas Gregor2700dcd2009-09-02 23:58:38 +000046}
47
48
Douglas Gregor81499bb2009-09-03 22:13:48 +000049struct X2 {
50 operator int() const;
51};
52
53template<typename T, typename U>
54T convert(const U& value) {
55 return value.operator T(); // expected-error{{operator long}}
56}
57
58void test_convert(X2 x2) {
59 convert<int>(x2);
60 convert<long>(x2); // expected-note{{instantiation}}
61}
Douglas Gregora71d8192009-09-04 17:36:40 +000062
63template<typename T>
64void destruct(T* ptr) {
65 ptr->~T();
66}
67
68template<typename T>
69void destruct_intptr(int *ip) {
70 ip->~T();
71}
72
73void test_destruct(X2 *x2p, int *ip) {
74 destruct(x2p);
75 destruct(ip);
76 destruct_intptr<int>(ip);
Douglas Gregora9e29aa2009-10-22 07:19:14 +000077}
78
79// PR5220
80class X3 {
81protected:
82 template <int> float* &f0();
83 template <int> const float* &f0() const;
84 void f1() {
85 (void)static_cast<float*>(f0<0>());
86 }
87 void f1() const{
88 (void)f0<0>();
89 }
90};