OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / objc.dg / objc-gc-4.m
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 } */
6 /* { dg-options "-fobjc-gc" } */
7 /* { dg-prune-output "cc1obj: warning: '-fobjc-gc' is ignored for '-fgnu-runtime'" } */
8
9 #include "../objc-obj-c++-shared/Object1.h"
10
11 @class MyWindow;
12
13 @interface MyDocument : Object {
14     MyWindow *_window;
15 }
16 @end
17
18 @interface MyFileDocument : MyDocument {
19      struct {
20         unsigned int autoClose:1;
21         unsigned int openForUI:1;
22         unsigned int isClosing:1;
23         unsigned int needsDiskCheck:1;
24         unsigned int isWritable:1;
25         unsigned int representsFileOnDisk:1;
26         unsigned int RESERVED:26;
27     } _fdFlags;
28 }
29 @end
30
31 @interface MyTextFileDocument : MyFileDocument {
32     Object *_textStorage;
33     struct __tfdFlags {
34         unsigned int immutable:1;
35         unsigned int lineEnding:2;
36         unsigned int isClosing:1;
37         unsigned int settingsAreSet:1;
38         unsigned int usesTabs:1;
39         unsigned int isUTF8WithBOM:1;
40         unsigned int wrapsLines:1;
41         unsigned int usingDefaultLanguage:1;
42         unsigned int RESERVED:23;
43     } _tfdFlags;
44     int _tabWidth;
45     int _indentWidth;
46 }
47 @end
48
49 @interface MyRTFFileDocument : MyTextFileDocument
50 - (BOOL)readFromFile:(const char *)fileName ofType:(const char *)type;
51 @end
52
53 @implementation MyRTFFileDocument
54 - (BOOL)readFromFile:(const char *)fileName ofType:(const char *)type {
55         if (_textStorage && fileName) {
56             [_textStorage free];
57             return YES;
58         } else if (type) {
59             _textStorage = [MyRTFFileDocument new];
60             return NO;
61         }
62    return (fileName && type);
63 }
64 @end