When printing a qualified type, look through a substituted template
[clang.git] / test / CXX / temp / temp.decls / temp.mem / p5.cpp
bloba188f05d535e3dc2a5aebcf93aa9c2c7391ee1ad
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 struct A {
3 template <class T> operator T*();
4 };
6 template <class T> A::operator T*() { return 0; }
7 template <> A::operator char*(){ return 0; } // specialization
8 template A::operator void*(); // explicit instantiation
10 int main() {
11 A a;
12 int *ip;
13 ip = a.operator int*();
16 // PR5742
17 namespace PR5742 {
18 template <class T> struct A { };
19 template <class T> struct B { };
21 struct S {
22 template <class T> operator T();
23 } s;
25 void f() {
26 s.operator A<A<int> >();
27 s.operator A<B<int> >();
28 s.operator A<B<A<int> > >();
32 // PR5762
33 class Foo {
34 public:
35 template <typename T> operator T();
37 template <typename T>
38 T As() {
39 return this->operator T();
42 template <typename T>
43 T As2() {
44 return operator T();
47 int AsInt() {
48 return this->operator int();
52 template float Foo::As();
53 template double Foo::As2();
55 // Partial ordering with conversion function templates.
56 struct X0 {
57 template<typename T> operator T*() {
58 T x = 1;
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 {
65 T x = T();
66 return x; // expected-error{{cannot initialize return object of type 'const char *' with an lvalue of type 'char'}}
70 template X0::operator const char*() const; // expected-note{{'X0::operator const char *<char>' requested here}}
71 template X0::operator const int*(); // expected-note{{'X0::operator const int *<const int>' requested here}}
72 template X0::operator float*() const; // expected-error{{explicit instantiation of undefined function template}}
74 void test_X0(X0 x0, const X0 &x0c) {
75 x0.operator const int*();
76 x0.operator float *();
77 x0c.operator const char*();