]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / CXX / temp / temp.fct.spec / temp.deduct / temp.deduct.conv / p4.cpp
1 // RUN: %clang_cc1 -fsyntax-only %s -verify
2
3 struct AnyT {
4   template<typename T>
5   operator T();
6 };
7
8 void test_cvqual_ref(AnyT any) {
9   const int &cir = any;  
10 }
11
12 struct AnyThreeLevelPtr {
13   template<typename T>
14   operator T***() const {
15     T x = 0; // expected-note 2{{declared const here}}
16     x = 0; // expected-error 2{{const-qualified type}}
17     T ***p;
18     return p;
19   }
20 };
21
22 struct X { };
23
24 void test_deduce_with_qual(AnyThreeLevelPtr a3) {
25   int * const * const * const ip1 = a3;
26   // FIXME: This is wrong; we are supposed to deduce 'T = int' here.
27   const int * const * const * const ip2 = a3; // expected-note {{instantiation of}}
28   // This one is correct, though.
29   const double * * * ip3 = a3; // expected-note {{instantiation of}}
30 }
31
32 struct AnyPtrMem {
33   template<typename Class, typename T>
34   operator T Class::*() const
35   {
36     // This is correct: we don't need a qualification conversion here, so we
37     // deduce 'T = const float'.
38     T x = 0; // expected-note {{declared const here}}
39     x = 0; // expected-error {{const-qualified type}}
40     return 0;
41   }
42 };
43
44 void test_deduce_ptrmem_with_qual(AnyPtrMem apm) {
45   const float X::* pm = apm; // expected-note {{instantiation of}}
46 }
47
48 struct TwoLevelPtrMem {
49   template<typename Class1, typename Class2, typename T>
50   operator T Class1::*Class2::*() const
51   {
52     T x = 0; // expected-note 2{{declared const here}}
53     x = 0; // expected-error 2{{const-qualified type}}
54     return 0;
55   }
56 };
57
58 void test_deduce_two_level_ptrmem_with_qual(TwoLevelPtrMem apm) {
59   // FIXME: This is wrong: we should deduce T = 'float'
60   const float X::* const X::* pm2 = apm; // expected-note {{instantiation of}}
61   // This is correct: we don't need a qualification conversion, so we directly
62   // deduce T = 'const double'
63   const double X::* X::* pm1 = apm; // expected-note {{instantiation of}}
64 }