[LLVMbugs] [Bug 11237] New: ARC: Warning when setter declared alongside property cannot be satisfied

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Oct 26 10:24:53 PDT 2011


           Summary: ARC: Warning when setter declared alongside property
                    cannot be satisfied
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jeremyw.sherman at gmail.com
                CC: llvmbugs at cs.uiuc.edu

Created an attachment (id=7534)
 --> (http://llvm.org/bugs/attachment.cgi?id=7534)
Minimal example reproducing the problem.

When compiling a class that declares both a setter and a property using
`-fobjc-arc`, a warning is given about a type mismatch between the setter
declaration and the property declaration. This mismatch cannot be addressed by
changing the type of the setter argument, as you can see by changing the
ownership qualification of the setter argument variable and recompiling with
each different qualifier in turn.

Declaring the setter the exact same way in the @implementation block
rather than the @interface block does NOT trigger any warning.

The warning is also frustrating: it says there is a type mismatch, but it does
not name the types involved in the mismatch so that you can see what's
mismatched and how.

Code reproducing the problem follows and is also attached:
//clang -fobjc-arc -c weak_prop.m -o weak_prop
> weak_prop.m:25:33: warning: type of property 'child' does not match type of accessor 'setChild:'
> @property(strong, nonatomic) id child;
>                                 ^
> weak_prop.m:24:1: note: declared here
> - (void)setChild:(__strong id)child;
> ^
> 1 warning generated.

Problem only occurs when compiling with -fobjc-arc.

No matter what type is given to chind in -setChild:, the same warning is given.
Whether the setter declaration precedes or follows the property declaration
has no effect.

Declaring the setter as - (void)setChild:(id)child in the @implementation block
does NOT trigger any warning.
Only doing so in the @interface block triggers the warning.

@interface Foo
- (id)child;  // Doesn't care about getter.
- (void)setChild:(__strong id)child;
@property(strong, nonatomic) id child;

System information:
$ clang --version
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.2.0
Thread model: posix
$ sw_vers
ProductName:    Mac OS X
ProductVersion:    10.7.2
BuildVersion:    11C74
$ uname -a
Darwin Hermes.local 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug  9 20:54:00
PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list