1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 template <class T> operator T*();
6 template <class T> A::operator T*() { return 0; }
7 template <> A::operator char*(){ return 0; } // specialization
8 template A::operator void*(); // explicit instantiation
13 ip = a.operator int*();
18 template <class T> struct A { };
19 template <class T> struct B { };
22 template <class T> operator T();
26 s.operator A<A<int> >();
27 s.operator A<B<int> >();
28 s.operator A<B<A<int> > >();
35 template <typename T> operator T();
39 return this->operator T();
48 return this->operator int();
52 template float Foo::As();
53 template double Foo::As2();
55 // Partial ordering with conversion function templates.
57 template<typename T> operator T*() {
59 x = 17; // expected-error{{read-only variable is not assignable}}
62 template<typename T> operator T*() const; // expected-note{{explicit instantiation refers here}}
64 template<typename T> operator const T*() const {
66 return x; // expected-error{{cannot initialize return object of type 'const char *' with an lvalue of type 'char'}} \
67 // expected-error{{cannot initialize return object of type 'const int *' with an lvalue of type 'int'}}
71 template X0::operator const char*() const; // expected-note{{'X0::operator const char *<char>' requested here}}
72 template X0::operator const int*(); // expected-note{{'X0::operator const int *<const int>' requested here}}
73 template X0::operator float*() const; // expected-error{{explicit instantiation of undefined function template}}
75 void test_X0(X0 x0, const X0 &x0c) {
76 x0.operator const int*(); // expected-note{{in instantiation of function template specialization}}
77 x0.operator float *();
78 x0c.operator const char*();