Merge reload-branch up to revision 101000
[official-gcc.git] / gcc / testsuite / obj-c++.dg / objc-gc-3.mm
blobdf0a44cd8dd4fd24d73776732f2083c349c7dae0
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>  */
5 /* { dg-do compile { target *-*-darwin* } } */
6 /* { dg-options "-fobjc-gc" } */
8 #include <objc/Object.h>
10 @class MyWindow;
12 @interface MyDocument : Object {
13     MyWindow *_window;
15 @end
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;
28 @end
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;
46 @end
48 @interface MyRTFFileDocument : MyTextFileDocument
49 - (BOOL)readFromFile:(const char *)fileName ofType:(const char *)type;
50 @end
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);
63 @end