1// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s 2 3@interface NSException 4@end 5 6// @throw 7template<typename T> 8void throw_test(T value) { 9 @throw value; // expected-error{{@throw requires an Objective-C object type ('int' invalid)}} 10} 11 12template void throw_test(NSException *); 13template void throw_test(int); // expected-note{{in instantiation of}} 14 15// @synchronized 16template<typename T> 17void synchronized_test(T value) { 18 @synchronized (value) { // expected-error{{@synchronized requires an Objective-C object type ('int' invalid)}} 19 value = 0; 20 } 21} 22 23template void synchronized_test(NSException *); 24template void synchronized_test(int); // expected-note{{in instantiation of}} 25 26// fast enumeration 27@interface NSArray 28- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount; 29@end 30 31@interface NSString 32@end 33 34struct vector {}; 35 36template<typename T> void eat(T); 37 38template<typename E, typename T> 39void fast_enumeration_test(T collection) { 40 for (E element in collection) { // expected-error{{selector element type 'int' is not a valid object}} \ 41 // expected-error{{the type 'vector' is not a pointer to a fast-enumerable object}} 42 eat(element); 43 } 44 45 E element; 46 for (element in collection) // expected-error{{selector element type 'int' is not a valid object}} \ 47 // expected-error{{the type 'vector' is not a pointer to a fast-enumerable object}} 48 eat(element); 49 50 for (NSString *str in collection) // expected-error{{the type 'vector' is not a pointer to a fast-enumerable object}} 51 eat(str); 52 53 NSString *str; 54 for (str in collection) // expected-error{{the type 'vector' is not a pointer to a fast-enumerable object}} 55 eat(str); 56} 57 58template void fast_enumeration_test<NSString *>(NSArray*); 59template void fast_enumeration_test<int>(NSArray*); // expected-note{{in instantiation of}} 60template void fast_enumeration_test<NSString *>(vector); // expected-note{{in instantiation of}} 61 62// @try/@catch/@finally 63 64template<typename T, typename U> 65void try_catch_finally_test(U value) { 66 @try { 67 value = 1; // expected-error{{incompatible integer to pointer conversion assigning to 'int *' from 'int'}} 68 } 69 @catch (T obj) { // expected-error{{@catch parameter is not a pointer to an interface type}} 70 id x = obj; 71 } @finally { 72 value = 0; 73 } 74} 75 76template void try_catch_finally_test<NSString *>(int); 77template void try_catch_finally_test<NSString *>(int*); // expected-note{{in instantiation of}} 78template void try_catch_finally_test<NSString>(int); // expected-note{{in instantiation of function template specialization 'try_catch_finally_test<NSString, int>' requested here}} 79