[cfe-dev] False positive warning: "warning: 'terminate:' is deprecated"?

John McCall rjmccall at apple.com
Mon Dec 12 11:47:39 PST 2011


On Dec 12, 2011, at 11:10 AM, jahanian wrote:
> On Dec 12, 2011, at 10:34 AM, Eli Friedman wrote:
>> On Mon, Dec 12, 2011 at 10:17 AM, Sean McBride <sean at rogue-research.com> wrote:
>>> Hi all,
>>> 
>>> With clang version 3.1 (trunk 146375) the code below generates a false positive warning:
>>> 
>>> test.m:7:6: warning: 'terminate:' is deprecated [-Wdeprecated-declarations]
>>>   [NSApp terminate:nil];
>>>    ^
>>> 
>>> As best as I can tell, that method is not deprecated.  The global variable NSApp is declared as 'id'.  If I cast it to NSApplication* the warning goes away.  This warning did not occur a few weeks ago, nor does it with gcc.
>>> 
>>> Is it a bug or am I missing something?
>> 
>> This change was made intentionally in r145999.  There are multiple
>> methods called terminate in Cocoa.h, and one of them (specifically,
>> the one on NSInputServiceProvider) is deprecated.  It's possible the
>> heuristic and/or the headers need tweaks.
> 
> That is correct. This was intentionally done on user request when receiver type is 'id' and there is at least one deprecated method
> of the given name. Type-cast always removes the warning.

Yeah, I don't think there's a better option right now.  There are things we could
do if we had "bounded bottom" typing, e.g. something with the message-send
behavior of id but with a guaranteed minimum protocol.  But we don't.

John.



More information about the cfe-dev mailing list