blob: 33fc5bebca43674e44fe341e4a20448af91d9b19 [file] [log] [blame]
/* APPLE LOCAL file radar 5732232 - blocks */
/* { dg-do compile } */
/* { dg-options "-fblocks" } */
typedef void (^CL)(void);
CL foo() {
short y;
short (^add1)(void) = ^{ return y+1; }; /* { dg-error "cannot initialize a variable" } */
CL X = ^{
if (2)
return;
return 1; /* { dg-error "return type 'int' must match previous return type 'void' when block literal has unspecified explicit return type" } */
};
int (^Y) (void) = ^{
if (3)
return 1;
else
return; /* { dg-error "return type 'void' must match previous return type 'int' when block literal has unspecified explicit return type" } */
};
char *(^Z)(void) = ^{ /* { dg-error "cannot initialize a variable" } */
if (3)
return "";
else
return (char*)0; /* { dg-error "return type 'char *' must match previous return type 'const char *' when block literal has unspecified explicit return type" } */
};
double (^A)(void) = ^ { /* { dg-error "cannot initialize a variable" } */
if (1)
return (float)1.0;
else
if (2)
return (double)2.0; /* { dg-error "return type 'double' must match previous return type 'float' when block literal has unspecified explicit return type" } */
return 1; /* { dg-error "return type 'int' must match previous return type 'float' when block literal has unspecified explicit return type" } */
};
char *(^B)(void) = ^{ /* { dg-error "cannot initialize a variable" } */
if (3)
return "";
else
return 2; /* { dg-error "return type 'int' must match previous return type 'const char *' when block literal has unspecified explicit return type" } */
};
__block int i;
int& (^o)() = ^ int& {
int &ri = i;
return ri;
};
int (^o1)() = ^ {
int &ri = i;
return ri;
};
o() = 1;
return ^{ return 1; }; /* { dg-error "annot initialize return object of type" } */
}