diff options
| author | Steve Naroff <snaroff@apple.com> | 2008-09-05 22:11:13 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2008-09-05 22:11:13 +0000 |
| commit | 8de9c3affe72973ac5ca8a660a10a7fe45fc31cd (patch) | |
| tree | f4cfeb4a55a457be603c3b9e65d84d32b351a57b /clang/test/Sema/block-misc.c | |
| parent | d94269f90662c46410f244db8b7803ce019f4300 (diff) | |
| download | bcm5719-llvm-8de9c3affe72973ac5ca8a660a10a7fe45fc31cd.tar.gz bcm5719-llvm-8de9c3affe72973ac5ca8a660a10a7fe45fc31cd.zip | |
More type checking for blocks. Still incomplete (will hopefully finish up this weekend).
llvm-svn: 55862
Diffstat (limited to 'clang/test/Sema/block-misc.c')
| -rw-r--r-- | clang/test/Sema/block-misc.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/clang/test/Sema/block-misc.c b/clang/test/Sema/block-misc.c new file mode 100644 index 00000000000..92632f3aaa1 --- /dev/null +++ b/clang/test/Sema/block-misc.c @@ -0,0 +1,50 @@ +// RUN: clang -fsyntax-only -verify %s +void donotwarn(); + +int (^IFP) (); +int (^II) (int); +int test1() { + int (^PFR) (int) = 0; // OK + PFR = II; // OK + + if (PFR == II) // OK + donotwarn(); + + if (PFR == IFP) // expected-error {{comparison of distinct block types}} + donotwarn(); + + if (PFR == (int (^) (int))IFP) // OK + donotwarn(); + + if (PFR == 0) // OK + donotwarn(); + + if (PFR) // OK + donotwarn(); + + if (!PFR) // OK + donotwarn(); + + return PFR != IFP; // expected-error {{comparison of distinct block types}} +} + +int test2(double (^S)()) { + double (^I)(int) = (void*) S; + (void*)I = (void *)S; // expected-error {{expression is not assignable}} + + void *pv = I; + + pv = S; + + I(1); + + return (void*)I == (void *)S; +} + +int^ x; // expected-error {{block pointer to non-function type is invalid}} +int^^ x1; // expected-error {{block pointer to non-function type is invalid}} + +int test3() { + char *^ y; // expected-error {{block pointer to non-function type is invalid}} +} + |

