]> granicus.if.org Git - clang/commitdiff
Test that -Wauto-var-id fires in value-dependent contexts.
authorJordan Rose <jordan_rose@apple.com>
Fri, 15 Jun 2012 18:19:43 +0000 (18:19 +0000)
committerJordan Rose <jordan_rose@apple.com>
Fri, 15 Jun 2012 18:19:43 +0000 (18:19 +0000)
There was already a test that it did not fire in type-dependent contexts.
This was already behaving correctly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158530 91177308-0d34-0410-b5e6-96231b3b80d8

test/SemaObjCXX/arc-0x.mm

index 88b3ab11786440862e2b407f25ef306a3afa8472..49ce145438e4251e8714fab1243368b734183a6b 100644 (file)
@@ -60,15 +60,21 @@ 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>
-void autoTemplateFunction(T param, id obj) {
+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(obj, obj); // no-warning
+  autoTemplateFunction<id, 2>(obj, obj, [Array new]); // no-warning
 }