https://llvm.org/bugs/show_bug.cgi?id=24328
Bug ID: 24328 Summary: clang should warn returning nil from Obj-C method that returns nonnull Product: new-bugs Version: trunk Hardware: Macintosh OS: MacOS X Status: NEW Severity: normal Priority: P Component: new bugs Assignee: unassignedb...@nondot.org Reporter: s...@rogue-research.com CC: llvmbugs@cs.uiuc.edu Classification: Unclassified Created attachment 14678 --> https://llvm.org/bugs/attachment.cgi?id=14678&action=edit repro case clang warns if a C function with "nonnull" specified on the return value actually does returns null. That's good. It should, but doesn't, do the same for Obj-C methods. Consider attached sample: ----------------------------------------------- #import <Foundation/Foundation.h> @interface MyObj : NSObject @end @implementation MyObj + (nonnull id)method { return nil; // WANT WARNING HERE } @end static void* __nonnull MyFunction (void) { return NULL; } int main(void) { MyFunction(); [MyObj method]; return 0; } ----------------------------------------------- built with: clang version 3.8.0 (trunk 243643) Target: x86_64-apple-darwin14.4.0 Thread model: posix clang -fsyntax-only -Weverything test.m gives: test.m:15:2: warning: null returned from function that requires a non-null return value [-Wnonnull] return NULL; ^ ~~~~ ie, works for function, but not method. (Xcode 6.4 and 7.0b4 clang also fail to warn, see <rdar://22093658>.) -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ LLVMbugs mailing list LLVMbugs@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs