diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-06-08 22:46:07 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-06-08 22:46:07 +0000 |
commit | 0abbdfe561377b7af8eba6fc87757a46342f7a10 (patch) | |
tree | 239e1d36459d9d79064d536ef3690e8dacb58778 /include/clang | |
parent | 1fdda369d3b94dae227abda0a10522fb60647d35 (diff) |
Warn in ObjC++ when an 'auto' variable deduces type 'id'.
This could happen for cases like this:
- (NSArray *)getAllNames:(NSArray *)images {
NSMutableArray *results = [NSMutableArray array];
for (auto img in images) {
[results addObject:img.name];
}
return results;
}
Here the property access will fail because 'img' has type 'id', rather than,
say, NSImage.
This warning will not fire in templated code, since the 'id' could have
come from a template parameter.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158239 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index e50138dccf..235c6abdae 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -1469,6 +1469,10 @@ def warn_cxx98_compat_unicode_type : Warning< // Objective-C++ def err_objc_decls_may_only_appear_in_global_scope : Error< "Objective-C declarations may only appear in global scope">; +def warn_auto_var_is_id : Warning< + "'auto' deduced as 'id' in declaration of %0">, + InGroup<DiagGroup<"auto-var-id">>; + // Attributes def err_nsobject_attribute : Error< "__attribute ((NSObject)) is for pointer types only">; |