Test that -Wauto-var-id fires in value-dependent contexts.

There was already a test that it did not fire in type-dependent contexts.
This was already behaving correctly.

llvm-svn: 158530
This commit is contained in:
Jordan Rose
2012-06-15 18:19:43 +00:00
parent e24d6a19e3
commit 7c0abc34f9

View 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
}