OSDN Git Service

PR fortran/30964
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / obj-c++.dg / objc-gc-3.mm
1 /* Test looking up fields in superclasses in the context of write-barriers
2    (where component references get rewritten).  */
3 /* Contributed by Ziemowit Laski <zlaski@apple.com>  */
4
5 /* { dg-do compile { target *-*-darwin* } } */
6 /* { dg-options "-fobjc-gc" } */
7
8 #include <objc/Object.h>
9
10 @class MyWindow;
11
12 @interface MyDocument : Object {
13     MyWindow *_window;
14 }
15 @end
16
17 @interface MyFileDocument : MyDocument {
18      struct {
19         unsigned int autoClose:1;
20         unsigned int openForUI:1;
21         unsigned int isClosing:1;
22         unsigned int needsDiskCheck:1;
23         unsigned int isWritable:1;
24         unsigned int representsFileOnDisk:1;
25         unsigned int RESERVED:26;
26     } _fdFlags;
27 }
28 @end
29
30 @interface MyTextFileDocument : MyFileDocument {
31     Object *_textStorage;
32     struct __tfdFlags {
33         unsigned int immutable:1;
34         unsigned int lineEnding:2;
35         unsigned int isClosing:1;
36         unsigned int settingsAreSet:1;
37         unsigned int usesTabs:1;
38         unsigned int isUTF8WithBOM:1;
39         unsigned int wrapsLines:1;
40         unsigned int usingDefaultLanguage:1;
41         unsigned int RESERVED:23;
42     } _tfdFlags;
43     int _tabWidth;
44     int _indentWidth;
45 }
46 @end
47
48 @interface MyRTFFileDocument : MyTextFileDocument
49 - (BOOL)readFromFile:(const char *)fileName ofType:(const char *)type;
50 @end
51
52 @implementation MyRTFFileDocument
53 - (BOOL)readFromFile:(const char *)fileName ofType:(const char *)type {
54         if (_textStorage && fileName) {
55             [_textStorage free];
56             return YES;
57         } else if (type) {
58             _textStorage = [MyRTFFileDocument new];
59             return NO;
60         }
61    return (fileName && type);
62 }
63 @end