1a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s 2daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 3daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanianvoid (^e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1))); 4daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 51eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumpint main() { 6a0b2ba1d0ec27240f922c95b5acd8df905e3d3e0Eli Friedman void (^bbad) (int arg, const char * format) __attribute__ ((__sentinel__)) ; // expected-warning {{'sentinel' attribute only supported for variadic blocks}} 7a0b2ba1d0ec27240f922c95b5acd8df905e3d3e0Eli Friedman bbad = ^void (int arg, const char * format) __attribute__ ((__sentinel__)) {} ; // expected-warning {{'sentinel' attribute only supported for variadic blocks}} 81eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void (^b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)) = // expected-note {{block has been explicitly marked sentinel here}} 91eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ^ __attribute__ ((__sentinel__)) (int arg, const char * format, ...) {}; 101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void (^z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))) = ^ __attribute__ ((__sentinel__ (2))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}} 11daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 12daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void (^y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))) = ^ __attribute__ ((__sentinel__ (5))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}} 14daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump b(1, "%s", (void*)0); // OK 161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump b(1, "%s", 0); // expected-warning {{missing sentinel in block call}} 171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in block call}} 181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump z(1, "%s", (void*)0, 1, 0); // OK 19daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in block call}} 21daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump y(1, "%s", (void*)0,3,4,5,6,7); // OK 23daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 24daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian} 25daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 26