2012-04-07 02:12:22 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-noreturn -fobjc-exceptions -Wno-objc-root-class %s
|
2009-07-23 07:56:57 +08:00
|
|
|
|
|
|
|
int test1() {
|
|
|
|
id a;
|
|
|
|
@throw a;
|
|
|
|
}
|
2009-10-27 09:59:05 +08:00
|
|
|
|
|
|
|
// PR5286
|
|
|
|
void test2(int a) {
|
|
|
|
while (1) {
|
|
|
|
if (a)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PR5286
|
2011-08-31 17:01:53 +08:00
|
|
|
void test3(int a) { // expected-warning {{function 'test3' could be declared with attribute 'noreturn'}}
|
2009-10-27 09:59:05 +08:00
|
|
|
while (1) {
|
|
|
|
if (a)
|
|
|
|
@throw (id)0;
|
|
|
|
}
|
|
|
|
}
|
2010-06-30 04:25:42 +08:00
|
|
|
|
|
|
|
// <rdar://problem/4289832> - This code always returns, we should not
|
|
|
|
// issue a noreturn warning.
|
|
|
|
@class NSException;
|
|
|
|
@class NSString;
|
|
|
|
NSString *rdar_4289832() { // no-warning
|
|
|
|
@try
|
|
|
|
{
|
|
|
|
return @"a";
|
|
|
|
}
|
|
|
|
@catch(NSException *exception)
|
|
|
|
{
|
|
|
|
return @"b";
|
|
|
|
}
|
|
|
|
@finally
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-10 08:56:20 +08:00
|
|
|
void exit(int) __attribute__((noreturn));
|
|
|
|
@interface rdar10098695
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation rdar10098695
|
|
|
|
- (void)method { // expected-warning{{method 'method' could be declared with attribute 'noreturn'}}
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
@end
|