block-sentinel-attribute.c revision 1eb4433ac451dc16f4133a88af2d002ac26c58ef
19f8f17cfdd6b7d1625386ad3d7a65bc4b1307885Fariborz Jahanian// RUN: clang-cc -fblocks -fsyntax-only -verify %s 2daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 3daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanianvoid (^e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1))); 4daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 51eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumpint main() { 61eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void (^bbad) (int arg, const char * format) __attribute__ ((__sentinel__)) ; // expected-warning {{sentinel' attribute only supported for variadic blocks}} 71eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void (^b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)) = // expected-note {{block has been explicitly marked sentinel here}} 81eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ^ __attribute__ ((__sentinel__)) (int arg, const char * format, ...) {}; 91eb4433ac451dc16f4133a88af2d002ac26c58efMike 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}} 10daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 11daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 121eb4433ac451dc16f4133a88af2d002ac26c58efMike 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}} 13daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump b(1, "%s", (void*)0); // OK 151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump b(1, "%s", 0); // expected-warning {{missing sentinel in block call}} 161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in block call}} 171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump z(1, "%s", (void*)0, 1, 0); // OK 18daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in block call}} 20daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump y(1, "%s", (void*)0,3,4,5,6,7); // OK 22daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 23daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian} 24daf0415583e33d5d279197c65e9227c1ed92474bFariborz Jahanian 25