| 1 | // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s |
| 2 | // rdar://10187884 |
| 3 | |
| 4 | typedef void (^blk)(id, __attribute((ns_consumed)) id); |
| 5 | typedef void (^blk1)(__attribute((ns_consumed))id, __attribute((ns_consumed)) id); |
| 6 | blk a = ^void (__attribute((ns_consumed)) id, __attribute((ns_consumed)) id){}; // expected-error {{cannot initialize a variable of type '__strong blk'}} |
| 7 | |
| 8 | blk b = ^void (id, __attribute((ns_consumed)) id){}; |
| 9 | |
| 10 | blk c = ^void (__attribute((ns_consumed)) id, __attribute((ns_consumed)) id){}; // expected-error {{cannot initialize a variable of type '__strong blk'}} |
| 11 | |
| 12 | blk d = ^void (id, id) {}; // expected-error {{cannot initialize a variable of type '__strong blk'}} |
| 13 | |
| 14 | blk1 a1 = ^void (__attribute((ns_consumed)) id, id){}; // expected-error {{cannot initialize a variable of type '__strong blk1'}} |
| 15 | |
| 16 | blk1 b2 = ^void (id, __attribute((ns_consumed)) id){}; // expected-error {{cannot initialize a variable of type '__strong blk1'}} |
| 17 | |
| 18 | blk1 c3 = ^void (__attribute((ns_consumed)) id, __attribute((ns_consumed)) id){}; |
| 19 | |
| 20 | blk1 d4 = ^void (id, id) {}; // expected-error {{cannot initialize a variable of type '__strong blk1'}} |
| 21 | |
| 22 | |
| 23 | typedef void (*releaser_t)(__attribute__((ns_consumed)) id); |
| 24 | |
| 25 | void normalFunction(id); |
| 26 | releaser_t r1 = normalFunction; // expected-error {{cannot initialize a variable of type 'releaser_t'}} |
| 27 | |
| 28 | void releaser(__attribute__((ns_consumed)) id); |
| 29 | releaser_t r2 = releaser; // no-warning |
| 30 | |
| 31 | template <typename T> |
| 32 | void templateFunction(T) { } // expected-note {{candidate template ignored: could not match 'void (__strong id)' against 'void (__attribute__((ns_consumed)) id)'}} \ |
| 33 | // expected-note {{candidate template ignored: failed template argument deduction}} |
| 34 | releaser_t r3 = templateFunction<id>; // expected-error {{address of overloaded function 'templateFunction' does not match required type 'void (__attribute__((ns_consumed)) id)'}} |
| 35 | |
| 36 | template <typename T> |
| 37 | void templateReleaser(__attribute__((ns_consumed)) T) { } // expected-note 2{{candidate template ignored: failed template argument deduction}} |
| 38 | releaser_t r4 = templateReleaser<id>; // no-warning |
| 39 | |
| 40 | |
| 41 | @class AntiRelease, ExplicitAntiRelease, ProRelease; |
| 42 | |
| 43 | template<> |
| 44 | void templateFunction(__attribute__((ns_consumed)) AntiRelease *); // expected-error {{no function template matches function template specialization 'templateFunction'}} |
| 45 | |
| 46 | template<> |
| 47 | void templateReleaser(AntiRelease *); // expected-error {{no function template matches function template specialization 'templateReleaser'}} |
| 48 | |
| 49 | template<> |
| 50 | void templateReleaser(ExplicitAntiRelease *) {} // expected-error {{no function template matches function template specialization 'templateReleaser'}} |
| 51 | |
| 52 | template<> |
| 53 | void templateReleaser(__attribute__((ns_consumed)) ProRelease *); // no-warning |
| 54 | |