Douglas Gregor | d1377b2 | 2010-04-22 21:44:01 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
| 3 | @interface NSException |
| 4 | @end |
| 5 | |
| 6 | // @throw |
| 7 | template<typename T> |
| 8 | void throw_test(T value) { |
| 9 | @throw value; // expected-error{{@throw requires an Objective-C object type ('int' invalid)}} |
| 10 | } |
| 11 | |
| 12 | template void throw_test(NSException *); |
| 13 | template void throw_test(int); // expected-note{{in instantiation of}} |
| 14 | |
Douglas Gregor | 8fdc13a | 2010-04-22 22:01:21 +0000 | [diff] [blame] | 15 | // @synchronized |
| 16 | template<typename T> |
| 17 | void synchronized_test(T value) { |
| 18 | @synchronized (value) { // expected-error{{@synchronized requires an Objective-C object type ('int' invalid)}} |
| 19 | value = 0; |
| 20 | } |
| 21 | } |
Douglas Gregor | d1377b2 | 2010-04-22 21:44:01 +0000 | [diff] [blame] | 22 | |
Douglas Gregor | 8fdc13a | 2010-04-22 22:01:21 +0000 | [diff] [blame] | 23 | template void synchronized_test(NSException *); |
| 24 | template void synchronized_test(int); // expected-note{{in instantiation of}} |
Douglas Gregor | c3203e7 | 2010-04-22 23:10:45 +0000 | [diff] [blame] | 25 | |
| 26 | // fast enumeration |
| 27 | @interface NSArray |
| 28 | @end |
| 29 | |
| 30 | @interface NSString |
| 31 | @end |
| 32 | |
| 33 | struct vector {}; |
| 34 | |
| 35 | template<typename T> void eat(T); |
| 36 | |
| 37 | template<typename E, typename T> |
| 38 | void fast_enumeration_test(T collection) { |
| 39 | for (E element in collection) { // expected-error{{selector element type 'int' is not a valid object}} \ |
| 40 | // expected-error{{collection expression type 'vector' is not a valid object}} |
| 41 | eat(element); |
| 42 | } |
| 43 | |
| 44 | E element; |
| 45 | for (element in collection) // expected-error{{selector element type 'int' is not a valid object}} \ |
| 46 | // expected-error{{collection expression type 'vector' is not a valid object}} |
| 47 | eat(element); |
| 48 | |
| 49 | for (NSString *str in collection) // expected-error{{collection expression type 'vector' is not a valid object}} |
| 50 | eat(str); |
| 51 | |
| 52 | NSString *str; |
| 53 | for (str in collection) // expected-error{{collection expression type 'vector' is not a valid object}} |
| 54 | eat(str); |
| 55 | } |
| 56 | |
| 57 | template void fast_enumeration_test<NSString *>(NSArray*); |
| 58 | template void fast_enumeration_test<int>(NSArray*); // expected-note{{in instantiation of}} |
| 59 | template void fast_enumeration_test<NSString *>(vector); // expected-note{{in instantiation of}} |