blob: ecee7be629c342686434f08f85d8659195f28e6a [file] [log] [blame]
Fariborz Jahanian8cecfe92012-08-10 18:10:56 +00001// RUN: %clang_cc1 -x objective-c++ -fcxx-exceptions -fsyntax-only -Werror -verify -Wno-objc-root-class %s
Andy Gibbsc6e68da2012-10-19 12:44:48 +00002// expected-no-diagnostics
Fariborz Jahanian8cecfe92012-08-10 18:10:56 +00003// rdar://10387088
4
5@interface MyClass
6- (void)someMethod;
7@end
8
9struct BadReturn {
10 BadReturn(MyClass * myObject);
11 int bar(MyClass * myObject);
Fariborz Jahanian053227f2012-08-10 20:34:17 +000012 void MemFunc(MyClass * myObject);
Fariborz Jahanian8cecfe92012-08-10 18:10:56 +000013 int i;
Fariborz Jahanian053227f2012-08-10 20:34:17 +000014 MyClass *CObj;
Fariborz Jahanian8cecfe92012-08-10 18:10:56 +000015};
16
17@implementation MyClass
18- (void)someMethod {
19 [self privateMethod]; // clang already does not warn here
20}
21
22int BadReturn::bar(MyClass * myObject) {
23 [myObject privateMethod];
24 return 0;
25}
26
Fariborz Jahanian053227f2012-08-10 20:34:17 +000027BadReturn::BadReturn(MyClass * myObject) try : CObj(myObject) {
Fariborz Jahanian8cecfe92012-08-10 18:10:56 +000028} catch(...) {
29 try {
30 [myObject privateMethod];
31 [myObject privateMethod1];
32 getMe = bar(myObject);
Fariborz Jahanian053227f2012-08-10 20:34:17 +000033 [CObj privateMethod1];
34 } catch(int ei) {
35 i = ei;
36 } catch(...) {
37 {
38 i = 0;
39 }
40 }
41}
42
43void BadReturn::MemFunc(MyClass * myObject) try {
44} catch(...) {
45 try {
46 [myObject privateMethod];
47 [myObject privateMethod1];
48 getMe = bar(myObject);
49 [CObj privateMethod1];
Fariborz Jahanian8cecfe92012-08-10 18:10:56 +000050 } catch(int ei) {
51 i = ei;
52 } catch(...) {
53 {
54 i = 0;
55 }
56 }
57}
58
59- (void)privateMethod { }
60
61- (void)privateMethod1 {
62 getMe = getMe+1;
63}
64
65static int getMe;
66
67@end