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