1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
15 typedef Base CrazyBase
;
22 template<typename TheBase
, typename T
>
23 void call_f0_through_typedef(T x
) {
24 typedef TheBase Base2
;
28 void test_f0_through_typedef(X0 x0
) {
29 call_f0_through_typedef
<Base
>(x0
);
32 template<typename TheBase
, typename T
>
33 void call_f0_through_typedef2(T x
) {
34 typedef TheBase CrazyBase
;
35 #if __cplusplus <= 199711L
36 // expected-note@-2 {{lookup from the current scope refers here}}
39 x
.CrazyBase::f0(); // expected-error 2{{no member named}}
40 #if __cplusplus <= 199711L
41 // expected-error@-2 {{lookup of 'CrazyBase' in member access expression is ambiguous}}
48 struct X1
: Base
, OtherBase
{
49 typedef OtherBase CrazyBase
;
50 #if __cplusplus <= 199711L
51 // expected-note@-2 {{lookup in the object type 'X1' refers here}}
55 void test_f0_through_typedef2(X0 x0
, X1 x1
) {
56 call_f0_through_typedef2
<Base
>(x0
);
57 call_f0_through_typedef2
<OtherBase
>(x1
); // expected-note{{instantiation}}
58 call_f0_through_typedef2
<Base
>(x1
); // expected-note{{instantiation}}
66 template<typename T
, typename U
>
67 T
convert(const U
& value
) {
68 return value
.operator T(); // expected-error{{operator long}}
71 void test_convert(X2 x2
) {
73 convert
<long>(x2
); // expected-note{{instantiation}}
77 void destruct(T
* ptr
) {
83 void destruct_intptr(int *ip
) {
88 void test_destruct(X2
*x2p
, int *ip
) {
91 destruct_intptr
<int>(ip
);
97 template <int> float* &f0();
98 template <int> const float* &f0() const;
100 (void)static_cast<float*>(f0
<0>());
107 // Fun with template instantiation and conversions
110 float& member() const;
115 void f(T
* ptr
) { int& ir
= ptr
->member(); }
116 void g(T
* ptr
) { float& fr
= ptr
->member(); }
119 void test_X5(X5
<X4
> x5
, X5
<const X4
> x5c
, X4
*xp
, const X4
*cxp
) {
124 // In theory we can do overload resolution at template-definition time on this.
125 // We should at least not assert.
128 template <class T
> void foo() {}
131 template <class T
> struct Foo
: Base
{
153 template <class T
> class Base
;
154 template <class T
> class Derived
: public Base
<T
> {
157 // It's okay if at some point we figure out how to diagnose this
158 // at instantiation time.
159 *ptr
= field
; // expected-error {{incompatible pointer types assigning to 'B *' from 'A *'}}
165 struct C
{ void g(); };
166 template<typename T
> struct A
{
169 (x
.g()); // expected-error {{invalid use of member 'x' in static member function}}
172 void h() { A
<C
>::f(); }