1// RUN: %clang_cc1 -x objective-c++ -fcxx-exceptions -fsyntax-only -Werror -verify -Wno-objc-root-class %s
2// rdar://10387088
3
4@interface MyClass
5- (void)someMethod;
6@end
7
8struct BadReturn {
9  BadReturn(MyClass * myObject);
10  int bar(MyClass * myObject);
11  void MemFunc(MyClass * myObject);
12  int i;
13  MyClass *CObj;
14};
15
16@implementation MyClass
17- (void)someMethod {
18    [self privateMethod];  // clang already does not warn here
19}
20
21int BadReturn::bar(MyClass * myObject) {
22    [myObject privateMethod];
23    return 0;
24}
25
26BadReturn::BadReturn(MyClass * myObject) try : CObj(myObject) {
27} catch(...) {
28  try {
29    [myObject privateMethod];
30    [myObject privateMethod1];
31    getMe = bar(myObject); // expected-error {{cannot refer to a non-static member from the handler of a constructor function try block}}
32    [CObj privateMethod1]; // expected-error {{cannot refer to a non-static member from the handler of a constructor function try block}}
33  } catch(int ei) {
34    i = ei; // expected-error {{cannot refer to a non-static member from the handler of a constructor function try block}}
35  } catch(...) {
36    {
37      i = 0; // expected-error {{cannot refer to a non-static member from the handler of a constructor function try block}}
38    }
39  }
40}
41
42void BadReturn::MemFunc(MyClass * myObject) try {
43} catch(...) {
44  try {
45    [myObject privateMethod];
46    [myObject privateMethod1];
47    getMe = bar(myObject);
48    [CObj privateMethod1];
49  } catch(int ei) {
50    i = ei;
51  } catch(...) {
52    {
53      i = 0;
54    }
55  }
56}
57
58- (void)privateMethod { }
59
60- (void)privateMethod1 {
61  getMe = getMe+1;
62}
63
64static int getMe;
65
66@end
67