xref: /llvm-project/clang/test/SemaObjC/objc-independent-class-attribute.m (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2
3@interface NSObject @end
4
5typedef NSObject * __attribute__((objc_independent_class))dispatch_queue_t;
6
7typedef struct S {int ii; } * __attribute__((objc_independent_class))dispatch_queue_t_2; // expected-warning {{Objective-C object}}
8
9typedef struct { // expected-warning {{'objc_independent_class' attribute may be put on a typedef only; attribute is ignored}}
10   NSObject *__attribute__((objc_independent_class)) ns; // expected-warning {{'objc_independent_class' attribute may be put on a typedef only; attribute is ignored}}
11} __attribute__((objc_independent_class)) T;
12
13dispatch_queue_t dispatch_queue_create(void);
14
15@interface DispatchQPointerCastIssue : NSObject {
16  NSObject *__attribute__((objc_independent_class)) Ivar; // expected-warning {{'objc_independent_class' attribute may be put on a typedef only; attribute is ignored}}
17}
18
19@property (copy) NSObject *__attribute__((objc_independent_class)) Prop; // expected-warning {{'objc_independent_class' attribute may be put on a typedef only; attribute is ignored}}
20
21typedef NSObject * __attribute__((objc_independent_class))dispatch_queue_t_1;
22
23@end
24
25@implementation DispatchQPointerCastIssue
26+ (dispatch_queue_t) newDispatchQueue {
27    return dispatch_queue_create();
28}
29@end
30
31NSObject *get_nsobject(void) {
32  typedef NSObject * __attribute__((objc_independent_class))dispatch_queue_t;
33  dispatch_queue_t dt;
34  return dt;
35}
36