Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
| 3 | typedef unsigned int size_t; |
| 4 | @protocol P @end |
| 5 | |
| 6 | @interface NSMutableArray |
| 7 | - (id)objectAtIndexedSubscript:(size_t)index; |
| 8 | - (void)setObject:(id)object atIndexedSubscript:(size_t)index; |
| 9 | @end |
| 10 | |
| 11 | @interface NSMutableDictionary |
| 12 | - (id)objectForKeyedSubscript:(id)key; |
| 13 | - (void)setObject:(id)object forKeyedSubscript:(size_t)key; |
| 14 | @end |
| 15 | |
| 16 | id func() { |
| 17 | NSMutableArray *array; |
| 18 | float f; |
Fariborz Jahanian | a78eca2 | 2012-03-28 17:56:49 +0000 | [diff] [blame] | 19 | array[f] = array; // expected-error {{indexing expression is invalid because subscript type 'float' is not an intergal or objective-C pointer type}} |
| 20 | return array[3.14]; // expected-error {{indexing expression is invalid because subscript type 'double' is not an intergal or objective-C pointer type}} |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | void test_unused() { |
| 24 | NSMutableArray *array; |
| 25 | array[10]; // expected-warning {{container access result unused - container access should not be used for side effects}} |
| 26 | |
| 27 | NSMutableDictionary *dict; |
| 28 | dict[array]; // expected-warning {{container access result unused - container access should not be used for side effects}} |
| 29 | } |
| 30 | |