| John McCall | 9b0a7ce | 2011-10-02 01:16:38 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s |
| Fariborz Jahanian | 600ba20 | 2011-09-28 20:22:05 +0000 | [diff] [blame] | 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'}} |
| Jordan Rose | a0a86be | 2013-03-08 22:25:36 +0000 | [diff] [blame] | 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> |
| John McCall | 3b5a8f5 | 2016-03-03 00:10:03 +0000 | [diff] [blame] | 32 | void templateFunction(T) { } // expected-note {{candidate template ignored: could not match 'void (__strong id)' against 'void (__attribute__((ns_consumed)) id)'}} \ |
| Larisse Voufo | 98b20f1 | 2013-07-19 23:00:19 +0000 | [diff] [blame] | 33 | // expected-note {{candidate template ignored: failed template argument deduction}} |
| John McCall | 3b5a8f5 | 2016-03-03 00:10:03 +0000 | [diff] [blame] | 34 | releaser_t r3 = templateFunction<id>; // expected-error {{address of overloaded function 'templateFunction' does not match required type 'void (__attribute__((ns_consumed)) id)'}} |
| Jordan Rose | a0a86be | 2013-03-08 22:25:36 +0000 | [diff] [blame] | 35 | |
| 36 | template <typename T> |
| Larisse Voufo | 98b20f1 | 2013-07-19 23:00:19 +0000 | [diff] [blame] | 37 | void templateReleaser(__attribute__((ns_consumed)) T) { } // expected-note 2{{candidate template ignored: failed template argument deduction}} |
| Jordan Rose | a0a86be | 2013-03-08 22:25:36 +0000 | [diff] [blame] | 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 |