OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 // Binding functions with reference parameters, unsupported. | 151 // Binding functions with reference parameters, unsupported. |
152 // | 152 // |
153 // See comment in NCTEST_DISALLOW_NON_CONST_REF_PARAM | 153 // See comment in NCTEST_DISALLOW_NON_CONST_REF_PARAM |
154 void WontCompile() { | 154 void WontCompile() { |
155 Parent p; | 155 Parent p; |
156 Callback<int()> ref_cb = Bind(&UnwrapParentRef, p); | 156 Callback<int()> ref_cb = Bind(&UnwrapParentRef, p); |
157 ref_cb.Run(); | 157 ref_cb.Run(); |
158 } | 158 } |
159 | 159 |
160 #elif defined(NCTEST_NO_IMPLICIT_ARRAY_PTR_CONVERSION) // [r"fatal error: stati
c_assert failed \"first bound argument to method cannot be array\""] | 160 #elif defined(NCTEST_NO_IMPLICIT_ARRAY_PTR_CONVERSION) // [r"fatal error: stati
c_assert failed \"First bound argument to a method cannot be an array.\""] |
161 | 161 |
162 // A method should not be bindable with an array of objects. | 162 // A method should not be bindable with an array of objects. |
163 // | 163 // |
164 // This is likely not wanted behavior. We specifically check for it though | 164 // This is likely not wanted behavior. We specifically check for it though |
165 // because it is possible, depending on how you implement prebinding, to | 165 // because it is possible, depending on how you implement prebinding, to |
166 // implicitly convert an array type to a pointer type. | 166 // implicitly convert an array type to a pointer type. |
167 void WontCompile() { | 167 void WontCompile() { |
168 HasRef p[10]; | 168 HasRef p[10]; |
169 Callback<void()> method_bound_to_array_cb = | 169 Callback<void()> method_bound_to_array_cb = |
170 Bind(&HasRef::VoidMethod0, p); | 170 Bind(&HasRef::VoidMethod0, p); |
171 method_bound_to_array_cb.Run(); | 171 method_bound_to_array_cb.Run(); |
172 } | 172 } |
173 | 173 |
174 #elif defined(NCTEST_NO_RAW_PTR_FOR_REFCOUNTED_TYPES) // [r"fatal error: static
_assert failed \"a parameter is a refcounted type and needs scoped_refptr\""] | 174 #elif defined(NCTEST_NO_RAW_PTR_FOR_REFCOUNTED_TYPES) // [r"fatal error: static
_assert failed \"A parameter is a refcounted type and needs scoped_refptr.\""] |
175 | 175 |
176 // Refcounted types should not be bound as a raw pointer. | 176 // Refcounted types should not be bound as a raw pointer. |
177 void WontCompile() { | 177 void WontCompile() { |
178 HasRef for_raw_ptr; | 178 HasRef for_raw_ptr; |
179 int a; | 179 int a; |
180 Callback<void()> ref_count_as_raw_ptr_a = | 180 Callback<void()> ref_count_as_raw_ptr_a = |
181 Bind(&VoidPolymorphic1<int*>, &a); | 181 Bind(&VoidPolymorphic1<int*>, &a); |
182 Callback<void()> ref_count_as_raw_ptr = | 182 Callback<void()> ref_count_as_raw_ptr = |
183 Bind(&VoidPolymorphic1<HasRef*>, &for_raw_ptr); | 183 Bind(&VoidPolymorphic1<HasRef*>, &for_raw_ptr); |
184 } | 184 } |
(...skipping 12 matching lines...) Expand all Loading... |
197 #elif defined(NCTEST_DISALLOW_ASSIGN_DIFFERENT_TYPES) // [r"fatal error: no via
ble conversion from 'Callback<MakeUnboundRunType<void \(\*\)\(int\)>>' to 'Callb
ack<void \(\)>'"] | 197 #elif defined(NCTEST_DISALLOW_ASSIGN_DIFFERENT_TYPES) // [r"fatal error: no via
ble conversion from 'Callback<MakeUnboundRunType<void \(\*\)\(int\)>>' to 'Callb
ack<void \(\)>'"] |
198 | 198 |
199 // Bind result cannot be assigned to Callbacks with a mismatching type. | 199 // Bind result cannot be assigned to Callbacks with a mismatching type. |
200 void WontCompile() { | 200 void WontCompile() { |
201 Closure callback_mismatches_bind_type = Bind(&VoidPolymorphic1<int>); | 201 Closure callback_mismatches_bind_type = Bind(&VoidPolymorphic1<int>); |
202 } | 202 } |
203 | 203 |
204 #endif | 204 #endif |
205 | 205 |
206 } // namespace base | 206 } // namespace base |
OLD | NEW |