blob: f46b4b01a5ff74a6a04970e3682d90ca2835f166 [file] [log] [blame]
John McCall260611a2012-06-20 06:18:46 +00001// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 -fobjc-exceptions -verify %s -o -
Steve Naroff8c565152008-12-05 17:03:39 +00002
3int main() {
4 @try {
Jean-Daniel Dupas5faf5d32012-01-27 23:21:02 +00005 printf("executing try"); // expected-warning{{implicitly declaring library function 'printf' with type 'int (const char *, ...)'}} \
Douglas Gregora316e7b2009-02-14 00:32:47 +00006 // expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
Steve Naroff8c565152008-12-05 17:03:39 +00007 return(0); // expected-warning{{rewriter doesn't support user-specified control flow semantics for @try/@finally (code may not execute properly)}}
8 } @finally {
9 printf("executing finally");
10 }
11 while (1) {
12 @try {
13 printf("executing try");
Steve Naroffb85e77a2009-12-05 21:43:12 +000014 break;
Steve Naroff8c565152008-12-05 17:03:39 +000015 } @finally {
16 printf("executing finally");
17 }
18 printf("executing after finally block");
19 }
20 @try {
21 printf("executing try");
22 } @finally {
23 printf("executing finally");
24 }
25 return 0;
26}
27
Steve Naroffb85e77a2009-12-05 21:43:12 +000028void test_sync_with_implicit_finally() {
29 id foo;
30 @synchronized (foo) {
31 return; // The rewriter knows how to generate code for implicit finally
32 }
33}
34
35void test2_try_with_implicit_finally() {
36 @try {
37 return; // The rewriter knows how to generate code for implicit finally
38 } @catch (id e) {
39
40 }
41}
42