[cfe-dev] Obj-C Retain Property Issues

Keaton Mowery kmowery at ucsd.edu
Thu Dec 15 14:37:27 PST 2011


Hi all,

I'm encountering an issue with LLVM/Clang's handling of Objective-C
properties. Notably, adding the retain property to a non-NSObject is
failing, even when the retain property can still be applied. Here's a
minimal testcase:

main.m
------------------
#import <Foundation/Foundation.h>

@interface Foo : NSObject {
  CFDictionaryRef dict;
}
@property (nonatomic, retain) __attribute__((NSObject)) CFDictionaryRef dict;
@end
@implementation Foo @synthesize dict; @end
------------------

When compiled via llvm/clang (svn r146687), this generates an error:
    main.m:7:1: error: property with 'retain (or strong)' attribute
must be of object type
    @property (nonatomic, retain) __attribute__((NSObject))
CFDictionaryRef dict;

When using the clang shipped with OSX (Apple clang version 3.0
(tags/Apple/clang-211.12) (based on LLVM 3.0svn)), this compiles
properly.

The issue crops up when including the system header at
/System/Library/Frameworks/AVFoundation.framework/Headers/AVVideoComposition.h:112,
which leads me to believe that this is proper Objective-C syntax.

Does anyone know what the problem might be?

Thank you!

Keaton Mowery



More information about the cfe-dev mailing list