| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // First, non-const reference parameters are disallowed by the Google | 139 // First, non-const reference parameters are disallowed by the Google |
| 140 // style guide. Second, since we are doing argument forwarding it becomes | 140 // style guide. Second, since we are doing argument forwarding it becomes |
| 141 // very tricky to avoid copies, maintain const correctness, and not | 141 // very tricky to avoid copies, maintain const correctness, and not |
| 142 // accidentally have the function be modifying a temporary, or a copy. | 142 // accidentally have the function be modifying a temporary, or a copy. |
| 143 void WontCompile() { | 143 void WontCompile() { |
| 144 Parent p; | 144 Parent p; |
| 145 Callback<int(Parent&)> ref_arg_cb = Bind(&UnwrapParentRef); | 145 Callback<int(Parent&)> ref_arg_cb = Bind(&UnwrapParentRef); |
| 146 ref_arg_cb.Run(p); | 146 ref_arg_cb.Run(p); |
| 147 } | 147 } |
| 148 | 148 |
| 149 #elif defined(NCTEST_DISALLOW_BIND_TO_NON_CONST_REF_PARAM) // [r"fatal error: s
tatic_assert failed \"do not bind functions with nonconst ref\""] | 149 #elif defined(NCTEST_DISALLOW_BIND_TO_NON_CONST_REF_PARAM) // [r"fatal error: b
inding value of type 'const base::Parent' to reference to type 'base::Parent' dr
ops 'const' qualifier"] |
| 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 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |