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