summaryrefslogtreecommitdiff
path: root/gcc/testsuite/obj-c++.dg/try-catch-8.mm
blob: b66662370259ba8dc568e6db75f303f211f82f91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* Test for graceful compilation of @synchronized statements.  */

/* { dg-do compile } */
/* { dg-options "-fobjc-exceptions" } */

#include "../objc-obj-c++-shared/Object1.h"

@interface Derived: Object
- (id) meth;
@end

@implementation Derived
- (id) meth {
  return self;
}

static Derived* rewriteDict(void) {
  static Derived *sDict = 0;
  if (sDict == 0) {
    @synchronized ([Derived class]) {
      if (sDict == 0)
	sDict = [Derived new];
    }
  } 
  return sDict;
}
@end