| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-noreturn -fobjc-exceptions -Wno-objc-root-class %s |
| 2 |
|
| 3 |
int test1(void) { |
| 4 |
id a; |
| 5 |
@throw a; |
| 6 |
} |
| 7 |
|
| 8 |
// PR5286 |
| 9 |
void test2(int a) { |
| 10 |
while (1) { |
| 11 |
if (a) |
| 12 |
return; |
| 13 |
} |
| 14 |
} |
| 15 |
|
| 16 |
// PR5286 |
| 17 |
void test3(int a) { // expected-warning {{function 'test3' could be declared with attribute 'noreturn'}} |
| 18 |
while (1) { |
| 19 |
if (a) |
| 20 |
@throw (id)0; |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
// This code always returns, we should not issue a noreturn warning. |
| 25 |
@class NSException; |
| 26 |
@class NSString; |
| 27 |
NSString *rdar_4289832(void) { // no-warning |
| 28 |
@try |
| 29 |
{ |
| 30 |
return @"a"; |
| 31 |
} |
| 32 |
@catch(NSException *exception) |
| 33 |
{ |
| 34 |
return @"b"; |
| 35 |
} |
| 36 |
@finally |
| 37 |
{ |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
void exit(int) __attribute__((noreturn)); |
| 42 |
@interface rdar10098695 |
| 43 |
@end |
| 44 |
|
| 45 |
@implementation rdar10098695 |
| 46 |
- (void)method { // expected-warning{{method 'method' could be declared with attribute 'noreturn'}} |
| 47 |
exit(1); |
| 48 |
} |
| 49 |
@end |