blob: db9c37970bdb2cfbe9514713e4a130dfc8acab06 [file] [log] [blame]
/* APPLE LOCAL file radar 5732232 - blocks */
/* { dg-do run } */
/* { dg-options "-fblocks" } */
#include <stdio.h>
void * _NSConcreteStackBlock;
void _Block_byref_assign_copy(void * dst, void *src){}
void _Block_byref_release(void*src){}
extern "C" void exit(int);
extern void exit(int);
typedef double (^myblock)(int);
double test(myblock I) {
return I(42);
}
int main() {
__byref int x = 1;
__byref int y = 2;
double res = test(^(int z){ y = x+z; return (double)x; });
printf("result = %f x = %d y = %d\n", res, x, y);
if (x != 1 || y != 43)
exit(1);
res = test(^(int z){ x = x+z; return (double)y; });
printf("result = %f x = %d y = %d\n", res, x, y);
if (x != 43 || y != 43)
exit(1);
return 0;
}