diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
commit | 56d91b49b13fe55c918afbda19f6165b5fbff87a (patch) | |
tree | 9abb1a658a297776086f4e0dfa6ca533de02104e /test/SemaObjCXX/arc-0x.mm | |
parent | 41e20f564abdb05101d6b2b29c59459a966c22cc (diff) |
Vendor import of clang trunk r161861:vendor/clang/clang-trunk-r161861
Notes
Notes:
svn path=/vendor/clang/dist/; revision=239313
svn path=/vendor/clang/clang-trunk-r161861/; revision=239314; tag=vendor/clang/clang-trunk-r161861
Diffstat (limited to 'test/SemaObjCXX/arc-0x.mm')
-rw-r--r-- | test/SemaObjCXX/arc-0x.mm | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/test/SemaObjCXX/arc-0x.mm b/test/SemaObjCXX/arc-0x.mm index 28eec51775bd..e24b9602fb7f 100644 --- a/test/SemaObjCXX/arc-0x.mm +++ b/test/SemaObjCXX/arc-0x.mm @@ -11,6 +11,9 @@ void move_it(__strong id &&from) { - init; @end +// <rdar://problem/12031870>: don't warn about this +extern "C" A* MakeA(); + // Ensure that deduction works with lifetime qualifiers. void deduction(id obj) { auto a = [[A alloc] init]; @@ -22,7 +25,7 @@ void deduction(id obj) { __strong id *idp = new auto(obj); __strong id array[17]; - for (auto x : array) { + for (auto x : array) { // expected-warning{{'auto' deduced as 'id' in declaration of 'x'}} __strong id *xPtr = &x; } @@ -51,3 +54,30 @@ void test1c() { (void) ^{ (void) p; }; (void) ^{ (void) v; }; // expected-error {{cannot capture __autoreleasing variable in a block}} } + + +// <rdar://problem/11319689> +// warn when initializing an 'auto' variable with an 'id' initializer expression + +void testAutoId(id obj) { + auto x = obj; // expected-warning{{'auto' deduced as 'id' in declaration of 'x'}} +} + +@interface Array ++ (instancetype)new; +- (id)objectAtIndex:(int)index; +@end + +// ...but don't warn if it's coming from a template parameter. +template<typename T, int N> +void autoTemplateFunction(T param, id obj, Array *arr) { + auto x = param; // no-warning + auto y = obj; // expected-warning{{'auto' deduced as 'id' in declaration of 'y'}} + auto z = [arr objectAtIndex:N]; // expected-warning{{'auto' deduced as 'id' in declaration of 'z'}} +} + +void testAutoIdTemplate(id obj) { + autoTemplateFunction<id, 2>(obj, obj, [Array new]); // no-warning +} + + |