Home | History | Annotate | Download | only in Parser
      1 // RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s
      2 // RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -x objective-c++ %s
      3 void * proc();
      4 
      5 @interface NSConstantString
      6 @end
      7 
      8 @interface Frob
      9 @end
     10 
     11 @interface Frob1
     12 @end
     13 
     14 void * foo()
     15 {
     16   @try {
     17     return proc();
     18   }
     19   @catch (Frob* ex) {
     20     @throw;
     21   }
     22   @catch (Frob1* ex) {
     23     @throw proc();
     24   }
     25   @finally {
     26     @try {
     27       return proc();
     28     }
     29     @catch (Frob* ex) {
     30       @throw 1,2; // expected-error {{@throw requires an Objective-C object type ('int' invalid)}} \
     31 				  // expected-warning {{expression result unused}}
     32     }
     33     @catch (float x) {  // expected-error {{@catch parameter is not a pointer to an interface type}}
     34       
     35     }
     36     @catch(...) {
     37       @throw (4,3,proc()); // expected-warning {{expression result unused}} \
     38 						   // expected-warning {{expression result unused}}
     39     }
     40   }
     41 
     42   @try {  // expected-error {{@try statement without a @catch and @finally clause}}
     43     return proc();
     44   }
     45 }
     46 
     47 
     48 void bar()
     49 {
     50   @try {}// expected-error {{@try statement without a @catch and @finally clause}}
     51   @"s"; //  expected-warning {{result unused}}
     52 }
     53 
     54 void baz()
     55 {
     56   @try {}// expected-error {{@try statement without a @catch and @finally clause}}
     57   @try {}
     58   @finally {}
     59 }
     60 
     61 void noTwoTokenLookAheadRequiresABitOfFancyFootworkInTheParser() {
     62     @try {
     63         // Do something
     64     } @catch (...) {}
     65     @try {
     66         // Do something
     67     } @catch (...) {}
     68     return;
     69 }
     70 
     71