Steve Naroff | dd972f2 | 2008-09-05 22:11:13 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | void donotwarn(); |
| 3 | |
| 4 | int (^IFP) (); |
| 5 | int (^II) (int); |
| 6 | int test1() { |
| 7 | int (^PFR) (int) = 0; // OK |
| 8 | PFR = II; // OK |
| 9 | |
| 10 | if (PFR == II) // OK |
| 11 | donotwarn(); |
| 12 | |
| 13 | if (PFR == IFP) // expected-error {{comparison of distinct block types}} |
| 14 | donotwarn(); |
| 15 | |
| 16 | if (PFR == (int (^) (int))IFP) // OK |
| 17 | donotwarn(); |
| 18 | |
| 19 | if (PFR == 0) // OK |
| 20 | donotwarn(); |
| 21 | |
| 22 | if (PFR) // OK |
| 23 | donotwarn(); |
| 24 | |
| 25 | if (!PFR) // OK |
| 26 | donotwarn(); |
| 27 | |
| 28 | return PFR != IFP; // expected-error {{comparison of distinct block types}} |
| 29 | } |
| 30 | |
| 31 | int test2(double (^S)()) { |
| 32 | double (^I)(int) = (void*) S; |
| 33 | (void*)I = (void *)S; // expected-error {{expression is not assignable}} |
| 34 | |
| 35 | void *pv = I; |
| 36 | |
| 37 | pv = S; |
| 38 | |
| 39 | I(1); |
| 40 | |
| 41 | return (void*)I == (void *)S; |
| 42 | } |
| 43 | |
| 44 | int^ x; // expected-error {{block pointer to non-function type is invalid}} |
| 45 | int^^ x1; // expected-error {{block pointer to non-function type is invalid}} |
| 46 | |
| 47 | int test3() { |
| 48 | char *^ y; // expected-error {{block pointer to non-function type is invalid}} |
| 49 | } |
| 50 | |
Chris Lattner | f7037b1 | 2008-09-28 05:30:26 +0000 | [diff] [blame^] | 51 | |
| 52 | |
| 53 | enum {NSBIRLazilyAllocated = 0}; |
| 54 | |
| 55 | int test4(int argc) { // rdar://6251437 |
| 56 | ^{ |
| 57 | switch (argc) { |
| 58 | case NSBIRLazilyAllocated: // is an integer constant expression. |
| 59 | default: |
| 60 | break; |
| 61 | } |
| 62 | }(); |
| 63 | return 0; |
| 64 | } |