Merged r157896 through r158228 into branch.
[official-gcc.git] / gcc / testsuite / objc.dg / objc-gc-4.m
blob097f35e9f2512591e4f2d63907a677f33ef83dd2
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 } */
6 /* { dg-options "-fobjc-gc" } */
7 /* { dg-prune-output "cc1obj: warning: '-fobjc-gc' is ignored for '-fgnu-runtime'" } */
9 #include "../objc-obj-c++-shared/Object1.h"
11 @class MyWindow;
13 @interface MyDocument : Object {
14     MyWindow *_window;
16 @end
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;
29 @end
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;
47 @end
49 @interface MyRTFFileDocument : MyTextFileDocument
50 - (BOOL)readFromFile:(const char *)fileName ofType:(const char *)type;
51 @end
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);
64 @end