xref: /llvm-project/clang/test/Parser/block-pointer-decl.c (revision c6e68daac0fa6e77a89f3ca72f266a528503dd1c)
167ca40c4SDouglas Gregor // RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
2*c6e68daaSAndy Gibbs // expected-no-diagnostics
367ca40c4SDouglas Gregor 
467ca40c4SDouglas Gregor int printf(char const *, ...);
5ec33ed9cSSteve Naroff 
6ec33ed9cSSteve Naroff struct blockStruct {
7ec33ed9cSSteve Naroff   int (^a)(float, int);
8ec33ed9cSSteve Naroff   int b;
9ec33ed9cSSteve Naroff };
10ec33ed9cSSteve Naroff 
11ec33ed9cSSteve Naroff int blockTaker (int (^myBlock)(int), int other_input)
12ec33ed9cSSteve Naroff {
130ac01283SSteve Naroff   return 5 * myBlock (other_input);
14ec33ed9cSSteve Naroff }
15ec33ed9cSSteve Naroff 
main(int argc,char ** argv)16ec33ed9cSSteve Naroff int main (int argc, char **argv)
17ec33ed9cSSteve Naroff {
180ac01283SSteve Naroff   int (^blockptr) (int) = ^(int inval) {
190ac01283SSteve Naroff     printf ("Inputs: %d, %d.\n", argc, inval);
200ac01283SSteve Naroff     return argc * inval;
210ac01283SSteve Naroff   };
220ac01283SSteve Naroff 
230ac01283SSteve Naroff 
240ac01283SSteve Naroff   argc = 10;
250ac01283SSteve Naroff   printf ("I got: %d.\n",
260ac01283SSteve Naroff           blockTaker (blockptr, 6));
27ec33ed9cSSteve Naroff   return 0;
28ec33ed9cSSteve Naroff }
29ec33ed9cSSteve Naroff 
30