OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This is a "No Compile Test" suite. | 5 // This is a "No Compile Test" suite. |
6 // http://dev.chromium.org/developers/testing/no-compile-tests | 6 // http://dev.chromium.org/developers/testing/no-compile-tests |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
11 | 11 |
12 struct Producer : SupportsWeakPtr<Producer> {}; | 12 struct Producer : SupportsWeakPtr<Producer> {}; |
13 struct DerivedProducer : Producer {}; | 13 struct DerivedProducer : Producer {}; |
14 struct OtherDerivedProducer : Producer {}; | 14 struct OtherDerivedProducer : Producer {}; |
15 struct MultiplyDerivedProducer : Producer, | 15 struct MultiplyDerivedProducer : Producer, |
16 SupportsWeakPtr<MultiplyDerivedProducer> {}; | 16 SupportsWeakPtr<MultiplyDerivedProducer> {}; |
17 struct Unrelated {}; | 17 struct Unrelated {}; |
18 struct DerivedUnrelated : Unrelated {}; | 18 struct DerivedUnrelated : Unrelated {}; |
19 | 19 |
20 #if defined(NCTEST_AUTO_DOWNCAST) // [r"fatal error: cannot initialize a member subobject of type 'base::DerivedProducer \*' with an lvalue of type 'base::Prod ucer \*const'"] | 20 #if defined(NCTEST_AUTO_DOWNCAST) // [r'fatal error: static_assert failed "othe r must be a subclass of T"'] |
Nico
2017/06/28 14:36:56
The changes in this CL also feel like they could b
hans
2017/06/28 20:37:35
Yeah, this is part of the "move ptr_ into WeakPtrB
| |
21 | 21 |
22 void WontCompile() { | 22 void WontCompile() { |
23 Producer f; | 23 Producer f; |
24 WeakPtr<Producer> ptr = f.AsWeakPtr(); | 24 WeakPtr<Producer> ptr = f.AsWeakPtr(); |
25 WeakPtr<DerivedProducer> derived_ptr = ptr; | 25 WeakPtr<DerivedProducer> derived_ptr = ptr; |
26 } | 26 } |
27 | 27 |
28 #elif defined(NCTEST_STATIC_DOWNCAST) // [r"fatal error: cannot initialize a me mber subobject of type 'base::DerivedProducer \*' with an lvalue of type 'base:: Producer \*const'"] | 28 #elif defined(NCTEST_STATIC_DOWNCAST) // [r'fatal error: static_assert failed " other must be a subclass of T"'] |
29 | 29 |
30 void WontCompile() { | 30 void WontCompile() { |
31 Producer f; | 31 Producer f; |
32 WeakPtr<Producer> ptr = f.AsWeakPtr(); | 32 WeakPtr<Producer> ptr = f.AsWeakPtr(); |
33 WeakPtr<DerivedProducer> derived_ptr = | 33 WeakPtr<DerivedProducer> derived_ptr = |
34 static_cast<WeakPtr<DerivedProducer> >(ptr); | 34 static_cast<WeakPtr<DerivedProducer> >(ptr); |
35 } | 35 } |
36 | 36 |
37 #elif defined(NCTEST_AUTO_REF_DOWNCAST) // [r"fatal error: non-const lvalue ref erence to type 'WeakPtr<base::DerivedProducer>' cannot bind to a value of unrela ted type 'WeakPtr<base::Producer>'"] | 37 #elif defined(NCTEST_AUTO_REF_DOWNCAST) // [r"fatal error: non-const lvalue ref erence to type 'WeakPtr<base::DerivedProducer>' cannot bind to a value of unrela ted type 'WeakPtr<base::Producer>'"] |
38 | 38 |
(...skipping 13 matching lines...) Expand all Loading... | |
52 } | 52 } |
53 | 53 |
54 #elif defined(NCTEST_STATIC_ASWEAKPTR_DOWNCAST) // [r"no matching function"] | 54 #elif defined(NCTEST_STATIC_ASWEAKPTR_DOWNCAST) // [r"no matching function"] |
55 | 55 |
56 void WontCompile() { | 56 void WontCompile() { |
57 Producer f; | 57 Producer f; |
58 WeakPtr<DerivedProducer> ptr = | 58 WeakPtr<DerivedProducer> ptr = |
59 SupportsWeakPtr<Producer>::StaticAsWeakPtr<DerivedProducer>(&f); | 59 SupportsWeakPtr<Producer>::StaticAsWeakPtr<DerivedProducer>(&f); |
60 } | 60 } |
61 | 61 |
62 #elif defined(NCTEST_UNSAFE_HELPER_DOWNCAST) // [r"fatal error: cannot initiali ze a member subobject of type 'base::DerivedProducer \*' with an lvalue of type 'base::Producer \*'"] | 62 #elif defined(NCTEST_UNSAFE_HELPER_DOWNCAST) // [r'fatal error: static_assert f ailed "other must be a subclass of T"'] |
63 | 63 |
64 void WontCompile() { | 64 void WontCompile() { |
65 Producer f; | 65 Producer f; |
66 WeakPtr<DerivedProducer> ptr = AsWeakPtr(&f); | 66 WeakPtr<DerivedProducer> ptr = AsWeakPtr(&f); |
67 } | 67 } |
68 | 68 |
69 #elif defined(NCTEST_UNSAFE_INSTANTIATED_HELPER_DOWNCAST) // [r"no matching fun ction"] | 69 #elif defined(NCTEST_UNSAFE_INSTANTIATED_HELPER_DOWNCAST) // [r"no matching fun ction"] |
70 | 70 |
71 void WontCompile() { | 71 void WontCompile() { |
72 Producer f; | 72 Producer f; |
73 WeakPtr<DerivedProducer> ptr = AsWeakPtr<DerivedProducer>(&f); | 73 WeakPtr<DerivedProducer> ptr = AsWeakPtr<DerivedProducer>(&f); |
74 } | 74 } |
75 | 75 |
76 #elif defined(NCTEST_UNSAFE_WRONG_INSANTIATED_HELPER_DOWNCAST) // [r"fatal erro r: cannot initialize a member subobject of type 'base::DerivedProducer \*' with an lvalue of type 'base::Producer \*'"] | 76 #elif defined(NCTEST_UNSAFE_WRONG_INSANTIATED_HELPER_DOWNCAST) // [r'fatal erro r: static_assert failed "other must be a subclass of T"'] |
77 | 77 |
78 void WontCompile() { | 78 void WontCompile() { |
79 Producer f; | 79 Producer f; |
80 WeakPtr<DerivedProducer> ptr = AsWeakPtr<Producer>(&f); | 80 WeakPtr<DerivedProducer> ptr = AsWeakPtr<Producer>(&f); |
81 } | 81 } |
82 | 82 |
83 #elif defined(NCTEST_UNSAFE_HELPER_CAST) // [r"fatal error: cannot initialize a member subobject of type 'base::OtherDerivedProducer \*' with an lvalue of type 'base::DerivedProducer \*'"] | 83 #elif defined(NCTEST_UNSAFE_HELPER_CAST) // [r'fatal error: static_assert faile d "other must be a subclass of T"'] |
84 | 84 |
85 void WontCompile() { | 85 void WontCompile() { |
86 DerivedProducer f; | 86 DerivedProducer f; |
87 WeakPtr<OtherDerivedProducer> ptr = AsWeakPtr(&f); | 87 WeakPtr<OtherDerivedProducer> ptr = AsWeakPtr(&f); |
88 } | 88 } |
89 | 89 |
90 #elif defined(NCTEST_UNSAFE_INSTANTIATED_HELPER_SIDECAST) // [r"fatal error: no matching function for call to 'AsWeakPtr'"] | 90 #elif defined(NCTEST_UNSAFE_INSTANTIATED_HELPER_SIDECAST) // [r"fatal error: no matching function for call to 'AsWeakPtr'"] |
91 | 91 |
92 void WontCompile() { | 92 void WontCompile() { |
93 DerivedProducer f; | 93 DerivedProducer f; |
94 WeakPtr<OtherDerivedProducer> ptr = AsWeakPtr<OtherDerivedProducer>(&f); | 94 WeakPtr<OtherDerivedProducer> ptr = AsWeakPtr<OtherDerivedProducer>(&f); |
95 } | 95 } |
96 | 96 |
97 #elif defined(NCTEST_UNSAFE_WRONG_INSTANTIATED_HELPER_SIDECAST) // [r"fatal err or: cannot initialize a member subobject of type 'base::OtherDerivedProducer \*' with an lvalue of type 'base::DerivedProducer \*'"] | 97 #elif defined(NCTEST_UNSAFE_WRONG_INSTANTIATED_HELPER_SIDECAST) // [r'fatal err or: static_assert failed "other must be a subclass of T"'] |
98 | 98 |
99 void WontCompile() { | 99 void WontCompile() { |
100 DerivedProducer f; | 100 DerivedProducer f; |
101 WeakPtr<OtherDerivedProducer> ptr = AsWeakPtr<DerivedProducer>(&f); | 101 WeakPtr<OtherDerivedProducer> ptr = AsWeakPtr<DerivedProducer>(&f); |
102 } | 102 } |
103 | 103 |
104 #elif defined(NCTEST_UNRELATED_HELPER) // [r"fatal error: cannot initialize a m ember subobject of type 'base::Unrelated \*' with an lvalue of type 'base::Deriv edProducer \*'"] | 104 #elif defined(NCTEST_UNRELATED_HELPER) // [r'fatal error: static_assert failed "other must be a subclass of T"'] |
105 | 105 |
106 void WontCompile() { | 106 void WontCompile() { |
107 DerivedProducer f; | 107 DerivedProducer f; |
108 WeakPtr<Unrelated> ptr = AsWeakPtr(&f); | 108 WeakPtr<Unrelated> ptr = AsWeakPtr(&f); |
109 } | 109 } |
110 | 110 |
111 #elif defined(NCTEST_UNRELATED_INSTANTIATED_HELPER) // [r"no matching function" ] | 111 #elif defined(NCTEST_UNRELATED_INSTANTIATED_HELPER) // [r"no matching function" ] |
112 | 112 |
113 void WontCompile() { | 113 void WontCompile() { |
114 DerivedProducer f; | 114 DerivedProducer f; |
(...skipping 17 matching lines...) Expand all Loading... | |
132 #elif defined(NCTEST_AMBIGUOUS_ANCESTORS) // [r"fatal error: use of undeclared identifier 'AsWeakPtrImpl'"] | 132 #elif defined(NCTEST_AMBIGUOUS_ANCESTORS) // [r"fatal error: use of undeclared identifier 'AsWeakPtrImpl'"] |
133 | 133 |
134 void WontCompile() { | 134 void WontCompile() { |
135 MultiplyDerivedProducer f; | 135 MultiplyDerivedProducer f; |
136 WeakPtr<MultiplyDerivedProducer> ptr = AsWeakPtr(&f); | 136 WeakPtr<MultiplyDerivedProducer> ptr = AsWeakPtr(&f); |
137 } | 137 } |
138 | 138 |
139 #endif | 139 #endif |
140 | 140 |
141 } | 141 } |
OLD | NEW |